Skip to content

Commit f79ba4e

Browse files
committed
Add direct connection string, fix yml creation
1 parent 35326b9 commit f79ba4e

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

.github/workflows/functional-tests.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
TAG=${INPUT_TAG}
8181
8282
EA_VERSION=2.2.0-1166
83+
export EA_VERSION
8384
8485
cat > cluster.yml <<'YAML'
8586
columnar: true
@@ -92,16 +93,37 @@ jobs:
9293
jwt: true
9394
YAML
9495
95-
# Substitute shell vars into YAML
96-
eval "echo \"$(cat cluster.yml)\"" > cluster.resolved.yml
96+
# Substitute shell vars into YAML (envsubst preserves YAML structure;
97+
# the previous eval+echo approach collapsed newlines and silently
98+
# dropped the load-balancer flag)
99+
envsubst < cluster.yml > cluster.resolved.yml
100+
echo "Resolved cluster definition:" && cat cluster.resolved.yml
97101
98102
CBDINO_CLUSTER_ID=$(cbdinocluster -v alloc --def="$(cat cluster.resolved.yml)")
103+
104+
# Connection string through the load balancer (used by most tests)
99105
CBDINO_CONNSTR=$(cbdinocluster -v connstr --tls --analytics "$CBDINO_CLUSTER_ID")
100106
107+
# Direct-to-node connection string (required for mTLS tests because
108+
# the nginx passive load balancer terminates TLS at L7, so client
109+
# certificates are not forwarded to the analytics service).
110+
# We get the first cluster node IP by listing nodes and filtering
111+
# out non-cluster containers (s3mock, nginx, haproxy).
112+
NODE_IP=$(cbdinocluster -v ps 2>&1 | grep -E 'columnar-node|server-node' | head -1 | grep -oP '\d+\.\d+\.\d+\.\d+' || echo "")
113+
if [ -n "$NODE_IP" ]; then
114+
CBDINO_CONNSTR_DIRECT="https://${NODE_IP}:18095"
115+
else
116+
# No LB or couldn't parse — fall back to the primary connstr
117+
CBDINO_CONNSTR_DIRECT="$CBDINO_CONNSTR"
118+
fi
119+
101120
echo "CBDINO_CLUSTER_ID=$CBDINO_CLUSTER_ID" >> "$GITHUB_ENV"
102121
echo "CBDINO_CONNSTR=$CBDINO_CONNSTR" >> "$GITHUB_ENV"
122+
echo "CBDINO_CONNSTR_DIRECT=$CBDINO_CONNSTR_DIRECT" >> "$GITHUB_ENV"
103123
echo "CBDINO_USER=Administrator" >> "$GITHUB_ENV"
104124
echo "CBDINO_PASS=password" >> "$GITHUB_ENV"
125+
echo "Load balancer connstr: $CBDINO_CONNSTR"
126+
echo "Direct node connstr: $CBDINO_CONNSTR_DIRECT"
105127
106128
- name: Create JWT test user and generate token
107129
run: |
@@ -144,6 +166,7 @@ jobs:
144166
{
145167
"TestSettings": {
146168
"ConnectionString": "${CBDINO_CONNSTR}",
169+
"DirectConnectionString": "${CBDINO_CONNSTR_DIRECT}",
147170
"Username": "${CBDINO_USER}",
148171
"Password": "${CBDINO_PASS}",
149172
"JwtToken": "${CBDINO_JWT}",

tests/Couchbase.Analytics.FunctionalTests/Fixtures/CertificateFixture.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ public CertificateFixture()
3737
FixtureSettings.ClientCertPath,
3838
FixtureSettings.ClientKeyPath);
3939

40+
// mTLS requires a direct-to-node connection because the nginx passive
41+
// load balancer terminates TLS at L7 and does not forward client
42+
// certificates to the analytics service.
43+
var connectionString = FixtureSettings.DirectConnectionString
44+
?? FixtureSettings.ConnectionString!;
45+
4046
ClusterOptions = new ClusterOptions();
4147
Cluster = Cluster.Create(
42-
FixtureSettings.ConnectionString!,
48+
connectionString,
4349
CertificateCredential,
4450
ClusterOptions);
4551
}

tests/Couchbase.Analytics.FunctionalTests/Fixtures/FixtureSettings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ public class FixtureSettings
77
[JsonPropertyName("ConnectionString")]
88
public string? ConnectionString { get; set; } = "http://localhost:8095";
99

10+
/// <summary>
11+
/// Direct-to-node connection string that bypasses the load balancer.
12+
/// Required for mTLS tests because the nginx passive load balancer
13+
/// terminates TLS at L7 and does not forward client certificates.
14+
/// Falls back to <see cref="ConnectionString"/> if not set.
15+
/// </summary>
16+
[JsonPropertyName("DirectConnectionString")]
17+
public string? DirectConnectionString { get; set; }
18+
1019
[JsonPropertyName("Username")]
1120
public string Username { get; set; } = "Administrator";
1221

0 commit comments

Comments
 (0)