Skip to content

Commit d99057b

Browse files
committed
Add go e2e tests
1 parent 94ccd30 commit d99057b

File tree

2 files changed

+221
-4
lines changed

2 files changed

+221
-4
lines changed

.github/workflows/e2e-go.yml

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
name: E2E - Go Layer
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
logzio_api_url:
7+
description: "Logz.io API base URL (default https://api.logz.io)"
8+
required: false
9+
default: "https://api.logz.io"
10+
aws_region:
11+
description: "AWS Region"
12+
required: false
13+
default: "us-east-1"
14+
15+
push:
16+
branches:
17+
- feat/unified-lambda-layer
18+
19+
permissions:
20+
contents: read
21+
22+
env:
23+
AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }}
24+
AWS_DEFAULT_REGION: ${{ inputs.aws_region || 'us-east-1' }}
25+
ARCHITECTURE: amd64
26+
FUNCTION_NAME: one-layer-e2e-test-go
27+
LAYER_BASE_NAME: otel-go-extension-e2e
28+
SERVICE_NAME: logzio-e2e-go-service
29+
LOGZIO_REGION: us
30+
31+
jobs:
32+
build-layer:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Go (for Collector)
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version-file: collector/go.mod
42+
43+
- name: Build combined Go layer (amd64)
44+
run: |
45+
cd go
46+
ARCHITECTURE=${ARCHITECTURE} ./build-combined.sh
47+
48+
- name: Upload layer artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: otel-go-extension-layer.zip
52+
path: go/build/otel-go-extension-layer.zip
53+
54+
publish-update-invoke:
55+
runs-on: ubuntu-latest
56+
needs: build-layer
57+
outputs:
58+
layer_arn: ${{ steps.publish.outputs.layer_arn }}
59+
e2e_label: ${{ steps.vars.outputs.e2e_label }}
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Download layer artifact
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: otel-go-extension-layer.zip
68+
69+
- name: Configure AWS (User Credentials)
70+
uses: aws-actions/configure-aws-credentials@v4
71+
with:
72+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
73+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
74+
aws-region: ${{ env.AWS_REGION }}
75+
76+
- name: Publish layer version
77+
id: publish
78+
shell: bash
79+
run: |
80+
set -euo pipefail
81+
LAYER_NAME="${LAYER_BASE_NAME}-amd64"
82+
ARN=$(aws lambda publish-layer-version \
83+
--layer-name "$LAYER_NAME" \
84+
--license-info "Apache-2.0" \
85+
--compatible-architectures x86_64 \
86+
--compatible-runtimes provided provided.al2 \
87+
--zip-file fileb://otel-go-extension-layer.zip \
88+
--query 'LayerVersionArn' --output text)
89+
echo "layer_arn=$ARN" >> "$GITHUB_OUTPUT"
90+
91+
- name: Prepare variables
92+
id: vars
93+
run: |
94+
echo "e2e_label=go-e2e-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT"
95+
96+
- name: Check function exists and get current config
97+
run: |
98+
echo "Checking if function exists and its current configuration..."
99+
aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query '{Role:Role,KMSKeyArn:KMSKeyArn,State:State,LastUpdateStatus:LastUpdateStatus}' --output table || {
100+
echo "❌ Function ${FUNCTION_NAME} does not exist or is not accessible."
101+
exit 1
102+
}
103+
104+
echo "Current environment variables:"
105+
aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query 'Environment.Variables' --output json || echo "No environment variables set"
106+
107+
- name: Update Lambda configuration
108+
run: |
109+
echo "Updating function configuration..."
110+
aws lambda update-function-configuration \
111+
--function-name "${FUNCTION_NAME}" \
112+
--layers "${{ steps.publish.outputs.layer_arn }}" \
113+
--environment "Variables={OPENTELEMETRY_COLLECTOR_CONFIG_URI=/opt/collector-config/config.e2e.yaml,OTEL_SERVICE_NAME=${SERVICE_NAME},OTEL_TRACES_SAMPLER=always_on,OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${{ steps.vars.outputs.e2e_label }},ENVIRONMENT=${{ steps.vars.outputs.e2e_label }},LOGZIO_REGION=${LOGZIO_REGION},LOGZIO_LOGS_TOKEN=${{ secrets.LOGZIO_LOGS_TOKEN }},LOGZIO_TRACES_TOKEN=${{ secrets.LOGZIO_TRACES_TOKEN }},LOGZIO_METRICS_TOKEN=${{ secrets.LOGZIO_METRICS_TOKEN }}}"
114+
115+
echo "Waiting for function update to complete..."
116+
aws lambda wait function-updated --function-name "${FUNCTION_NAME}"
117+
118+
echo "Updated configuration:"
119+
aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query '{Layers:Layers[].Arn,Environment:Environment.Variables}' --output json
120+
121+
- name: Invoke function multiple times
122+
run: |
123+
echo "Invoking function first time..."
124+
aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response1.json
125+
echo "First invocation response:"
126+
cat response1.json
127+
echo ""
128+
129+
echo "Invoking function second time..."
130+
aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response2.json
131+
echo "Second invocation response:"
132+
cat response2.json
133+
echo ""
134+
135+
echo "Sleeping for 5 seconds before additional invocations..."
136+
sleep 5
137+
138+
echo "Invoking function third time..."
139+
aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response3.json
140+
echo "Third invocation response:"
141+
cat response3.json
142+
echo ""
143+
144+
echo "Invoking function fourth time..."
145+
aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response4.json
146+
echo "Fourth invocation response:"
147+
cat response4.json
148+
echo ""
149+
150+
echo "Invoking function fifth time..."
151+
aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response5.json
152+
echo "Fifth invocation response:"
153+
cat response5.json
154+
echo ""
155+
156+
- name: Check CloudWatch logs
157+
run: |
158+
echo "Checking recent CloudWatch logs for the function..."
159+
LOG_GROUP_NAME="/aws/lambda/${FUNCTION_NAME}"
160+
161+
# Get recent log events (last 5 minutes)
162+
aws logs filter-log-events \
163+
--log-group-name "$LOG_GROUP_NAME" \
164+
--start-time $(date -d '5 minutes ago' +%s)000 \
165+
--query 'events[].message' \
166+
--output text || {
167+
echo "❌ Could not fetch CloudWatch logs. Log group might not exist or no recent logs."
168+
echo "Checking if log group exists..."
169+
aws logs describe-log-groups --log-group-name-prefix "$LOG_GROUP_NAME" --query 'logGroups[].logGroupName' --output text
170+
}
171+
172+
verify-e2e:
173+
runs-on: ubuntu-latest
174+
needs: publish-update-invoke
175+
steps:
176+
- name: Checkout
177+
uses: actions/checkout@v4
178+
179+
- name: Set up Go
180+
uses: actions/setup-go@v5
181+
with:
182+
go-version: '1.21'
183+
184+
- name: Run E2E verification tests
185+
working-directory: e2e_tests
186+
env:
187+
LOGZIO_API_KEY: ${{ secrets.LOGZIO_API_KEY }}
188+
LOGZIO_API_URL: ${{ inputs.logzio_api_url || 'https://api.logz.io' }}
189+
LOGZIO_API_METRICS_KEY: ${{ secrets.LOGZIO_API_METRICS_KEY }}
190+
LOGZIO_METRICS_QUERY_URL: ${{ inputs.logzio_api_url || 'https://api.logz.io' }}
191+
LOGZIO_API_TRACES_KEY: ${{ secrets.LOGZIO_API_TRACES_KEY }}
192+
E2E_TEST_ENVIRONMENT_LABEL: ${{ needs.publish-update-invoke.outputs.e2e_label }}
193+
EXPECTED_LAMBDA_FUNCTION_NAME: one-layer-e2e-test-go
194+
EXPECTED_SERVICE_NAME: ${{ env.SERVICE_NAME }}
195+
GITHUB_RUN_ID: ${{ github.run_id }}
196+
AWS_REGION: ${{ env.AWS_REGION }}
197+
run: |
198+
go mod tidy
199+
go test ./... -v -tags=e2e -run TestE2ERunner
200+
201+
cleanup:
202+
if: always()
203+
runs-on: ubuntu-latest
204+
needs: [publish-update-invoke, verify-e2e]
205+
steps:
206+
- name: Configure AWS (User Credentials)
207+
uses: aws-actions/configure-aws-credentials@v4
208+
with:
209+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
210+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
211+
aws-region: ${{ inputs.aws_region || 'us-east-1' }}
212+
- name: Delete published layer version
213+
if: ${{ needs.publish-update-invoke.outputs.layer_arn != '' }}
214+
shell: bash
215+
run: |
216+
ARN="${{ needs.publish-update-invoke.outputs.layer_arn }}"
217+
LAYER_NAME=$(echo "$ARN" | cut -d: -f7)
218+
LAYER_VERSION=$(echo "$ARN" | cut -d: -f8)
219+
aws lambda delete-layer-version --layer-name "$LAYER_NAME" --version-number "$LAYER_VERSION" || echo "Failed to delete layer version."
220+
221+

.github/workflows/e2e-ruby.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ on:
1212
required: false
1313
default: "us-east-1"
1414

15-
push:
16-
branches:
17-
- feat/unified-lambda-layer
18-
1915
permissions:
2016
contents: read
2117

0 commit comments

Comments
 (0)