-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a cron job to test OSV API on test instance (#2540)
Our test instance lacks real-life traffic, making it difficult to catch API query errors. Converting [tools/api-performance-test](https://github.com/google/osv.dev/tree/master/tools/api-performance-test) into a cron job that runs for one hour daily. This job will send traffic to the test instance's API, helping us identify errors before deploying changes to production. The [tools/api-performance-test ](https://github.com/google/osv.dev/tree/master/tools/api-performance-test)script will be deleted once the cron job is running stably.
- Loading branch information
Showing
8 changed files
with
693 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
deployment/clouddeploy/gke-workers/environments/oss-vdb-test/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
resources: | ||
- ../../base | ||
- staging-api-test.yaml | ||
patches: | ||
- path: workers.yaml | ||
- path: scaler.yaml | ||
|
26 changes: 26 additions & 0 deletions
26
deployment/clouddeploy/gke-workers/environments/oss-vdb-test/staging-api-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: staging-api-test | ||
spec: | ||
schedule: "50 9 * * *" | ||
concurrencyPolicy: Forbid | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: staging-api-test | ||
image: staging-api-test | ||
imagePullPolicy: Always | ||
env: | ||
- name: GOOGLE_CLOUD_PROJECT | ||
value: "oss-vdb-test" | ||
resources: | ||
requests: | ||
cpu: 1.5 | ||
memory: "4G" | ||
limits: | ||
cpu: 2 | ||
memory: "10G" | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM gcr.io/oss-vdb/worker | ||
|
||
WORKDIR /staging_api_test | ||
|
||
COPY retrieve_bugs_from_db.py perform_api_calls.py run.sh ./ | ||
|
||
# Add aiohttp lib | ||
RUN cd /env/docker/worker && POETRY_VIRTUALENVS_CREATE=false poetry add aiohttp | ||
|
||
RUN chmod 755 retrieve_bugs_from_db.py perform_api_calls.py run.sh | ||
|
||
ENTRYPOINT ["./run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash -x | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
docker build -t gcr.io/oss-vdb-test/staging-api-test:$1 . && \ | ||
docker build -t gcr.io/oss-vdb-test/staging-api-test:latest . && \ | ||
docker push gcr.io/oss-vdb-test/staging-api-test:$1 && \ | ||
docker push gcr.io/oss-vdb-test/staging-api-test:latest |
Oops, something went wrong.