Skip to content

Commit 86395a4

Browse files
committed
chore: circleci config for OpenShift 4 integration tests
1 parent d9b0c98 commit 86395a4

File tree

11 files changed

+31
-109
lines changed

11 files changed

+31
-109
lines changed

.circleci/config.yml

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,11 @@ jobs:
4242
- checkout
4343
- setup_remote_docker
4444
- install_python_requests
45-
- run:
46-
command: pip install operator-courier==2.1.7
47-
name: Install operator-courier
4845
- run:
4946
command: |
50-
RELEASE_VERSION=v0.15.1
51-
DOWNLOAD_LOCATION=./operator-sdk
52-
CURL_FOLLOW_REDIRECTS="-L"
53-
curl ${CURL_FOLLOW_REDIRECTS} https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu -o ${DOWNLOAD_LOCATION}
54-
chmod +x ${DOWNLOAD_LOCATION}
55-
name: Download Operator SDK
47+
scripts/operator/download_operator_sdk.py
48+
scripts/operator/download_operator_package_manager.py
49+
name: Download Operator SDK and Operator Package Manager
5650
- run:
5751
command: |
5852
export IMAGE_TAG=$([[ "$CIRCLE_BRANCH" == "staging" ]] && echo "staging-candidate" || echo "discardable")
@@ -71,16 +65,10 @@ jobs:
7165
name: Package Operator Bundle
7266
- run:
7367
command: |
74-
if [ "$CIRCLE_BRANCH" != "staging" ]; then
75-
exit 0
76-
fi
77-
export QUAY_TOKEN=$(scripts/operator/get_quay_token.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}")
7868
export OPERATOR_DIR=$OPERATOR_PATH
79-
export QUAY_NAMESPACE=snyk-runtime
80-
export PACKAGE_NAME=snyk-operator
8169
export PACKAGE_VERSION="0.0.1-${CIRCLE_SHA1}"
82-
operator-courier push "${OPERATOR_DIR}" "${QUAY_NAMESPACE}" "${PACKAGE_NAME}" "${PACKAGE_VERSION}" "${QUAY_TOKEN}"
83-
name: Upload Operator to Quay
70+
scripts/operator/create_operator_bundle_and_index_and_push.py "${OPERATOR_DIR}" "${PACKAGE_VERSION}" "${DOCKERHUB_USER}" "${DOCKERHUB_PASSWORD}"
71+
name: Create Operator Bundle and Index and push to Docker Hub
8472
- run:
8573
command: |
8674
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
@@ -109,21 +97,6 @@ jobs:
10997
name: Notify Slack on failure
11098
when: on_fail
11199
working_directory: ~/kubernetes-monitor
112-
delete_operators_from_quay:
113-
docker:
114-
- auth:
115-
password: $DOCKERHUB_PASSWORD
116-
username: $DOCKERHUB_USER
117-
image: circleci/python:3.9
118-
steps:
119-
- checkout
120-
- install_python_requests
121-
- run:
122-
command: |
123-
python3 scripts/operator/delete_operators_from_quay.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}"
124-
name: Delete Operators from Quay
125-
when: always
126-
working_directory: ~/kubernetes-monitor
127100
deploy_dev:
128101
docker:
129102
- auth:
@@ -266,11 +239,6 @@ jobs:
266239
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
267240
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
268241
name: Operator integration tests on plain k8s
269-
- run:
270-
command: |
271-
scripts/operator/delete_operators_from_quay.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}"
272-
name: Delete Operators from Quay
273-
when: always
274242
- run:
275243
command: |
276244
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
@@ -342,10 +310,7 @@ jobs:
342310
name: create temp dir for logs
343311
- run:
344312
command: |
345-
echo "${OPENSHIFT4_ETC_HOSTS_ENTRY}" | sudo tee -a /etc/hosts
346-
name: Append an entry to the test environment to /etc/hosts
347-
- run:
348-
command: |
313+
export OPERATOR_VERSION="0.0.1-${CIRCLE_SHA1}"
349314
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
350315
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:openshift4:operator
351316
name: Integration tests OpenShift 4
@@ -957,14 +922,6 @@ workflows:
957922
requires:
958923
- build_image
959924
- build_and_upload_operator
960-
- delete_operators_from_quay:
961-
filters:
962-
branches:
963-
only:
964-
- staging
965-
requires:
966-
- integration_tests_operator_on_k8s
967-
- openshift4_integration_tests
968925
- tag_and_push:
969926
filters:
970927
branches:

.circleci/config/@config.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ workflows:
7979
- build_image
8080
- build_and_upload_operator
8181
<<: *staging_branch_only_filter
82-
- delete_operators_from_quay:
83-
requires:
84-
- integration_tests_operator_on_k8s
85-
- openshift4_integration_tests
86-
<<: *staging_branch_only_filter
8782
- tag_and_push:
8883
requires:
8984
- build_image

