Skip to content

Commit 3923484

Browse files
committed
add complex node test
1 parent e390e2d commit 3923484

File tree

9 files changed

+286
-91
lines changed

9 files changed

+286
-91
lines changed

docker-compose.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,33 @@ services:
4646
environment:
4747
- TARGET_HOST=redis
4848
- TARGET_PORT=6379
49-
- LISTEN_PORT=7000,7001,7002 # Multiple proxy nodes for cluster simulation
49+
- LISTEN_PORT=17000,17001,17002,17003 # 4 proxy nodes: initially show 3, swap in 4th during SMIGRATED
5050
- LISTEN_HOST=0.0.0.0
5151
- API_PORT=3000
5252
- DEFAULT_INTERCEPTORS=cluster,hitless
5353
ports:
54-
- "7000:7000" # Proxy node 1 (host:container)
55-
- "7001:7001" # Proxy node 2 (host:container)
56-
- "7002:7002" # Proxy node 3 (host:container)
57-
- "8100:3000" # HTTP API port (host:container)
54+
- "17000:17000" # Proxy node 1 (host:container)
55+
- "17001:17001" # Proxy node 2 (host:container)
56+
- "17002:17002" # Proxy node 3 (host:container)
57+
- "17003:17003" # Proxy node 4 (host:container) - hidden initially, swapped in during SMIGRATED
58+
- "18100:3000" # HTTP API port (host:container)
5859
depends_on:
5960
- redis
6061
profiles:
6162
- e2e
6263
- all
6364

6465
proxy-fault-injector:
65-
image: golang:1.23-alpine
66+
build:
67+
context: .
68+
dockerfile: maintnotifications/e2e/cmd/proxy-fi-server/Dockerfile
6669
container_name: proxy-fault-injector
67-
working_dir: /app
68-
environment:
69-
- CGO_ENABLED=0
70-
command: >
71-
sh -c "go run ./maintnotifications/e2e/cmd/proxy-fi-server/main.go --listen 0.0.0.0:5000 --proxy-api-url http://cae-resp-proxy:3000"
7270
ports:
73-
- "5000:5000" # Fault injector API port
71+
- "15000:5000" # Fault injector API port (host:container)
7472
depends_on:
7573
- cae-resp-proxy
76-
volumes:
77-
- ".:/app"
74+
environment:
75+
- PROXY_API_URL=http://cae-resp-proxy:3000
7876
profiles:
7977
- e2e
8078
- all

maintnotifications/e2e/cmd/proxy-fi-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ EXPOSE 5000
3939

4040
# Run the server
4141
ENTRYPOINT ["/app/proxy-fi-server"]
42-
CMD ["--listen", "0.0.0.0:5000", "--proxy-api-port", "3000"]
42+
CMD ["--listen", "0.0.0.0:5000", "--proxy-api-url", "http://cae-resp-proxy:3000"]
4343

