Skip to content

Commit 8059a1a

Browse files
committed
refactor
1 parent 94d8c5c commit 8059a1a

File tree

3 files changed

+114
-122
lines changed

3 files changed

+114
-122
lines changed

.github/actions/setup/action.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 'Setup Integration Test Environment'
2+
description: 'Common setup steps for integration and secure integration tests'
3+
4+
inputs:
5+
elastic_stack_version:
6+
description: 'Elasticsearch stack version to test against'
7+
required: true
8+
snapshot:
9+
description: 'Whether to use snapshot version'
10+
required: false
11+
default: 'false'
12+
secure_integration:
13+
description: 'Enable secure integration testing'
14+
required: false
15+
default: 'false'
16+
es_ssl_key_invalid:
17+
description: 'Use invalid SSL key for testing'
18+
required: false
19+
default: 'false'
20+
es_ssl_supported_protocols:
21+
description: 'SSL/TLS protocols to test'
22+
required: false
23+
default: ''
24+
25+
outputs:
26+
skip:
27+
description: 'Whether the test should be skipped'
28+
value: ${{ steps.check_skip.outputs.skip }}
29+
30+
runs:
31+
using: 'composite'
32+
steps:
33+
- name: Set up environment variables
34+
shell: bash
35+
env:
36+
ELASTIC_STACK_VERSION: ${{ inputs.elastic_stack_version }}
37+
SNAPSHOT: ${{ inputs.snapshot }}
38+
SECURE_INTEGRATION: ${{ inputs.secure_integration }}
39+
ES_SSL_KEY_INVALID: ${{ inputs.es_ssl_key_invalid }}
40+
ES_SSL_SUPPORTED_PROTOCOLS: ${{ inputs.es_ssl_supported_protocols }}
41+
run: |
42+
echo "INTEGRATION=true" >> $GITHUB_ENV
43+
echo "LOG_LEVEL=info" >> $GITHUB_ENV
44+
echo "ELASTIC_STACK_VERSION=${ELASTIC_STACK_VERSION}" >> $GITHUB_ENV
45+
46+
if [ "${SNAPSHOT}" = "true" ]; then
47+
echo "SNAPSHOT=true" >> $GITHUB_ENV
48+
fi
49+
50+
if [ "${SECURE_INTEGRATION}" = "true" ]; then
51+
echo "SECURE_INTEGRATION=true" >> $GITHUB_ENV
52+
fi
53+
54+
if [ "${ES_SSL_KEY_INVALID}" = "true" ]; then
55+
echo "ES_SSL_KEY_INVALID=true" >> $GITHUB_ENV
56+
fi
57+
58+
if [ -n "${ES_SSL_SUPPORTED_PROTOCOLS}" ]; then
59+
echo "ES_SSL_SUPPORTED_PROTOCOLS=${ES_SSL_SUPPORTED_PROTOCOLS}" >> $GITHUB_ENV
60+
fi
61+
62+
- name: Setup Docker Buildx
63+
uses: docker/setup-buildx-action@v3
64+
65+
- name: Run docker-setup.sh
66+
id: docker_setup
67+
shell: bash
68+
run: |
69+
set -e
70+
cd .ci
71+
wget -q https://raw.githubusercontent.com/elastic/logstash/main/.ci/docker-setup.sh -O .ci/docker-setup.shhttps://raw.githubusercontent.com/logstash-plugins/.ci/refs/heads/1.x/docker-setup.sh || exit 1
72+
chmod 755 docker-setup.sh
73+
bash .ci/docker-setup.sh
74+
continue-on-error: true
75+
76+
- name: Check if test should be skipped
77+
id: check_skip
78+
if: steps.docker_setup.outcome == 'failure'
79+
shell: bash
80+
run: |
81+
if [ ${{ steps.docker_setup.outputs.exit_code }} -eq 99 ]; then
82+
echo "skip=true" >> $GITHUB_OUTPUT
83+
echo "Test skipped - Docker image not available for this configuration"
84+
else
85+
exit 1
86+
fi

.github/workflows/integration-tests.yml

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ name: Integration Tests
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- "[0-9]+.[0-9]+"
85
pull_request:
96
branches:
107
- main
11-
- "[0-9]+.[0-9]+"
128
workflow_dispatch:
139

1410
jobs:
@@ -27,48 +23,20 @@ jobs:
2723
include:
2824
- elastic_stack_version: "main"
2925
snapshot: true
30-
26+
3127
steps:
3228
- name: Checkout code
33-
uses: actions/checkout@v4
34-
35-
- name: Set up environment variables
36-
run: |
37-
echo "INTEGRATION=true" >> $GITHUB_ENV
38-
echo "LOG_LEVEL=info" >> $GITHUB_ENV
39-
echo "ELASTIC_STACK_VERSION=${{ matrix.elastic_stack_version }}" >> $GITHUB_ENV
40-
if [ "${{ matrix.snapshot }}" = "true" ]; then
41-
echo "SNAPSHOT=true" >> $GITHUB_ENV
42-
fi
43-
44-
- name: Setup Docker Buildx
45-
uses: docker/setup-buildx-action@v3
46-
47-
- name: Run docker-setup.sh
48-
id: docker_setup
49-
run: |
50-
set -e
51-
bash .ci/docker-setup.sh
52-
continue-on-error: true
29+
uses: actions/checkout@v6
5330

54-
- name: Check if test should be skipped
55-
id: check_skip
56-
if: steps.docker_setup.outcome == 'failure'
57-
run: |
58-
if [ ${{ steps.docker_setup.outputs.exit_code }} -eq 99 ]; then
59-
echo "skip=true" >> $GITHUB_OUTPUT
60-
echo "Test skipped - Docker image not available for this configuration"
61-
else
62-
exit 1
63-
fi
31+
- name: Setup test environment
32+
id: setup
33+
uses: ./.github/actions/setup
34+
with:
35+
elastic_stack_version: ${{ matrix.elastic_stack_version }}
36+
snapshot: ${{ matrix.snapshot }}
6437

