-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RHINENG-9589 add autopromotion pipeline tests
- Loading branch information
1 parent
2fd63b2
commit 462f22c
Showing
13 changed files
with
257 additions
and
11 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
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
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
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
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,32 @@ | ||
#!/bin/ruby | ||
|
||
require 'yaml' | ||
|
||
objects = YAML.load_stream(STDIN) | ||
|
||
# Replacing namespace 'default' with 'floorist-operator-system' due to the difference in namespaces | ||
# between the local (minikube) and staging environments | ||
stage_namespace = 'floorist-operator-system' | ||
|
||
objects.each do |object| | ||
# Replacing 'name' key with 'generateName' key ensuring Job name uniqueness in the staging environment | ||
if object['kind'] == 'Job' | ||
object['metadata']['name'] += '-' | ||
object['metadata']['generateName'] = object['metadata'].delete('name') | ||
end | ||
|
||
object['subjects'][0]['namespace'] = stage_namespace if object['kind'] == 'RoleBinding' | ||
|
||
object['metadata']['namespace'] = stage_namespace | ||
end | ||
|
||
template = { | ||
'apiVersion' => 'v1', | ||
'kind' => 'Template', | ||
'metadata' => { | ||
'name' => 'floorist-operator-stage-test' | ||
}, | ||
'objects' => objects | ||
} | ||
|
||
YAML.dump(template, STDOUT) |
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,22 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
# Adds namespace to all resources. | ||
namespace: default | ||
|
||
# Value of this field is prepended to the | ||
# names of all resources, e.g. a deployment named | ||
# "wordpress" becomes "alices-wordpress". | ||
# Note that it should also match with the prefix (text before '-') of the namespace | ||
# field above. | ||
namePrefix: floorist-operator- | ||
|
||
# Labels to add to all resources and selectors. | ||
#commonLabels: | ||
# someName: someValue | ||
|
||
resources: | ||
- stage_test_service_account.yaml | ||
- stage_test_role.yaml | ||
- stage_test_role_binding.yaml | ||
- stage_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,23 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: stage-test | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
serviceAccountName: stage-test-service-account | ||
containers: | ||
- image: quay.io/cloudservices/floorist-operator:latest | ||
name: floorist-operator-stage-test | ||
imagePullPolicy: Always | ||
command: | ||
- sh | ||
args: | ||
- stage_test.sh | ||
resources: | ||
requests: | ||
memory: 256Mi | ||
cpu: 300m | ||
limits: | ||
memory: 512Mi |
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,14 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: stage-test-role | ||
rules: | ||
- apiGroups: | ||
- batch | ||
resources: | ||
- cronjobs | ||
- jobs | ||
verbs: | ||
- get | ||
- list | ||
- watch |
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,11 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: stage-test-rolebinding | ||
roleRef: | ||
kind: Role | ||
name: stage-test-role | ||
apiGroup: rbac.authorization.k8s.io | ||
subjects: | ||
- kind: ServiceAccount | ||
name: stage-test-service-account |
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,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: stage-test-service-account |
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
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,24 @@ | ||
#!/bin/bash | ||
|
||
# Get names of all cronjobs, if not found any ignore the error message | ||
# to not let k8s raise an error with an exit code indicating success | ||
CRONJOBS=$(oc get cronjobs 2>/dev/null | awk 'NR>1 {print $1}') | ||
|
||
if [ -z "$CRONJOBS" ]; then | ||
echo "ERROR: no cronjobs found" | ||
exit 1 | ||
fi | ||
|
||
for CRONJOB in $CRONJOBS; do | ||
SUCCESS=$(oc get job -l "pod=${CRONJOB}" -o jsonpath='{.items[].status.succeeded}{"\n"}') | ||
|
||
if [ -z "$SUCCESS" ]; then | ||
echo "ERROR: cronjob $CRONJOB has not created any jobs" | ||
exit 1 | ||
fi | ||
|
||
if [ "$SUCCESS" != "1" ]; then | ||
echo "ERROR: cronjob $CRONJOB has not created successful jobs" | ||
exit 1 | ||
fi | ||
done |
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,63 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Template | ||
metadata: | ||
name: floorist-operator-stage-test | ||
objects: | ||
- apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: floorist-operator-stage-test-service-account | ||
namespace: floorist-operator-system | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: floorist-operator-stage-test-role | ||
namespace: floorist-operator-system | ||
rules: | ||
- apiGroups: | ||
- batch | ||
resources: | ||
- cronjobs | ||
- jobs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: floorist-operator-stage-test-rolebinding | ||
namespace: floorist-operator-system | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: floorist-operator-stage-test-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: floorist-operator-stage-test-service-account | ||
namespace: floorist-operator-system | ||
- apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
namespace: floorist-operator-system | ||
generateName: floorist-operator-stage-test- | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- args: | ||
- stage_test.sh | ||
command: | ||
- sh | ||
image: quay.io/cloudservices/floorist-operator:latest | ||
imagePullPolicy: Always | ||
name: floorist-operator-stage-test | ||
resources: | ||
limits: | ||
memory: 512Mi | ||
requests: | ||
cpu: 300m | ||
memory: 256Mi | ||
restartPolicy: Never | ||
serviceAccountName: floorist-operator-stage-test-service-account |