.circleci/config/jobs/@jobs.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,10 @@ build_and_upload_operator:
3333
- setup_remote_docker
3434
- install_python_requests
3535
- run:
36-
name: Install operator-courier
37-
command: pip install operator-courier==2.1.7
38-
- run:
39-
name: Download Operator SDK
36+
name: Download Operator SDK and Operator Package Manager
4037
command: |
41-
RELEASE_VERSION=v0.15.1
42-
DOWNLOAD_LOCATION=./operator-sdk
43-
CURL_FOLLOW_REDIRECTS="-L"
44-
curl ${CURL_FOLLOW_REDIRECTS} https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu -o ${DOWNLOAD_LOCATION}
45-
chmod +x ${DOWNLOAD_LOCATION}
38+
scripts/operator/download_operator_sdk.py
39+
scripts/operator/download_operator_package_manager.py
4640
- run:
4741
name: Create Operator and push Operator image to DockerHub
4842
command: |
@@ -60,17 +54,11 @@ build_and_upload_operator:
6054
OPERATOR_PATH=$(scripts/operator/package_operator_bundle.py "${SNYK_OPERATOR_VERSION}" "${SNYK_OPERATOR_IMAGE_TAG}" "${SNYK_MONITOR_IMAGE_TAG}")
6155
echo "export OPERATOR_PATH=$OPERATOR_PATH" >> $BASH_ENV
6256
- run:
63-
name: Upload Operator to Quay
57+
name: Create Operator Bundle and Index and push to Docker Hub
6458
command: |
65-
if [ "$CIRCLE_BRANCH" != "staging" ]; then
66-
exit 0
67-
fi
68-
export QUAY_TOKEN=$(scripts/operator/get_quay_token.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}")
6959
export OPERATOR_DIR=$OPERATOR_PATH
70-
export QUAY_NAMESPACE=snyk-runtime
71-
export PACKAGE_NAME=snyk-operator
7260
export PACKAGE_VERSION="0.0.1-${CIRCLE_SHA1}"
73-
operator-courier push "${OPERATOR_DIR}" "${QUAY_NAMESPACE}" "${PACKAGE_NAME}" "${PACKAGE_VERSION}" "${QUAY_TOKEN}"
61+
scripts/operator/create_operator_bundle_and_index_and_push.py "${OPERATOR_DIR}" "${PACKAGE_VERSION}" "${DOCKERHUB_USER}" "${DOCKERHUB_PASSWORD}"
7462
- run:
7563
name: Notify Slack on failure
7664
command: |
@@ -278,13 +266,10 @@ openshift4_integration_tests:
278266
- run:
279267
name: create temp dir for logs
280268
command: mkdir -p /tmp/logs/test/integration/openshift4
281-
- run:
282-
name: Append an entry to the test environment to /etc/hosts
283-
command: |
284-
echo "${OPENSHIFT4_ETC_HOSTS_ENTRY}" | sudo tee -a /etc/hosts
285269
- run:
286270
name: Integration tests OpenShift 4
287271
command: |
272+
export OPERATOR_VERSION="0.0.1-${CIRCLE_SHA1}"
288273
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
289274
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:openshift4:operator
290275
- run:
@@ -295,22 +280,6 @@ openshift4_integration_tests:
295280
- store_artifacts:
296281
path: /tmp/logs/test/integration/openshift4
297282

298-
delete_operators_from_quay:
299-
docker:
300-
- image: circleci/python:3.9
301-
auth:
302-
username: $DOCKERHUB_USER
303-
password: $DOCKERHUB_PASSWORD
304-
working_directory: ~/kubernetes-monitor
305-
steps:
306-
- checkout
307-
- install_python_requests
308-
- run:
309-
name: Delete Operators from Quay
310-
command: |
311-
python3 scripts/operator/delete_operators_from_quay.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}"
312-
when: always
313-
314283
######################## MERGE TO STAGING ########################
315284
tag_and_push:
316285
docker:

.circleci/config/jobs/integration_tests_operator_on_k8s.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ steps:
1414
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
1515
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:kindolm:operator
1616
name: Operator integration tests on plain k8s
17-
- run:
18-
name: Delete Operators from Quay
19-
command: |
20-
scripts/operator/delete_operators_from_quay.py "${QUAY_USERNAME}" "${QUAY_PASSWORD}"
21-
when: always
2217
- run:
2318
command: |
2419
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"

scripts/operator/create_operator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from tempfile import mkdtemp
2424
from subprocess import call
2525
from os import chdir
26-
from shutil import copy, copytree, rmtree
26+
from shutil import copy, copytree
2727

2828

