-
Notifications
You must be signed in to change notification settings - Fork 43
161 lines (147 loc) · 8.5 KB
/
Copy pathnightly-upgrade-test.yaml
File metadata and controls
161 lines (147 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Nightly checks (Upgrade)
on:
# workflow_dispatch so that it can be triggered manually if needed
workflow_dispatch:
schedule:
- cron: "55 23 * * *"
jobs:
e2e-upgrade-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
from_branch:
- release-1.5
- release-1.6
- release-1.7
to_branch:
- main
- release-1.7
- release-1.6
- release-1.5
name: 'E2E Upgrade: ${{ matrix.from_branch }} => ${{ matrix.to_branch }}'
concurrency:
group: '${{ github.workflow }}-${{ matrix.from_branch }}-${{ matrix.to_branch }}'
cancel-in-progress: true
env:
CONTAINER_ENGINE: podman
steps:
- name: Determine if upgrade path should be skipped
id: upgrade-path-checker
run: |
SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="false"
from_branch=${{ matrix.from_branch }}
to_branch=${{ matrix.to_branch }}
if [[ "${from_branch}" == "main" ]]; then
# This is considered a downgrade or a test using the same from/to branches
SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="true"
else
from_version="${from_branch#release-}"
from_minor=$(echo $from_version | cut -d. -f2)
if [[ "${to_branch}" != "main" ]]; then
to_version="${to_branch#release-}"
to_minor=$(echo $to_version | cut -d. -f2)
if [[ $from_minor -ge $to_minor ]]; then
SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE="true"
fi
fi
fi
echo "SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE=${SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE}" >> $GITHUB_OUTPUT
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 # default branch will be checked out by default on scheduled workflows
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }}
with:
fetch-depth: 0
- name: Setup Go
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }}
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: 'go.mod'
- name: Set env vars
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }}
run: |
distLocation="dist/rhdh/install.yaml"
from_branch=${{ matrix.from_branch }}
FROM_OPERATOR_MANIFEST="${{ github.workspace }}/${distLocation}"
proto="file://"
if [[ "${from_branch}" != "main" ]]; then
version="${from_branch#release-}"
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
FROM_OPERATOR_MANIFEST="${{ github.workspace }}/tests/e2e/testdata/rhdh-operator-${version}.yaml"
# TODO(rm3l): remove this once 1.6 is the minimal supported version
if [[ $major -ge 1 && $minor -ge 6 ]]; then
FROM_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${from_branch}/${distLocation}"
proto=""
fi
fi
echo "FROM_OPERATOR_MANIFEST=${FROM_OPERATOR_MANIFEST}" >> $GITHUB_ENV
FROM_OPERATOR_IMAGE=$(curl -s "${proto}${FROM_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image')
echo "FROM_OPERATOR_IMAGE=${FROM_OPERATOR_IMAGE}" >> $GITHUB_ENV
to_branch=${{ matrix.to_branch }}
TO_OPERATOR_MANIFEST="${{ github.workspace }}/${distLocation}"
proto="file://"
if [[ "${to_branch}" != "main" ]]; then
version="${to_branch#release-}"
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
TO_OPERATOR_MANIFEST="${{ github.workspace }}/tests/e2e/testdata/rhdh-operator-${version}.yaml"
# TODO(rm3l): remove this once 1.6 is the minimal supported version
if [[ $major -ge 1 && $minor -ge 6 ]]; then
TO_OPERATOR_MANIFEST="https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/${to_branch}/${distLocation}"
proto=""
fi
fi
echo "TO_OPERATOR_MANIFEST=${TO_OPERATOR_MANIFEST}" >> $GITHUB_ENV
TO_OPERATOR_IMAGE=$(curl -s "${proto}${TO_OPERATOR_MANIFEST}" | yq 'select(.kind == "Deployment" and .metadata.labels.app == "rhdh-operator") | .spec.template.spec.containers[0].image')
echo "TO_OPERATOR_IMAGE=${TO_OPERATOR_IMAGE}" >> $GITHUB_ENV
- name: Check if operator images exist in remote registry
id: operator-image-existence-checker
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' }}
run: |
echo "FROM_OPERATOR_IMAGE_EXISTS=$(skopeo inspect "docker://${{ env.FROM_OPERATOR_IMAGE }}" > /dev/null && echo "true" || echo "false")" >> $GITHUB_OUTPUT
echo "TO_OPERATOR_IMAGE_EXISTS=$(skopeo inspect "docker://${{ env.TO_OPERATOR_IMAGE }}" > /dev/null && echo "true" || echo "false")" >> $GITHUB_OUTPUT
- name: Display warning if any of the operator images were not found
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && (steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'false' || steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'false') }}
run: |
echo "::warning ::One of the operator images (${{ env.FROM_OPERATOR_IMAGE }} or ${{ env.TO_OPERATOR_IMAGE }}) could not be found for testing the ${{ matrix.from_branch }} => ${{ matrix.to_branch }} upgrade path. They might have expired. Skipping."
- name: Generate Kind Config
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }}
run: |
cat <<EOF > /tmp/kind-config.yaml
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
EOF
- name: Create Kind cluster
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }}
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
with:
cluster_name: test-cluster
config: /tmp/kind-config.yaml
ignore_failed_clean: true
- name: Install Ingress Controller
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }}
run: |
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=90s
- name: 'Run E2E tests (RHDH Operator Upgrade path: ${{ matrix.from_branch }} => ${{ matrix.to_branch }})'
if: ${{ steps.upgrade-path-checker.outputs.SHOULD_BE_SKIPPED_BECAUSE_SAME_BRANCH_OR_DOWNGRADE != 'true' && steps.operator-image-existence-checker.outputs.FROM_OPERATOR_IMAGE_EXISTS == 'true' && steps.operator-image-existence-checker.outputs.TO_OPERATOR_IMAGE_EXISTS == 'true' }}
env:
BACKSTAGE_OPERATOR_TESTS_PLATFORM: kind
PROFILE: 'rhdh'
FROM_OPERATOR_MANIFEST: ${{ env.FROM_OPERATOR_MANIFEST }}
TO_OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }}
OPERATOR_MANIFEST: ${{ env.TO_OPERATOR_MANIFEST }}
IMG: ${{ env.TO_OPERATOR_IMAGE }}
run: make test-e2e-upgrade