Skip to content

Commit 7357a9c

Browse files
author
Arthur Granado
committed
chore: test the snyk-operator on kubernetes cluster
1 parent 6900e46 commit 7357a9c

22 files changed

+298
-118
lines changed

.circleci/config.yml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,34 @@ jobs:
199199
- store_artifacts:
200200
path: /tmp/logs/test/integration/kind-helm
201201
working_directory: ~/kubernetes-monitor
202+
integration_tests_operator_on_k8s:
203+
machine:
204+
docker_layer_caching: true
205+
enabled: true
206+
steps:
207+
- checkout
208+
- setup_node12
209+
- install_python_requests
210+
- run:
211+
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
212+
name: Create temporary directory for logs
213+
- run:
214+
command: |
215+
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
216+
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
217+
name: Operator integration tests on plain k8s
218+
- run:
219+
command: |
220+
./scripts/operator/delete-operator-from-quay.sh
221+
name: Delete Operator from Quay
222+
- run:
223+
command: |
224+
./scripts/slack/notify_failure_on_branch.py "staging-integration-tests-operator-on-k8s-${CIRCLE_SHA1}"
225+
name: Notify Slack on failure
226+
when: on_fail
227+
- store_artifacts:
228+
path: /tmp/logs/test/integration/kind-olm-operator
229+
working_directory: ~/kubernetes-monitor
202230
integration_tests_proxy:
203231
machine:
204232
docker_layer_caching: true
@@ -214,7 +242,7 @@ jobs:
214242
command: |
215243
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
216244
npm run test:integration:kind:proxy
217-
name: Integration tests with Helm deployment
245+
name: Integration tests with proxy
218246
- run:
219247
command: |
220248
./scripts/slack/notify_failure_on_branch.py "staging-integration-proxy-tests-${CIRCLE_SHA1}"
@@ -601,7 +629,7 @@ jobs:
601629
command: |
602630
CURRENT_DIRECTORY=$(pwd)
603631
COMMUNITY_FOLDER_LOCATION="community-operators"
604-
./scripts/operator/push-operator.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
632+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
605633
name: Push new Operator to the fork of the community-operators repository
606634
- run:
607635
command: |
@@ -615,7 +643,7 @@ jobs:
615643
- run:
616644
command: |
617645
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
618-
./scripts/slack/notify_failure.py "push-new-operator on ${COMMUNITY_FOLDER_LOCATION}"
646+
./scripts/slack/notify_failure.py "push-new-operator on community-operators"
619647
fi
620648
name: Notify Slack on failure
621649
when: on_fail
@@ -663,7 +691,7 @@ jobs:
663691
command: |
664692
CURRENT_DIRECTORY=$(pwd)
665693
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
666-
./scripts/operator/push-operator.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
694+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
667695
name: Push new Operator to the fork of the upstream-community-operators repository
668696
- run:
669697
command: |
@@ -862,6 +890,15 @@ workflows:
862890
- staging
863891
requires:
864892
- build_image
893+
- integration_tests_operator_on_k8s:
894+
filters:
895+
branches:
896+
only:
897+
- staging
898+
requires:
899+
- build_image
900+
- build_operator
901+
- upload_operator
865902
- openshift4_integration_tests:
866903
filters:
867904
branches:
@@ -891,7 +928,7 @@ workflows:
891928
- staging
892929
requires:
893930
- tag_and_push
894-
NIGHTLY:
931+
MONTHLY:
895932
jobs:
896933
- operator_upgrade_tests
897934
- push_operator_to_community_operators:
@@ -900,6 +937,16 @@ workflows:
900937
- push_operator_to_upstream_community_operators:
901938
requires:
902939
- operator_upgrade_tests
940+
triggers:
941+
- schedule:
942+
cron: 0 1 1 * *
943+
filters:
944+
branches:
945+
only:
946+
- master
947+
NIGHTLY:
948+
jobs:
949+
- operator_upgrade_tests
903950
triggers:
904951
- schedule:
905952
cron: 0 1 * * *

.circleci/config/@config.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ workflows:
3838
requires:
3939
- build_image
4040
<<: *main_branches_filter
41-
- integration_tests_proxy:
42-
requires:
43-
- build_image
44-
<<: *main_branches_filter
45-
- integration_tests_proxy:
46-
requires:
47-
- build_image
48-
<<: *main_branches_filter
4941

5042
MERGE_TO_STAGING:
5143
jobs:
@@ -92,7 +84,6 @@ workflows:
9284
- build_image
9385
- build_operator
9486
- upload_operator
95-
- integration_tests_operator_on_k8s
9687
<<: *staging_branch_only_filter
9788
- tag_and_push:
9889
requires:
@@ -128,6 +119,17 @@ workflows:
128119
- master
129120
jobs:
130121
- operator_upgrade_tests
122+
123+
MONTHLY:
124+
triggers:
125+
- schedule:
126+
cron: "0 1 1 * *"
127+
filters:
128+
branches:
129+
only:
130+
- master
131+
jobs:
132+
- operator_upgrade_tests
131133
- push_operator_to_community_operators:
132134
requires:
133135
- operator_upgrade_tests