2929
def createOperatorAndBuildOperatorImage(operator_name_and_tag: str, monitor_tag: str) -> None:
@@ -56,8 +56,6 @@ def createOperatorAndBuildOperatorImage(operator_name_and_tag: str, monitor_tag:
5656
call([operator_sdk_path, "build", operator_name_and_tag])
5757
chdir(return_path)
5858

59-
rmtree(new_operator_dir)
60-
6159

6260
if __name__ == '__main__':
6361
_, operator_name_and_tag, monitor_tag = argv

scripts/operator/create_operator_bundle_and_index_and_push.py

100644100755
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from os import chdir, environ, getcwd
44
from subprocess import call
55
from shutil import copy
6+
from sys import argv
67

78

89
def createOperatorBundleAndIndexAndPushToDockerHub(operator_path: str, new_operator_tag: str, dockerhub_user: str, dockerhub_password: str) -> None:
@@ -24,3 +25,9 @@ def createOperatorBundleAndIndexAndPushToDockerHub(operator_path: str, new_opera
2425
":" + new_operator_tag, "--tag", "snyk/kubernetes-operator-index" + ":" + new_operator_tag])
2526
call(["docker", "push", "snyk/kubernetes-operator-index" + ":" + new_operator_tag])
2627
chdir(return_dir)
28+
29+
30+
if __name__ == '__main__':
31+
_, operator_path, new_operator_tag, dockerhub_user, dockerhub_password = argv
32+
createOperatorBundleAndIndexAndPushToDockerHub(
33+
operator_path, new_operator_tag, dockerhub_user, dockerhub_password)

scripts/operator/download_operator_package_manager.py

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def downloadOperatorPackageManager() -> None:
1818
opm = get(
1919
"https://github.com/operator-framework/operator-registry/releases/download/v1.16.1/darwin-amd64-opm")
2020
else:
21-
raise RuntimeError("Unsupported system " + current_sys)
21+
opm = get(
22+
"https://github.com/operator-framework/operator-registry/releases/download/v1.16.1/linux-amd64-opm")
2223

2324
with open(operator_package_manager_path, "wb") as f:
2425
f.write(opm.content)

scripts/operator/download_operator_sdk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def downloadOperatorSdk() -> None:
2121
sdk = get(
2222
"https://github.com/operator-framework/operator-sdk/releases/download/v0.15.1/operator-sdk-v0.15.1-x86_64-apple-darwin")
2323
else:
24-
raise RuntimeError("Unsupported system " + current_sys)
24+
sdk = get(
25+
"https://github.com/operator-framework/operator-sdk/releases/download/v0.15.1/operator-sdk-v0.15.1-x86_64-linux-gnu")
2526

2627
with open(operator_sdk_path, "wb") as f:
2728
f.write(sdk.content)

scripts/operator/main.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
- DOCKERHUB_PASSWORD
1515
"""
1616

17-
from os import environ, remove
17+
from os import environ, remove, getcwd
1818
from hashlib import sha1
1919
from datetime import datetime
20-
from shutil import rmtree
2120
from subprocess import call
2221
from download_operator_package_manager import downloadOperatorPackageManager
2322
from create_operator_and_push import createOperatorAndPushToDockerHub
@@ -29,7 +28,7 @@
2928
random_digest = sha1(str(datetime.now()).encode("utf-8")).hexdigest()
3029
operator_version = "0.0.1-" + random_digest
3130

32-
with open(".operator_version", "w") as f:
31+
with open(getcwd() + "/" + ".operator_version", "w") as f:
3332
f.write(operator_version)
3433

3534
try:
@@ -46,7 +45,6 @@
4645
downloadOperatorSdk()
4746
print("Downloading Operator Package Manager")
4847
downloadOperatorPackageManager()
49-
call(["pip3", "install", "operator-courier==2.1.7"])
5048

5149
print("Creating Operator image and pushing to DockerHub")
5250
dockerhub_user = environ['DOCKERHUB_USER']
@@ -65,6 +63,5 @@
6563
print("Operator version " + operator_version +
6664
" has been pushed to Docker Hub")
6765

68-
# rmtree(operator_path)
69-
# remove("operator-sdk")
70-
# remove("opm")
66+
remove("operator-sdk")
67+
remove("opm")

scripts/operator/package_operator_bundle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def createOperatorFromTemplate(new_version: str, new_operator_tag: str, new_moni
4848

4949
copytree("snyk-operator/certified-operator",
5050
new_operator_dir + "/" + "certified-operator")
51+
mkdir(new_operator_dir + "/" + "certified-operator/bundle/manifests")
5152
copy(new_csv_path, new_operator_dir + "/" + "certified-operator/bundle/manifests" +
5253
"/" + "snyk-operator.v" + new_version + ".clusterserviceversion.yaml")
5354
copy(new_crd_path, new_operator_dir + "/" + "certified-operator/bundle/manifests" +

0 commit comments

Comments
 (0)