From ede1b306bc6f3ff2332e0cf31f6f5be1082b1217 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 26 Nov 2026 10:33:55 +0000
Subject: [PATCH] Stop Cassandra and Postgres after LDAP CI tests (#1332)
---
.github/workflows/build.yml | 6 ++++--
.github/scripts/stop-test-container.sh | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/.github/scripts/stop-test-container.sh b/.github/scripts/stop-test-container.sh
new file mode 100644
index 0000000..ad0b94c
--- /dev/null
+++ b/.github/scripts/stop-test-container.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# The contents of this file are subject to the terms of the Common Development and
+# Distribution License (the License). You may not use this file except in compliance with the
+# License.
+#
+# You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
+# specific language governing permission and limitations under the License.
+#
+# When distributing Covered Software, include this CDDL Header Notice in each file and include
+# the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
+# Header, with the fields enclosed by brackets [] replaced by your own identifying
+# information: "Portions copyright [year] [name of copyright owner]".
+#
+# Copyright 2026 3A Systems, LLC.
+
+step_status=$1
+container_id=$2
+
+if stop_output=$(docker stop "$container_id" 2>&1); then
+ exit "$step_status"
+else
+ stop_status=$?
+fi
+
+# Docker may have already removed a container started with --rm.
+if running=$(docker ps --quiet --filter "id=$container_id") && [[ -z "$running" ]]; then
+ exit "$step_status"
+fi
+
+printf '%s\n' "$stop_output" >&2
+if (( step_status == 0 )); then
+ exit "$stop_status"
+fi
+exit "$step_status"
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b17e8ba..4096eee 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -289,7 +289,8 @@
- name: Test LDAP in Cassandra
if: runner.os == 'Linux'
run: |
- docker run --rm -it -d -p 9042:9042 --name cassandra cassandra
+ container_id=$(docker run --rm -it -d -p 9042:9042 --name cassandra cassandra)
+ trap 'bash .github/scripts/stop-test-container.sh "$?" "$container_id" || exit "$?"' EXIT
timeout 5m bash -c 'until docker logs cassandra | grep -q "Created default superuser role"; do sleep 5; done'
export OPENDJ_JAVA_ARGS="-server -Xmx512m -Ddatastax-java-driver.basic.contact-points.0=localhost:9042 -Ddatastax-java-driver.basic.load-balancing-policy.local-datacenter=datacenter1"
opendj-server-legacy/target/package/opendj/setup -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --cli --acceptLicense --no-prompt
@@ -304,7 +305,8 @@
- name: Test LDAP in Postgres
if: runner.os == 'Linux'
run: |
- docker run --rm -it -d -p 5432:5432 -e POSTGRES_DB=database_name -e POSTGRES_PASSWORD=password --name postgres postgres
+ container_id=$(docker run --rm -it -d -p 5432:5432 -e POSTGRES_DB=database_name -e POSTGRES_PASSWORD=password --name postgres postgres)
+ trap 'bash .github/scripts/stop-test-container.sh "$?" "$container_id" || exit "$?"' EXIT
timeout 5m bash -c 'until docker logs postgres | grep -q "database system is ready to accept connections"; do sleep 5; done'
export OPENDJ_JAVA_ARGS="-server -Xmx512m"
opendj-server-legacy/target/package/opendj/setup -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --cli --acceptLicense --no-prompt
--
Gitblit v1.10.0