.circleci/config/jobs/@jobs.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -174,36 +174,6 @@ integration_tests_helm:
174174
- store_artifacts:
175175
path: /tmp/logs/test/integration/kind-helm
176176

177-
integration_tests_operator_on_k8s:
178-
machine:
179-
docker_layer_caching: true
180-
enabled: true
181-
steps:
182-
- checkout
183-
- setup_node12
184-
- install_python_requests
185-
- run:
186-
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
187-
name: Create temporary directory for logs
188-
- run:
189-
command: |
190-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
191-
npm run test:integration:kindolm:operator
192-
name: Operator integration tests on plain k8s
193-
- run:
194-
name: Delete Operator from Quay
195-
command: |
196-
./scripts/operator/delete-operator-from-quay.sh
197-
when: on_fail # it will be deleted on success in the openshift4 tests
198-
- run:
199-
command: |
200-
./scripts/slack/notify_failure_on_branch.py "staging-integration-operator-k8s-tests-${CIRCLE_SHA1}"
201-
name: Notify Slack on failure
202-
when: on_fail
203-
- store_artifacts:
204-
path: /tmp/logs/test/integration/kind-olm-operator
205-
working_directory: ~/kubernetes-monitor
206-
207177
integration_tests_proxy:
208178
machine:
209179
enabled: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
machine:
2+
docker_layer_caching: true
3+
enabled: true
4+
steps:
5+
- checkout
6+
- setup_node12
7+
- install_python_requests
8+
- run:
9+
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
10+
name: Create temporary directory for logs
11+
- run:
12+
command: |
13+
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
14+
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
15+
name: Operator integration tests on plain k8s
16+
- run:
17+
name: Delete Operator from Quay
18+
command: |
19+
./scripts/operator/delete-operator-from-quay.sh
20+
- run:
21+
command: |
22+
./scripts/slack/notify_failure_on_branch.py "staging-integration-tests-operator-on-k8s-${CIRCLE_SHA1}"
23+
name: Notify Slack on failure
24+
when: on_fail
25+
- store_artifacts:
26+
path: /tmp/logs/test/integration/kind-olm-operator
27+
working_directory: ~/kubernetes-monitor

.circleci/config/jobs/push_operator_to_community_operators.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,22 @@ steps:
5353
command: |
5454
CURRENT_DIRECTORY=$(pwd)
5555
COMMUNITY_FOLDER_LOCATION="community-operators"
56-
./scripts/operator/push-operator.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
56+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
5757
- run:
5858
name: Open a Pull Request to the operator-framework/community-operators repository for community-operators
5959
command: |
6060
COMMUNITY_FOLDER_LOCATION="community-operators"
61-
python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}"
61+
PR_URL=$(python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
62+
export SLACK_PR_URL=${PR_URL}
6263
- run:
6364
name: Notify Slack on new branch in snyk/community-operators
6465
command: |
65-
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}"
66+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
6667
6768
- run:
6869
name: Notify Slack on failure
6970
command: |
7071
if [[ "${NOTHING_TO_TEST}" != "true" ]]; then
71-
./scripts/slack/notify_failure.py "push-new-operator on ${COMMUNITY_FOLDER_LOCATION}"
72+
./scripts/slack/notify_failure.py "push-new-operator on community-operators"
7273
fi
7374
when: on_fail

