Skip to content

Commit 62310ad

Browse files
committed
feat: add support to testing operator on disconnected env
Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
1 parent 6e579e8 commit 62310ad

File tree

6 files changed

+321
-0
lines changed

6 files changed

+321
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
base_images:
2+
cli:
3+
name: "4.17"
4+
namespace: ocp
5+
tag: cli
6+
tools:
7+
name: "4.17"
8+
namespace: ocp
9+
tag: tools
10+
upi-installer:
11+
name: "4.17"
12+
namespace: ocp
13+
tag: upi-installer
14+
build_root:
15+
image_stream_tag:
16+
name: release
17+
namespace: openshift
18+
tag: rhel-8-release-golang-1.21-openshift-4.16
19+
images:
20+
- context_dir: .
21+
dockerfile_path: tests/Dockerfile
22+
to: power-monitoring-operator-tests-runner
23+
releases:
24+
latest:
25+
candidate:
26+
product: ocp
27+
stream: nightly
28+
version: "4.17"
29+
resources:
30+
'*':
31+
requests:
32+
cpu: 100m
33+
memory: 200Mi
34+
tests:
35+
- always_run: false
36+
as: powermonitoring-tests-disconnected
37+
steps:
38+
cluster_profile: gcp-qe
39+
test:
40+
- ref: openshift-power-monitoring-install-disconnected
41+
workflow: cucushift-installer-rehearse-gcp-ipi-disconnected
42+
zz_generated_metadata:
43+
branch: v1alpha1
44+
org: openshift-power-monitoring
45+
repo: power-monitoring-operator
46+
variant: ocp-4.17-disconnected

