Skip to content

Commit bf94984

Browse files
ci: fix docker env creation for e2e tests (#909)
- Update the matrix version to get the latest splunk version to be used in e2e tests - Fixes the issue with the e2e tests execution where the tests were failing due to issues in the docker services being created.
1 parent cd0c088 commit bf94984

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

.github/workflows/build-test-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
meta:
1818
runs-on: ubuntu-22.04
1919
outputs:
20-
matrix_supportedSplunk: ${{ steps.matrix.outputs.supportedSplunk }}
20+
matrix_supportedSplunk: ${{ steps.matrix.outputs.latestSplunk }}
2121
steps:
2222
- uses: actions/checkout@v4
2323
- id: matrix
24-
uses: splunk/addonfactory-test-matrix-action@v1
24+
uses: splunk/addonfactory-test-matrix-action@v3
2525

2626
fossa-scan:
2727
continue-on-error: true

docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ services:
3838
- "6514"
3939
stdin_open: true
4040
tty: true
41-
links:
42-
- splunk
41+
depends_on:
42+
splunk:
43+
condition: service_healthy
4344
environment:
4445
- SPLUNK_HEC_URL=https://splunk:8088
4546
- SPLUNK_HEC_TOKEN=${SPLUNK_HEC_TOKEN}
@@ -92,8 +93,9 @@ services:
9293
ports:
9394
- "9997"
9495
- "8089"
95-
links:
96-
- splunk
96+
depends_on:
97+
splunk:
98+
condition: service_healthy
9799
environment:
98100
- SPLUNK_PASSWORD=Chang3d!
99101
- SPLUNK_START_ARGS=--accept-license

pytest_splunk_addon/docker_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def start(self, *services):
6565
6666
:param services: the names of the services as defined in compose file
6767
"""
68-
self._docker_compose.execute("up", "--build", "-d", *services)
68+
self._docker_compose.execute("up", "--build", "--wait", *services)
6969

7070
def stop(self, *services):
7171
"""Ensures that the given services are stopped via docker compose.

pytest_splunk_addon/splunk.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,6 @@ def uf_docker(docker_services, tmp_path_factory, worker_id, request):
490490
"""
491491
Provides IP of the uf server and management port based on pytest-args(splunk_type)
492492
"""
493-
LOGGER.info("Starting docker_service=uf")
494-
os.environ["CURRENT_DIR"] = os.getcwd()
495-
if worker_id:
496-
# get the temp directory shared by all workers
497-
root_tmp_dir = tmp_path_factory.getbasetemp().parent
498-
fn = root_tmp_dir / "pytest_docker"
499-
with FileLock(str(fn) + ".lock"):
500-
docker_services.start("uf")
501493
uf_info = {
502494
"uf_host": docker_services.docker_ip,
503495
"uf_port": docker_services.port_for("uf", 8089),
@@ -540,6 +532,7 @@ def splunk_docker(
540532
"""
541533
# configuration of environment variables needed by docker-compose file
542534
os.environ["SPLUNK_APP_PACKAGE"] = request.config.getoption("splunk_app")
535+
os.environ["CURRENT_DIR"] = os.getcwd()
543536
try:
544537
config = configparser.ConfigParser()
545538
config.read(
@@ -558,14 +551,14 @@ def splunk_docker(
558551
os.environ["SPLUNK_VERSION"] = request.config.getoption("splunk_version")
559552
os.environ["SC4S_VERSION"] = request.config.getoption("sc4s_version")
560553

561-
LOGGER.info("Starting docker_service=splunk")
554+
LOGGER.info("Starting docker services")
562555
if worker_id:
563556
# get the temp directory shared by all workers
564557
root_tmp_dir = tmp_path_factory.getbasetemp().parent
565558
fn = root_tmp_dir / "pytest_docker"
566559
# if you encounter docker-compose not found modify shell path in your IDE to use /bin/bash
567560
with FileLock(str(fn) + ".lock"):
568-
docker_services.start("splunk")
561+
docker_services.start()
569562

570563
splunk_info = {
571564
"host": docker_services.docker_ip,
@@ -648,13 +641,6 @@ def sc4s_docker(docker_services, tmp_path_factory, worker_id):
648641
"""
649642
Provides IP of the sc4s server and related ports based on pytest-args(splunk_type)
650643
"""
651-
if worker_id:
652-
# get the temp directory shared by all workers
653-
root_tmp_dir = tmp_path_factory.getbasetemp().parent
654-
fn = root_tmp_dir / "pytest_docker"
655-
with FileLock(str(fn) + ".lock"):
656-
docker_services.start("sc4s")
657-
658644
ports = {514: docker_services.port_for("sc4s", 514)}
659645
for x in range(5000, 5007):
660646
ports.update({x: docker_services.port_for("sc4s", x)})

0 commit comments

Comments
 (0)