maintnotifications/e2e/cmd/proxy-fi-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func main() {
1414
listenAddr := flag.String("listen", "0.0.0.0:5000", "Address to listen on for fault injector API")
15-
proxyAPIURL := flag.String("proxy-api-url", "http://localhost:8100", "URL of the cae-resp-proxy API")
15+
proxyAPIURL := flag.String("proxy-api-url", "http://localhost:18100", "URL of the cae-resp-proxy API (updated to avoid macOS Control Center conflict)")
1616
flag.Parse()
1717

1818
fmt.Printf("Starting Proxy Fault Injector Server...\n")

maintnotifications/e2e/config_autostart_logic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestFaultInjectorClientCreation(t *testing.T) {
153153
name string
154154
url string
155155
}{
156-
{"localhost", "http://localhost:5000"},
156+
{"localhost", "http://localhost:15000"}, // Updated to avoid macOS Control Center conflict
157157
{"with port", "http://test:9999"},
158158
{"with trailing slash", "http://test:9999/"},
159159
}

maintnotifications/e2e/config_parser_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func CreateTestFaultInjector() (*FaultInjectorClient, error) {
561561
//
562562
// Decision logic based on environment:
563563
// 1. If REDIS_ENDPOINTS_CONFIG_PATH is set -> use real fault injector from FAULT_INJECTION_API_URL
564-
// 2. If REDIS_ENDPOINTS_CONFIG_PATH is NOT set -> use Docker fault injector at http://localhost:5000
564+
// 2. If REDIS_ENDPOINTS_CONFIG_PATH is NOT set -> use Docker fault injector at http://localhost:15000
565565
//
566566
// Both the Docker proxy and fault injector should already be running (started via Docker Compose)
567567
// This function does NOT start any services - it only connects to existing ones
@@ -578,9 +578,9 @@ func CreateTestFaultInjectorWithCleanup() (*FaultInjectorClient, func(), error)
578578
// If environment config fails, use Docker fault injector
579579
// Note: GetEnvConfig() only fails if REDIS_ENDPOINTS_CONFIG_PATH is not set
580580
if err != nil {
581-
// Use Docker fault injector at http://localhost:5000
581+
// Use Docker fault injector at http://localhost:15000 (updated to avoid macOS Control Center conflict)
582582
// The fault injector should already be running via docker-compose
583-
faultInjectorURL := "http://localhost:5000"
583+
faultInjectorURL := "http://localhost:15000"
584584

585585
// Check if fault injector is accessible
586586
client := &http.Client{Timeout: 2 * time.Second}
@@ -1012,7 +1012,7 @@ func SetupTestDatabaseWithConfig(t *testing.T, ctx context.Context, dbConfig Dat
10121012
// SetupTestDatabaseAndFactory creates a database from environment config and returns both bdbID, factory, test mode config, and cleanup function
10131013
// This is the recommended way to setup tests as it ensures the client factory connects to the newly created database
10141014
//
1015-
// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (localhost:7000) instead of creating a new database.
1015+
// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (127.0.0.1:17000) instead of creating a new database.
10161016
// This allows tests to work with either the real fault injector OR the Docker proxy setup.
10171017
//
10181018
// Usage:
@@ -1024,12 +1024,12 @@ func SetupTestDatabaseAndFactory(t *testing.T, ctx context.Context, databaseName
10241024
envConfig, err := GetEnvConfig()
10251025
if err != nil {
10261026
// No environment config - use Docker proxy setup
1027-
t.Logf("No environment config found, using Docker proxy setup at localhost:7000")
1027+
t.Logf("No environment config found, using Docker proxy setup at 127.0.0.1:17000")
10281028

10291029
// Create a simple Redis connection config for Docker proxy
10301030
redisConfig := &RedisConnectionConfig{
1031-
Host: "localhost",
1032-
Port: 7000,
1031+
Host: "127.0.0.1", // Use 127.0.0.1 to force IPv4
1032+
Port: 17000,
10331033
Username: "",
10341034
Password: "",
10351035
TLS: false,
@@ -1126,7 +1126,7 @@ func SetupTestDatabaseAndFactory(t *testing.T, ctx context.Context, databaseName
11261126

11271127
// SetupTestDatabaseAndFactoryWithConfig creates a database with custom config and returns both bdbID, factory, test mode config, and cleanup function
11281128
//
1129-
// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (localhost:7000) instead of creating a new database.
1129+
// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (127.0.0.1:17000) instead of creating a new database.
11301130
// This allows tests to work with either the real fault injector OR the Docker proxy setup.
11311131
//
11321132
// Usage:
@@ -1138,12 +1138,12 @@ func SetupTestDatabaseAndFactoryWithConfig(t *testing.T, ctx context.Context, da
11381138
envConfig, err := GetEnvConfig()
11391139
if err != nil {
11401140
// No environment config - use Docker proxy setup
1141-
t.Logf("No environment config found, using Docker proxy setup at localhost:7000")
1141+
t.Logf("No environment config found, using Docker proxy setup at 127.0.0.1:17000")
11421142

11431143
// Create a simple Redis connection config for Docker proxy
11441144
redisConfig := &RedisConnectionConfig{
1145-
Host: "localhost",
1146-
Port: 7000,
1145+
Host: "127.0.0.1", // Use 127.0.0.1 to force IPv4
1146+
Port: 17000,
11471147
Username: "",
11481148
Password: "",
11491149
TLS: false,

0 commit comments

Comments
 (0)