ci-operator/jobs/openshift-power-monitoring/power-monitoring-operator/openshift-power-monitoring-power-monitoring-operator-v1alpha1-presubmits.yaml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,141 @@ presubmits:
112112
secret:
113113
secretName: result-aggregator
114114
trigger: (?m)^/test( | .* )images,?($|\s.*)
115+
- agent: kubernetes
116+
always_run: true
117+
branches:
118+
- ^v1alpha1$
119+
- ^v1alpha1-
120+
cluster: build10
121+
context: ci/prow/ocp-4.17-disconnected-images
122+
decorate: true
123+
decoration_config:
124+
skip_cloning: true
125+
labels:
126+
ci-operator.openshift.io/variant: ocp-4.17-disconnected
127+
ci.openshift.io/generator: prowgen
128+
job-release: "4.17"
129+
pj-rehearse.openshift.io/can-be-rehearsed: "true"
130+
name: pull-ci-openshift-power-monitoring-power-monitoring-operator-v1alpha1-ocp-4.17-disconnected-images
131+
rerun_command: /test ocp-4.17-disconnected-images
132+
spec:
133+
containers:
134+
- args:
135+
- --gcs-upload-secret=/secrets/gcs/service-account.json
136+
- --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson
137+
- --report-credentials-file=/etc/report/credentials
138+
- --target=[images]
139+
- --variant=ocp-4.17-disconnected
140+
command:
141+
- ci-operator
142+
image: ci-operator:latest
143+
imagePullPolicy: Always
144+
name: ""
145+
resources:
146+
requests:
147+
cpu: 10m
148+
volumeMounts:
149+
- mountPath: /secrets/gcs
150+
name: gcs-credentials
151+
readOnly: true
152+
- mountPath: /secrets/manifest-tool
153+
name: manifest-tool-local-pusher
154+
readOnly: true
155+
- mountPath: /etc/pull-secret
156+
name: pull-secret
157+
readOnly: true
158+
- mountPath: /etc/report
159+
name: result-aggregator
160+
readOnly: true
161+
serviceAccountName: ci-operator
162+
volumes:
163+
- name: manifest-tool-local-pusher
164+
secret:
165+
secretName: manifest-tool-local-pusher
166+
- name: pull-secret
167+
secret:
168+
secretName: registry-pull-credentials
169+
- name: result-aggregator
170+
secret:
171+
secretName: result-aggregator
172+
trigger: (?m)^/test( | .* )ocp-4.17-disconnected-images,?($|\s.*)
173+
- agent: kubernetes
174+
always_run: false
175+
branches:
176+
- ^v1alpha1$
177+
- ^v1alpha1-
178+
cluster: build02
179+
context: ci/prow/ocp-4.17-disconnected-powermonitoring-tests-disconnected
180+
decorate: true
181+
decoration_config:
182+
skip_cloning: true
183+
labels:
184+
ci-operator.openshift.io/cloud: gcp
185+
ci-operator.openshift.io/cloud-cluster-profile: gcp-qe
186+
ci-operator.openshift.io/variant: ocp-4.17-disconnected
187+
ci.openshift.io/generator: prowgen
188+
job-release: "4.17"
189+
pj-rehearse.openshift.io/can-be-rehearsed: "true"
190+
name: pull-ci-openshift-power-monitoring-power-monitoring-operator-v1alpha1-ocp-4.17-disconnected-powermonitoring-tests-disconnected
191+
rerun_command: /test ocp-4.17-disconnected-powermonitoring-tests-disconnected
192+
spec:
193+
containers:
194+
- args:
195+
- --gcs-upload-secret=/secrets/gcs/service-account.json
196+
- --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson
197+
- --lease-server-credentials-file=/etc/boskos/credentials
198+
- --report-credentials-file=/etc/report/credentials
199+
- --secret-dir=/secrets/ci-pull-credentials
200+
- --target=powermonitoring-tests-disconnected
201+
- --variant=ocp-4.17-disconnected
202+
command:
203+
- ci-operator
204+
image: ci-operator:latest
205+
imagePullPolicy: Always
206+
name: ""
207+
resources:
208+
requests:
209+
cpu: 10m
210+
volumeMounts:
211+
- mountPath: /etc/boskos
212+
name: boskos
213+
readOnly: true
214+
- mountPath: /secrets/ci-pull-credentials
215+
name: ci-pull-credentials
216+
readOnly: true
217+
- mountPath: /secrets/gcs
218+
name: gcs-credentials
219+
readOnly: true
220+
- mountPath: /secrets/manifest-tool
221+
name: manifest-tool-local-pusher
222+
readOnly: true
223+
- mountPath: /etc/pull-secret
224+
name: pull-secret
225+
readOnly: true
226+
- mountPath: /etc/report
227+
name: result-aggregator
228+
readOnly: true
229+
serviceAccountName: ci-operator
230+
volumes:
231+
- name: boskos
232+
secret:
233+
items:
234+
- key: credentials
235+
path: credentials
236+
secretName: boskos-credentials
237+
- name: ci-pull-credentials
238+
secret:
239+
secretName: ci-pull-credentials
240+
- name: manifest-tool-local-pusher
241+
secret:
242+
secretName: manifest-tool-local-pusher
243+
- name: pull-secret
244+
secret:
245+
secretName: registry-pull-credentials
246+
- name: result-aggregator
247+
secret:
248+
secretName: result-aggregator
249+
trigger: (?m)^/test( | .* )(ocp-4.17-disconnected-powermonitoring-tests-disconnected|remaining-required),?($|\s.*)
115250
- agent: kubernetes
116251
always_run: false
117252
branches:

