Skip to content

Commit 4e8f110

Browse files
authored
[DX-2749] remove default image names from chip ingress' docker-compose file (#2391)
1 parent eb33f42 commit 4e8f110

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Remove default ChIP Ingress/Config image name & tag values from docker-compose.yaml, so that they can be overwritten by `testcontainers-go`

framework/components/dockercompose/chip_ingress_set/chip_ingress.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const (
8585

8686
ChipIngressGRPCHostPortEnvVar = "CHIP_INGRESS_GRPC_HOST_PORT"
8787
ChipIngressGRPCPortEnvVar = "CHIP_INGRESS_GRPC_PORT"
88+
ChipIngressImageEnvVar = "CHIP_INGRESS_IMAGE"
89+
ChipConfigImageEnvVar = "CHIP_CONFIG_IMAGE"
8890
)
8991

9092
func New(in *Input) (*Output, error) {
@@ -122,21 +124,22 @@ func NewWithContext(ctx context.Context, in *Input) (*Output, error) {
122124
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
123125
defer cancel()
124126

125-
// Start the stackwith all environment variables from the host process
126-
// set BASIC_AUTH_ENABLED and BASIC_AUTH_PREFIX to false and empty string and allow them to be overridden by the host process
127127
envVars := make(map[string]string)
128-
envVars["BASIC_AUTH_ENABLED"] = "false"
129-
envVars["BASIC_AUTH_PREFIX"] = ""
130-
envVars[ChipIngressGRPCHostPortEnvVar] = DEFAULT_CHIP_INGRESS_GRPC_PORT
131-
envVars[ChipIngressGRPCPortEnvVar] = DEFAULT_CHIP_INGRESS_GRPC_PORT
132-
133128
for _, env := range os.Environ() {
134129
pair := strings.SplitN(env, "=", 2)
135130
if len(pair) == 2 {
136131
envVars[pair[0]] = pair[1]
137132
}
138133
}
139134

135+
if _, ok := envVars[ChipIngressImageEnvVar]; !ok {
136+
return nil, fmt.Errorf("%s env var is not set", ChipIngressImageEnvVar)
137+
}
138+
139+
if _, ok := envVars[ChipConfigImageEnvVar]; !ok {
140+
return nil, fmt.Errorf("%s env var is not set", ChipConfigImageEnvVar)
141+
}
142+
140143
upErr := stack.
141144
WithEnv(envVars).
142145
Up(ctx)

framework/components/dockercompose/chip_ingress_set/docker-compose.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33

44
chip-ingress:
55
# added image (instead of build) to use image created by a setup script
6-
image: ${CHIP_INGRESS_IMAGE:-chip-ingress:local-cre}
6+
image: "${CHIP_INGRESS_IMAGE}"
77
container_name: chip-ingress
88
depends_on:
99
- redpanda-0
@@ -12,7 +12,7 @@ services:
1212
command: ["write-service"]
1313
environment:
1414
SERVER_HOST: "0.0.0.0"
15-
SERVER_GRPC_PORT: "${CHIP_INGRESS_GRPC_PORT:-}"
15+
SERVER_GRPC_PORT: "${CHIP_INGRESS_GRPC_PORT:-50051}"
1616
SERVER_METRICS_PORT: "9090"
1717
SERVER_HEALTHCHECKS_PORT: "9091"
1818
SERVER_METRICS_IMPLEMENTATION: "otel"
@@ -22,7 +22,7 @@ services:
2222
KAFKA_BROKERS: "redpanda-0:9092"
2323
SCHEMA_REGISTRY_URL: "http://redpanda-0:8081"
2424
# this has been modified and default values were removed, somehow we cannot override them in testcontainers-go
25-
BASIC_AUTH_ENABLED: ${BASIC_AUTH_ENABLED:-}
25+
BASIC_AUTH_ENABLED: ${BASIC_AUTH_ENABLED:-false}
2626
BASIC_AUTH_PREFIX: ${BASIC_AUTH_PREFIX:-}
2727
CE_SA_BEHOLDER_DEMO_CLIENT: |
2828
{"username": "beholder-demo-client", "password": "password", "allowed_domains": ["*"]}
@@ -38,7 +38,7 @@ services:
3838
CHIP_CONFIG_HOST: ${CHIP_CONFIG_HOST:-chip-config}
3939
CHIP_CONFIG_PORT: ${CHIP_CONFIG_PORT:-50051}
4040
ports:
41-
- "${CHIP_INGRESS_GRPC_HOST_PORT:-}:${CHIP_INGRESS_GRPC_PORT:-}"
41+
- "${CHIP_INGRESS_GRPC_HOST_PORT:-50051}:${CHIP_INGRESS_GRPC_PORT:-50051}"
4242
- "9090:9090"
4343
- "9092:9091"
4444
healthcheck:
@@ -49,7 +49,7 @@ services:
4949
retries: 10
5050

5151
chip-config:
52-
image: ${CHIP_CONFIG_IMAGE:-chip-config:local-cre}
52+
image: "${CHIP_CONFIG_IMAGE}"
5353
container_name: chip-config
5454
hostname: chip-config
5555
command:
@@ -71,6 +71,7 @@ services:
7171
depends_on:
7272
postgres:
7373
condition: service_healthy
74+
restart: on-failure
7475

7576
postgres:
7677
image: postgres:16-alpine

framework/examples/chip_ingress/smoke_chip_ingress_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chip_ingress_test
22

33
import (
44
"context"
5+
"os"
56
"testing"
67
"time"
78

@@ -19,6 +20,8 @@ type ChipConfig struct {
1920
func TestChipIngressSmoke(t *testing.T) {
2021
in, err := framework.Load[ChipConfig](t)
2122
require.NoError(t, err, "failed to load config")
23+
require.NotEmpty(t, os.Getenv("CHIP_CONFIG_IMAGE"), "CHIP_CONFIG_IMAGE env var is not set")
24+
require.NotEmpty(t, os.Getenv("CHIP_INGRESS_IMAGE"), "CHIP_INGRESS_IMAGE env var is not set")
2225

2326
out, err := chipingressset.NewWithContext(t.Context(), in.ChipIngress)
2427
require.NoError(t, err, "failed to create chip ingress set")

0 commit comments

Comments
 (0)