Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a cron job to test OSV API on test instance #2540

Merged
merged 10 commits into from
Sep 9, 2024
12 changes: 12 additions & 0 deletions deployment/build-and-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ steps:
args: ['push', '--all-tags', 'gcr.io/oss-vdb/alias-computation']
waitFor: ['build-alias-computation', 'cloud-build-queue']

# Build/push staging-api-test images to gcr.io/oss-vdb-test.
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/oss-vdb-test/staging-api-test:latest', '-t', 'gcr.io/oss-vdb-test/staging-api-test:$COMMIT_SHA', '.']
dir: 'docker/staging_api_test'
id: 'build-staging-api-test'
waitFor: ['build-worker']
- name: gcr.io/cloud-builders/docker
args: ['push', '--all-tags', 'gcr.io/oss-vdb-test/staging-api-test']
waitFor: ['build-staging-api-test', 'cloud-build-queue']

# Build/push cron job images.
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/oss-vdb/cron:latest', '-t', 'gcr.io/oss-vdb/cron:$COMMIT_SHA', '.']
Expand Down Expand Up @@ -263,6 +273,7 @@ steps:
importer=gcr.io/oss-vdb/importer:$COMMIT_SHA,\
exporter=gcr.io/oss-vdb/exporter:$COMMIT_SHA,\
alias-computation=gcr.io/oss-vdb/alias-computation:$COMMIT_SHA,\
staging-api-test=gcr.io/oss-vdb-test/staging-api-test:$COMMIT_SHA,\
cron=gcr.io/oss-vdb/cron:$COMMIT_SHA,\
debian-convert=gcr.io/oss-vdb/debian-convert:$COMMIT_SHA,\
combine-to-osv=gcr.io/oss-vdb/combine-to-osv:$COMMIT_SHA,\
Expand Down Expand Up @@ -325,3 +336,4 @@ images:
- 'gcr.io/oss-vdb/cpe-repo-gen:$COMMIT_SHA'
- 'gcr.io/oss-vdb/nvd-cve-osv:$COMMIT_SHA'
- 'gcr.io/oss-vdb/nvd-mirror:$COMMIT_SHA'
- 'gcr.io/oss-vdb-test/staging-api-test:$COMMIT_SHA'
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
Expand Down
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
26 changes: 26 additions & 0 deletions docker/staging_api_test/Dockerfile
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"]
19 changes: 19 additions & 0 deletions docker/staging_api_test/build.sh
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
Loading
Loading