6538
- name: Run integration tests
66-
if: steps.check_skip.outputs.skip != 'true'
67-
run: |
68-
bash .ci/docker-run.sh
39+
if: steps.setup.outputs.skip != 'true'
40+
run: .ci/docker-run.sh
6941

70-
- name: Cleanup
71-
if: always()
72-
run: |
73-
cd .ci
74-
docker compose down -v || true
42+
# NOTE: no cleanup needed when running on ephemeral runners

.github/workflows/secure-integration-tests.yml

Lines changed: 17 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,41 @@ name: Secure Integration Tests
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- "[0-9]+.[0-9]+"
85
pull_request:
96
branches:
107
- main
11-
- "[0-9]+.[0-9]+"
128
workflow_dispatch:
139

1410
jobs:
1511
secure-integration-tests:
16-
name: Secure Integration Test - ES ${{ matrix.elastic_stack_version }} ${{ matrix.snapshot && '(Snapshot)' || '' }} ${{ matrix.es_ssl_key_invalid && '(Invalid SSL)' || '' }} ${{ matrix.es_ssl_supported_protocols && format('({0})', matrix.es_ssl_supported_protocols) || '' }}
12+
name: Secure Integration Test - ES ${{ matrix.elastic_stack_version }} ${{ matrix.snapshot && '(Snapshot)' || '' }}
1713
runs-on: ubuntu-latest
1814
strategy:
1915
fail-fast: false
2016
matrix:
17+
elastic_stack_version:
18+
- "7.current"
19+
- "8.current"
20+
- "9.current"
21+
snapshot: [false, true]
2122
include:
22-
# Regular secure integration tests
23-
- elastic_stack_version: "7.current"
24-
snapshot: false
25-
- elastic_stack_version: "8.current"
26-
snapshot: false
27-
- elastic_stack_version: "9.current"
28-
snapshot: false
29-
30-
# SSL configuration tests for 8.current
31-
- elastic_stack_version: "8.current"
32-
snapshot: false
33-
es_ssl_key_invalid: true
34-
- elastic_stack_version: "8.current"
35-
snapshot: false
36-
es_ssl_supported_protocols: "TLSv1.3"
37-
38-
# SSL configuration tests for 9.current
39-
- elastic_stack_version: "9.current"
40-
snapshot: false
41-
es_ssl_key_invalid: true
42-
- elastic_stack_version: "9.current"
43-
snapshot: false
44-
es_ssl_supported_protocols: "TLSv1.3"
45-
46-
# Snapshot tests
47-
- elastic_stack_version: "8.current"
48-
snapshot: true
49-
- elastic_stack_version: "9.current"
50-
snapshot: true
5123
- elastic_stack_version: "main"
5224
snapshot: true
5325

5426
steps:
5527
- name: Checkout code
56-
uses: actions/checkout@v4
57-
58-
- name: Set up environment variables
59-
run: |
60-
echo "SECURE_INTEGRATION=true" >> $GITHUB_ENV
61-
echo "INTEGRATION=true" >> $GITHUB_ENV
62-
echo "LOG_LEVEL=info" >> $GITHUB_ENV
63-
echo "ELASTIC_STACK_VERSION=${{ matrix.elastic_stack_version }}" >> $GITHUB_ENV
64-
if [ "${{ matrix.snapshot }}" = "true" ]; then
65-
echo "SNAPSHOT=true" >> $GITHUB_ENV
66-
fi
67-
if [ "${{ matrix.es_ssl_key_invalid }}" = "true" ]; then
68-
echo "ES_SSL_KEY_INVALID=true" >> $GITHUB_ENV
69-
fi
70-
if [ -n "${{ matrix.es_ssl_supported_protocols }}" ]; then
71-
echo "ES_SSL_SUPPORTED_PROTOCOLS=${{ matrix.es_ssl_supported_protocols }}" >> $GITHUB_ENV
72-
fi
73-
74-
- name: Setup Docker Buildx
75-
uses: docker/setup-buildx-action@v3
76-
77-
- name: Run docker-setup.sh
78-
id: docker_setup
79-
run: |
80-
set -e
81-
bash .ci/docker-setup.sh
82-
continue-on-error: true
28+
uses: actions/checkout@v6
8329

84-
- name: Check if test should be skipped
85-
id: check_skip
86-
if: steps.docker_setup.outcome == 'failure'
87-
run: |
88-
if [ ${{ steps.docker_setup.outputs.exit_code }} -eq 99 ]; then
89-
echo "skip=true" >> $GITHUB_OUTPUT
90-
echo "Test skipped - Docker image not available for this configuration"
91-
else
92-
exit 1
93-
fi
30+
- name: Setup test environment
31+
id: setup
32+
uses: ./.github/actions/setup
33+
with:
34+
elastic_stack_version: ${{ matrix.elastic_stack_version }}
35+
snapshot: ${{ matrix.snapshot }}
36+
secure_integration: true
9437

9538
- name: Run secure integration tests
96-
if: steps.check_skip.outputs.skip != 'true'
97-
run: |
98-
bash .ci/docker-run.sh
39+
if: steps.setup.outputs.skip != 'true'
40+
run: .ci/docker-run.sh
9941

100-
- name: Cleanup
101-
if: always()
102-
run: |
103-
cd .ci
104-
docker compose down -v || true
42+
# NOTE: no cleanup needed when running on ephemeral runners

0 commit comments

Comments
 (0)