ci-operator/step-registry/openshift-power-monitoring/install/disconnected/OWNERS

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
# Set XDG_RUNTIME_DIR/containers to be used by oc mirror
8+
export HOME=/tmp/home
9+
export XDG_RUNTIME_DIR="${HOME}/run"
10+
export REGISTRY_AUTH_PREFERENCE=podman
11+
mkdir -p "${XDG_RUNTIME_DIR}/containers"
12+
cd "$HOME" || exit 1
13+
14+
function run_command() {
15+
local CMD="$1"
16+
echo "Running Command: ${CMD}"
17+
eval "${CMD}"
18+
}
19+
20+
# Mirror operator and test images to the Mirror registry. Create Catalog sources and Image Content Source Policy.
21+
function mirror_catalog_icsp() {
22+
registry_cred=$(head -n 1 "/var/run/vault/mirror-registry/registry_creds" | base64 -w 0)
23+
24+
optional_auth_user=$(cat "/var/run/vault/mirror-registry/registry_quay.json" | jq -r '.user')
25+
optional_auth_password=$(cat "/var/run/vault/mirror-registry/registry_quay.json" | jq -r '.password')
26+
qe_registry_auth=$(echo -n "${optional_auth_user}:${optional_auth_password}" | base64 -w 0)
27+
28+
openshifttest_auth_user=$(cat "/var/run/vault/mirror-registry/registry_quay_openshifttest.json" | jq -r '.user')
29+
openshifttest_auth_password=$(cat "/var/run/vault/mirror-registry/registry_quay_openshifttest.json" | jq -r '.password')
30+
openshifttest_registry_auth=$(echo -n "${openshifttest_auth_user}:${openshifttest_auth_password}" | base64 -w 0)
31+
32+
brew_auth_user=$(cat "/var/run/vault/mirror-registry/registry_brew.json" | jq -r '.user')
33+
brew_auth_password=$(cat "/var/run/vault/mirror-registry/registry_brew.json" | jq -r '.password')
34+
brew_registry_auth=$(echo -n "${brew_auth_user}:${brew_auth_password}" | base64 -w 0)
35+
36+
stage_auth_user=$(cat "/var/run/vault/mirror-registry/registry_stage.json" | jq -r '.user')
37+
stage_auth_password=$(cat "/var/run/vault/mirror-registry/registry_stage.json" | jq -r '.password')
38+
stage_registry_auth=$(echo -n "${stage_auth_user}:${stage_auth_password}" | base64 -w 0)
39+
40+
redhat_auth_user=$(cat "/var/run/vault/mirror-registry/registry_redhat.json" | jq -r '.user')
41+
redhat_auth_password=$(cat "/var/run/vault/mirror-registry/registry_redhat.json" | jq -r '.password')
42+
redhat_registry_auth=$(echo -n "${redhat_auth_user}:${redhat_auth_password}" | base64 -w 0)
43+
44+
# run_command "cat ${CLUSTER_PROFILE_DIR}/pull-secret"
45+
# Running Command: cat /tmp/.dockerconfigjson
46+
# {"auths":{"ec2-3-92-162-185.compute-1.amazonaws.com:5000":{"auth":"XXXXXXXXXXXXXXXX"}}}
47+
run_command "oc extract secret/pull-secret -n openshift-config --confirm --to /tmp"
48+
ret=$?
49+
MIRROR_REGISTRY_HOST=$(head -n 1 "${SHARED_DIR}/mirror_registry_url")
50+
echo $MIRROR_REGISTRY_HOST
51+
if [[ $ret -eq 0 ]]; then
52+
jq --argjson a "{\"registry.stage.redhat.io\": {\"auth\": \"$stage_registry_auth\"}, \"brew.registry.redhat.io\": {\"auth\": \"$brew_registry_auth\"}, \"registry.redhat.io\": {\"auth\": \"$redhat_registry_auth\"}, \"${MIRROR_REGISTRY_HOST}\": {\"auth\": \"$registry_cred\"}, \"quay.io/openshift-qe-optional-operators\": {\"auth\": \"${qe_registry_auth}\", \"email\":\"jiazha@redhat.com\"},\"quay.io/openshifttest\": {\"auth\": \"${openshifttest_registry_auth}\"}}" '.auths |= . + $a' "/tmp/.dockerconfigjson" >${XDG_RUNTIME_DIR}/containers/auth.json
53+
export REG_CREDS=${XDG_RUNTIME_DIR}/containers/auth.json
54+
else
55+
echo "!!! fail to extract the auth of the cluster"
56+
return 1
57+
fi
58+
59+
# prepare ImageSetConfiguration
60+
run_command "mkdir /tmp/images"
61+
cat <<EOF >/tmp/image-set.yaml
62+
63+
kind: ImageSetConfiguration
64+
apiVersion: mirror.openshift.io/v1alpha2
65+
archiveSize: 30
66+
storageConfig:
67+
local:
68+
path: /tmp/images
69+
mirror:
70+
additionalImages:
71+
# Used for running disconnected tests
72+
- name: quay.io/redhat-user-workloads/rhpm-tenant/power-monitoring-operator-bundle:v0.4.0
73+
- name: quay.io/redhat-user-workloads/rhpm-tenant/power-monitoring-operator:v0.15.0
74+
- name: quay.io/redhat-user-workloads/rhpm-tenant/kepler:v0.7.12
75+
EOF
76+
77+
run_command "cd /tmp"
78+
run_command "curl -L -o oc-mirror.tar.gz https://mirror.openshift.com/pub/openshift-v4/amd64/clients/ocp/latest/oc-mirror.tar.gz && tar -xvzf oc-mirror.tar.gz && chmod +x oc-mirror"
79+
run_command "./oc-mirror --config=/tmp/image-set.yaml docker://${MIRROR_REGISTRY_HOST} --continue-on-error --ignore-history --source-skip-tls --dest-skip-tls || true"
80+
run_command "cp oc-mirror-workspace/results-*/mapping.txt ."
81+
# run_command "sed -e 's|registry.redhat.io|registry.stage.redhat.io|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/tempo|brew.registry.redhat.io/rh-osbs/iib|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/otel|brew.registry.redhat.io/rh-osbs/iib|g' -e 's|brew.registry.stage.redhat.io/rh-osbs/jaeger|brew.registry.redhat.io/rh-osbs/iib|g' mapping.txt > mapping-stage.txt"
82+
run_command "oc image mirror -a ${REG_CREDS} -f mapping.txt --insecure --filter-by-os='.*'"
83+
84+
echo "Creating Image Content Source Policy"
85+
oc apply -f - <<EOF
86+
apiVersion: operator.openshift.io/v1alpha1
87+
kind: ImageContentSourcePolicy
88+
metadata:
89+
name: test-registry
90+
spec:
91+
repositoryDigestMirrors:
92+
- mirrors:
93+
- $MIRROR_REGISTRY_HOST
94+
source: quay.io
95+
EOF
96+
echo "Install operator-sdk and dependencies"
97+
export OPERATOR_SDK_VERSION=1.36.1
98+
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
99+
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATOR_SDK_VERSION}
100+
curl -Lo operator-sdk ${OPERATOR_SDK_DL_URL}/operator-sdk_linux_${ARCH}
101+
chmod +x operator-sdk
102+
./operator-sdk version
103+
104+
./operator-sdk run bundle --timeout=5m --namespace "openshift-operators" "quay.io/redhat-user-workloads/rhpm-tenant/power-monitoring-operator-bundle:v0.4.0" --verbose
105+
106+
oc logs -n openshift-operators -f deployment/kepler-operator-controller
107+
108+
}
109+
110+
run_command "oc whoami"
111+
run_command "oc version -o yaml"
112+
113+
mirror_catalog_icsp
114+
115+
while [[ -f /tmp/unsleep ]]; do
116+
echo "sleeping for 10 seconds"
117+
sleep 10
118+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"path": "openshift-power-monitoring/install/disconnected/openshift-power-monitoring-install-disconnected-ref.yaml",
3+
"owners": {}
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ref:
2+
as: openshift-power-monitoring-install-disconnected
3+
from: upi-installer
4+
timeout: 3h0m0s
5+
cli: latest
6+
grace_period: 10m
7+
commands: openshift-power-monitoring-install-disconnected-commands.sh
8+
resources:
9+
requests:
10+
cpu: 100m
11+
memory: 100Mi
12+
credentials:
13+
- namespace: test-credentials
14+
name: openshift-custom-mirror-registry
15+
mount_path: /var/run/vault/mirror-registry
16+
documentation: |-
17+
Install Power Monitoring Operator catalog source for running operators in disconnected env.
18+

0 commit comments

Comments
 (0)