forked from awslabs/mountpoint-s3-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (195 loc) · 7.37 KB
/
Copy pathe2e-rosa-tests.yaml
File metadata and controls
201 lines (195 loc) · 7.37 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: E2E ROSA Tests
on:
workflow_call:
inputs:
environment:
required: true
type: string
ref:
required: true
type: string
concurrency:
group: e2e-cluster-${{ inputs.environment }}
queue: max
env:
IMAGE_NAME: "s3-csi-driver"
BENCHMARK_ARTIFACTS_FOLDER: ".github/artifacts"
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BENCHMARK_BUCKET: "s3://${{ vars.BENCHMARK_BUCKET }}"
TAG_UNTESTED: "untested_${{ inputs.ref }}"
TAG_PASSED: "test_passed_${{ inputs.ref }}"
CLUSTER_TYPE: "openshift"
CLUSTER_NAME: "s3-csi-${{ inputs.environment }}"
jobs:
build:
runs-on: ubuntu-22.04 # FIXME - https://github.com/actions/runner-images/issues/11471
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ vars.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker image to Amazon ECR Private Repository
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
PLATFORM: "linux/amd64,linux/arm64"
TAG: "${{ env.TAG_UNTESTED }}"
run: |
make -j `nproc` all-push-skip-if-present
test:
needs: [build]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
env:
AWS_REGION: "${{ vars.AWS_REGION }}"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
- name: Install Terraform
uses: hashicorp/setup-terraform@v4
with:
terraform_version: "1.14.9" # FIXME - Remove pin once Terraform >= 1.15.1 is released
- name: Configure AWS Credentials
id: aws-creds
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ vars.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 7200
- name: Install tools
env:
ACTION: "install_tools"
run: tests/e2e-kubernetes/scripts/run.sh
- name: Install OpenShift CLI
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "latest"
- name: Get ROSA Token
uses: aws-actions/aws-secretsmanager-get-secrets@v3
with:
secret-ids: |
RosaToken
- name: Initialize Terraform
working-directory: tests/e2e-kubernetes/rosa/
env:
TF_VAR_aws_region: "${{ vars.AWS_REGION }}"
TERRAFORM_BUCKET: "${{ vars.TERRAFORM_BUCKET }}"
run: |
terraform init \
-backend-config="bucket=$TERRAFORM_BUCKET" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=$TF_VAR_aws_region"
- name: Validate Terraform configuration
working-directory: tests/e2e-kubernetes/rosa/
run: terraform validate
- name: Check cluster age and destroy if too old
id: check_cluster_age
working-directory: tests/e2e-kubernetes/rosa/
env:
MAX_AGE_DAYS: 3
run: |
set -euo pipefail
# Check if cluster creation timestamp exists in Terraform state
CLUSTER_CREATED=$(terraform show -json | jq -r '
(.values.root_module.resources // []) |
map(select(.type == "terraform_data" and .name == "cluster_creation_time")) |
.[0].values.output // empty
')
if [ -z "$CLUSTER_CREATED" ] || [ "$CLUSTER_CREATED" = "null" ]; then
echo "No existing cluster found (no creation timestamp in state)"
echo "destroy_cluster=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Cluster created at: $CLUSTER_CREATED"
# Calculate cluster age in days
CREATED_EPOCH=$(date -d "$CLUSTER_CREATED" +%s)
CURRENT_EPOCH=$(date +%s)
AGE_DAYS=$(( ($CURRENT_EPOCH - $CREATED_EPOCH) / 86400 ))
echo "Cluster age: $AGE_DAYS days"
if [ $AGE_DAYS -ge $MAX_AGE_DAYS ]; then
echo "Cluster is $AGE_DAYS days old (>= $MAX_AGE_DAYS days). Destroying for fresh deployment."
echo "destroy_cluster=true" >> $GITHUB_OUTPUT
else
echo "Cluster is $AGE_DAYS days old (< $MAX_AGE_DAYS days). Will reuse existing cluster."
echo "destroy_cluster=false" >> $GITHUB_OUTPUT
fi
- name: Destroy old cluster
if: steps.check_cluster_age.outputs.destroy_cluster != 'false'
working-directory: tests/e2e-kubernetes/rosa/
env:
TF_VAR_aws_region: "${{ vars.AWS_REGION }}"
TF_VAR_cluster_name: "s3-csi-${{ inputs.environment }}"
TF_VAR_rhcs_token: "${{ env.ROSATOKEN }}"
TF_VAR_billing_account_id: ${{ secrets.ROSA_BILLING_ACCOUNT_ID }}
run: terraform destroy --auto-approve
- name: Create/Update ROSA cluster
working-directory: tests/e2e-kubernetes/rosa/
env:
TF_VAR_aws_region: "${{ vars.AWS_REGION }}"
TF_VAR_cluster_name: "s3-csi-${{ inputs.environment }}"
TF_VAR_rhcs_token: "${{ env.ROSATOKEN }}"
TF_VAR_billing_account_id: ${{ secrets.ROSA_BILLING_ACCOUNT_ID }}
run: terraform apply --auto-approve
- name: Get OpenShift credentials
uses: aws-actions/aws-secretsmanager-get-secrets@v3
with:
secret-ids: |
OPENSHIFT_CREDS,s3-csi-${{ inputs.environment }}-openshift-credentials
parse-json-secrets: true
- name: Login to OpenShift
id: openshift_login
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_CREDS_CLUSTER_API_URL }}
openshift_username: ${{ env.OPENSHIFT_CREDS_CLUSTER_ADMIN_USERNAME }}
openshift_password: ${{ env.OPENSHIFT_CREDS_CLUSTER_ADMIN_PASSWORD }}
- name: Install the driver
env:
ACTION: "install_driver"
TAG: "untested_${{ inputs.ref }}"
CSI_DRIVER_IRSA_ROLE_ARN: "arn:aws:iam::${{ steps.aws-creds.outputs.aws-account-id }}:role/s3-csi-${{ inputs.environment }}-driver-irsa"
run: tests/e2e-kubernetes/scripts/run.sh
- name: Run E2E Tests
env:
ACTION: "run_tests"
IMDS_AVAILABLE: "false"
run: tests/e2e-kubernetes/scripts/run.sh
- name: Post e2e cleanup
if: always()
env:
ACTION: "e2e_cleanup"
run: tests/e2e-kubernetes/scripts/run.sh
- name: Uninstall the driver
# Skip uninstall if OpenShift login did not succeed - no cluster access
if: ${{ always() && steps.openshift_login.conclusion == 'success' }}
env:
ACTION: "uninstall_driver"
run: tests/e2e-kubernetes/scripts/run.sh