-
Notifications
You must be signed in to change notification settings - Fork 58
169 lines (162 loc) · 7.38 KB
/
Copy pathtest-windows-e2e.yml
File metadata and controls
169 lines (162 loc) · 7.38 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
name: Run Windows E2E on EKS
on:
workflow_dispatch:
push:
branches:
- test-windows-*
pull_request:
branches:
- main
permissions:
id-token: write
contents: read
pull-requests: read
security-events: write
concurrency:
group: windows-e2e-tests
cancel-in-progress: false
jobs:
generate-key:
# Do not run e2e tests if PR has skip-e2e label, or if it's from a forked repo (external contribution)
if: github.event_name != 'pull_request' || (!contains(github.event.pull_request.labels.*.name, 'ci/skip-e2e') && github.event.pull_request.head.repo.full_name == 'newrelic/nri-kubernetes')
runs-on: ubuntu-latest
outputs:
run_key: ${{ steps.random-string.outputs.random_string }}
steps:
- name: just a small random 5 letter string
id: random-string
run: |
echo "random_string=$(head -c20 /dev/urandom | base64 | tr -dc 'a-z' | head -c5)" >> $GITHUB_OUTPUT
create-linux-image:
name: Create Linux Image for E2E Test
needs: generate-key
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: '1'
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }}
password: ${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }}
- name: Build and push Linux image
run: |
GOOS=linux GOARCH=amd64 make compile
docker build -t newrelic/nri-kubernetes-internal:linux-e2e-testing-${{ needs.generate-key.outputs.run_key }} .
docker push newrelic/nri-kubernetes-internal:linux-e2e-testing-${{ needs.generate-key.outputs.run_key }}
create-windows-image:
name: Create Windows Image for E2E Test
needs: generate-key
uses: "./.github/workflows/build-windows-integration-test.yml"
with:
# leave this empty to build both ltsc2019 and ltsc2022
only_this_windows_version_tag:
scenario_tag: ${{ needs.generate-key.outputs.run_key }}
secrets:
K8S_AGENTS_DOCKERHUB_USERNAME: ${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }}
K8S_AGENTS_DOCKERHUB_TOKEN: ${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }}
e2e:
needs: [ create-linux-image, create-windows-image, generate-key ]
strategy:
fail-fast: false
matrix:
runner:
- kubernetes_version: 'v1.31.0'
values_template: 'e2e-values-windows-k8s-1-31-template.yml'
spec_file: 'test-specs-windows-k8s-1-31.yml'
exceptions_file: '1_31-exceptions-windows.yml'
eks_cluster_name: 'test-win-1-31'
iam_role: 'gha-role-test-win-1-31'
- kubernetes_version: 'v1.35.0'
values_template: 'e2e-values-windows-k8s-1-35-template.yml'
spec_file: 'test-specs-windows-k8s-1-35.yml'
exceptions_file: '1_35-exceptions-windows.yml'
eks_cluster_name: 'test-win-1-35'
iam_role: 'gha-role-test-win-1-35'
name: E2E Test on EKS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Create Cluster Specific Scenario Tag and Namespace Env
id: create-scenario-tag-and-ns
run: |
scenario_tag="${{ needs.generate-key.outputs.run_key }}-${{ matrix.runner.eks_cluster_name }}"
echo "scenario_tag=$scenario_tag" >> "$GITHUB_OUTPUT"
new_namespace="nr-$scenario_tag"
echo "new_namespace=$new_namespace" >> "$GITHUB_OUTPUT"
- name: Configure AWS Credentials via OIDC
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::${{ secrets.K8S_AWS_ACCOUNT_ID }}:role/${{ matrix.runner.iam_role }}
aws-region: us-west-1
role-session-name: ${{ matrix.runner.iam_role }}-test-session
- name: Update kubeconfig
run: |
aws eks update-kubeconfig --name ${{ matrix.runner.eks_cluster_name }} --region us-west-1
- name: Verify cluster access
run: |
kubectl get nodes
- name: Echo output from build-windows-integration-test
run: |
echo "Output from build-windows-integration-test: ${{ needs.create-windows-image.outputs.image }}"
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }}
password: ${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }}
- name: Setup Access to Private Docker Registry
env:
NEW_NAMESPACE: ${{ steps.create-scenario-tag-and-ns.outputs.new_namespace }}
run: |
kubectl create namespace $NEW_NAMESPACE || echo "Namespace $NEW_NAMESPACE already exists, skipping creation."
if ! kubectl get secret "nri-kubernetes-internal-dockerhub" -n $NEW_NAMESPACE >/dev/null 2>&1; then
kubectl create secret docker-registry nri-kubernetes-internal-dockerhub -n $NEW_NAMESPACE \
--docker-server=docker.io \
--docker-username=${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }} \
--docker-password=${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }}
else
echo "Secret nri-kubernetes-internal-dockerhub already exists, skipping creation."
fi
- name: Setup Helm
run: |
chmod go-r /home/runner/.kube/config
helm repo add newrelic https://helm-charts.newrelic.com
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
- name: Add PullSecret to e2e-values.yml
run: |
export IMAGE_2019="newrelic/nri-kubernetes-internal:windows-ltsc2019-e2e-testing-${{ needs.generate-key.outputs.run_key }}"
export IMAGE_2022="newrelic/nri-kubernetes-internal:windows-ltsc2022-e2e-testing-${{ needs.generate-key.outputs.run_key }}"
export LINUX_TAG="linux-e2e-testing-${{ needs.generate-key.outputs.run_key }}"
envsubst < e2e/${{ matrix.runner.values_template }} > e2e/e2e-values-windows.yml
cat e2e/e2e-values-windows.yml
- name: Run e2e-test
uses: newrelic/newrelic-integration-e2e-action@v1
env:
EXCEPTIONS_SOURCE_FILE: ${{ matrix.runner.exceptions_file }}
FETCH_PODS_FROM_KUBE_SERVICE: "false"
with:
retry_seconds: 60
retry_attempts: 5
agent_enabled: false
scenario_tag: ${{ steps.create-scenario-tag-and-ns.outputs.scenario_tag }}
spec_path: e2e/${{ matrix.runner.spec_file }}
account_id: ${{ secrets.K8S_AGENTS_E2E_ACCOUNT_ID }}
api_key: ${{ secrets.K8S_AGENTS_E2E_API_KEY }}
license_key: ${{ secrets.K8S_AGENTS_E2E_LICENSE_KEY }}
- name: Cleanup Testing Resources
if: always()
env:
NEW_NAMESPACE: ${{ steps.create-scenario-tag-and-ns.outputs.new_namespace }}
SCENARIO_TAG: ${{ steps.create-scenario-tag-and-ns.outputs.scenario_tag }}
run: |
helm uninstall $SCENARIO_TAG -n $NEW_NAMESPACE || echo "Helm release $SCENARIO_TAG already deleted or does not exist."
helm uninstall $SCENARIO_TAG-resources -n $NEW_NAMESPACE || echo "Helm release $SCENARIO_TAG-resources already deleted or does not exist."
kubectl delete namespace $NEW_NAMESPACE || echo "Namespace $NEW_NAMESPACE already deleted or does not exist."