.circleci/config/jobs/push_operator_to_upstream_community_operators.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,17 @@ steps:
5353
command: |
5454
CURRENT_DIRECTORY=$(pwd)
5555
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
56-
./scripts/operator/push-operator.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
56+
./scripts/operator/push-operator-to-snyk-upstream.sh "${CURRENT_DIRECTORY}" "${COMMUNITY_FOLDER_LOCATION}"
5757
- run:
5858
name: Open a Pull Request to the operator-framework/community-operators repository for upstream-community-operators
5959
command: |
6060
COMMUNITY_FOLDER_LOCATION="upstream-community-operators"
61-
python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}"
61+
PR_URL=$(python ./scripts/operator/raise_pr_to_community_operators_from_our_fork.py "${COMMUNITY_FOLDER_LOCATION}" "${NEW_OPERATOR_VERSION}")
62+
export SLACK_PR_URL=${PR_URL}
6263
- run:
6364
name: Notify Slack on new branch in snyk/upstream-community-operators
6465
command: |
65-
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}"
66+
./scripts/slack/notify_success_operator_push.py "${NEW_OPERATOR_VERSION}" "${COMMUNITY_FOLDER_LOCATION}" "${SLACK_PR_URL}"
6667
6768
- run:
6869
name: Notify Slack on failure

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"test:integration:kind:yaml": "DEPLOYMENT_TYPE=YAML TEST_PLATFORM=kind CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
1111
"test:integration:kind:helm": "DEPLOYMENT_TYPE=Helm TEST_PLATFORM=kind CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
1212
"test:integration:kind:proxy": "DEPLOYMENT_TYPE=Proxy TEST_PLATFORM=kind CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
13-
"test:integration:kindolm:operator": "DEPLOYMENT_TYPE=Operator TEST_PLATFORM=kindolm CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
13+
"test:integration:kindolm:operator": "DEPLOYMENT_TYPE=OperatorOLM TEST_PLATFORM=kindolm CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
1414
"test:integration:eks:yaml": "DEPLOYMENT_TYPE=YAML TEST_PLATFORM=eks CREATE_CLUSTER=false tap test/integration/kubernetes.test.ts --timeout=900",
1515
"test:integration:openshift3:yaml": "DEPLOYMENT_TYPE=YAML TEST_PLATFORM=openshift3 CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts --timeout=900",
16-
"test:integration:openshift4:operator": "DEPLOYMENT_TYPE=Operator TEST_PLATFORM=openshift4 CREATE_CLUSTER=false tap test/integration/kubernetes.test.ts --timeout=900",
16+
"test:integration:openshift4:operator": "DEPLOYMENT_TYPE=OperatorOS TEST_PLATFORM=openshift4 CREATE_CLUSTER=false tap test/integration/kubernetes.test.ts --timeout=900",
1717
"test:coverage": "npm run test:unit -- --coverage",
1818
"test:watch": "tsc-watch --onSuccess 'npm run test:unit'",
1919
"start": "bin/start",

scripts/operator/delete-operator-from-quay.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ OPERATOR_VERSION="0.0.1-${CIRCLE_SHA1}"
77

88
STATUSCODE=$( curl --silent --output /dev/stderr --write-out "%{http_code}" -XDELETE -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: $QUAY_TOKEN" "https://quay.io/cnr/api/v1/packages/snyk-runtime/snyk-operator/${OPERATOR_VERSION}/helm" )
99

10-
if test $STATUSCODE -ge 300; then
10+
if test $STATUSCODE -ge 300 && test $STATUSCODE != 404; then
1111
echo "Unexpected status code $STATUSCODE"
1212
exit 1
1313
fi

scripts/operator/push-operator.sh renamed to scripts/operator/push-operator-to-snyk-upstream.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Outputs:
88
# - Push a new branch to snyk/community-operators
99
#
10+
# Sync snyk/community-operators repo from framework-operator/community-operators repo.
1011
# Push a new version of the Operator to the Snyk community-operators fork to publish it later.
1112
# This branch will be ready to open a pull request to operator-framework community-operators repo.
1213
#
@@ -29,6 +30,14 @@ git config --global user.name "${OPENSHIFT_OPERATOR_GITHUB_NAME}"
2930
# Clone Community Operators repo from Snyk
3031
git clone https://github.com/snyk/community-operators.git $COMMUNITY_OPERATORS_UPSTREAM_LOCATION
3132
cd "${COMMUNITY_OPERATORS_UPSTREAM_LOCATION}"
33+
34+
# Sync snyk/community-operators repo from operator-framework/community-operators repo
35+
git remote add upstream https://github.com/operator-framework/community-operators.git
36+
git fetch upstream
37+
git merge upstream/master
38+
git push origin master
39+
40+
# Checkout branch for new snyk-operator version on community folder
3241
git checkout -b snyk/${COMMUNITY_FOLDER_LOCATION}/snyk-operator-v${NEW_OPERATOR_VERSION}
3342

3443
# Create location if it doesn't exist

scripts/operator/raise_pr_to_community_operators_from_our_fork.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def create_pull_request(new_operator_version, new_release_branch_name):
2727
print('Raised a PR for operator version ' +
2828
new_operator_version + ': ' + pr.url)
2929

30+
return pr.url
31+
3032

3133
if __name__ == '__main__':
3234
operator_upstream_folder = sys.argv[1]
@@ -41,4 +43,5 @@ def create_pull_request(new_operator_version, new_release_branch_name):
4143
os.exit(1)
4244
else:
4345
new_operator_release_branch = get_new_operator_release_branch(new_operator_version, operator_upstream_folder)
44-
create_pull_request(new_operator_version, new_operator_release_branch)
46+
pr_url = create_pull_request(new_operator_version, new_operator_release_branch)
47+
print(pr_url)

0 commit comments

Comments
 (0)