hubcio commented on code in PR #3384:
URL: https://github.com/apache/iggy/pull/3384#discussion_r3333589715
##########
bdd/docker-compose.yml:
##########
@@ -222,74 +58,59 @@ services:
- iggy-bdd-network
go-bdd:
+ image: iggy-bdd-go
build:
context: ..
dockerfile: bdd/go/Dockerfile
- depends_on:
- iggy-server:
- condition: service_healthy
- iggy-leader:
- condition: service_healthy
- iggy-follower:
- condition: service_healthy
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- - IGGY_TCP_ADDRESS=iggy-server:8090
- - GO_TEST_EXTRA_FLAGS=${GO_TEST_EXTRA_FLAGS:-}
- volumes:
- -
./scenarios/basic_messaging.feature:/app/features/basic_messaging.feature
- command: [ "sh", "-c", "go test -v ${GO_TEST_EXTRA_FLAGS} ./..." ]
+ - BDD_FEATURE=${BDD_FEATURE:-all}
+ command: [ "sh", "-c", "go test -v ./..." ]
networks:
- iggy-bdd-network
node-bdd:
+ image: iggy-bdd-node
build:
context: ..
dockerfile: bdd/node/Dockerfile
- depends_on:
- iggy-server:
- condition: service_healthy
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- - IGGY_TCP_ADDRESS=iggy-server:8090
command: [ "npm", "run", "test:bdd" ]
networks:
- iggy-bdd-network
csharp-bdd:
+ image: iggy-bdd-csharp
build:
context: ..
dockerfile: bdd/csharp/Dockerfile
- depends_on:
- iggy-server:
- condition: service_healthy
- iggy-leader:
- condition: service_healthy
- iggy-follower:
- condition: service_healthy
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- - IGGY_TCP_ADDRESS=iggy-server:8090
- - IGGY_TCP_ADDRESS_LEADER=iggy-leader:8091
- - IGGY_TCP_ADDRESS_FOLLOWER=iggy-follower:8092
- command: [ "dotnet", "test" ]
+ - BDD_FEATURE=${BDD_FEATURE:-all}
+ command:
+ - sh
+ - -c
+ - |
+ case "$BDD_FEATURE" in
+ basic_messaging) dotnet test --filter "Category=basic-messaging"
;;
Review Comment:
also line 100, and the same pattern in `docker-compose.coverage.yml`.
the C# project runs under microsoft testing platform
(`foreign/csharp/global.json` sets the runner to `Microsoft.Testing.Platform`,
csproj uses `xunit.v3.mtp-v2`), and MTP does not accept the VSTest-style
`--filter`. ran it locally: `dotnet test --filter "Category=basic-messaging"`
prints `Unknown option '--filter'`, runs zero tests and exits 5. so
`run-bdd-tests.sh csharp basic_messaging` (and `csharp leader_redirection`)
hard-fail instead of running the selected feature.
CI doesn't hit this because it always calls the script with no feature ->
`all` -> the `*)` branch runs bare `dotnet test`. only the explicit
single-feature paths this PR adds are broken.
the xunit v3 / MTP equivalent is `--filter-trait`. confirmed `dotnet test
--filter-trait "Category=basic-messaging"` discovers the scenario. so use
`dotnet test --filter-trait "Category=basic-messaging"` and `dotnet test
--filter-trait "Category=requires-leader-awareness"`.
##########
bdd/docker-compose.coverage.yml:
##########
@@ -70,15 +73,15 @@ services:
volumes:
- ../reports:/reports
command:
- - dotnet
- - test
- - --coverage
- - --coverage-output-format
- - cobertura
- - --coverage-output
- - csharp-bdd-coverage.cobertura.xml
- - --results-directory
- - /reports
+ - sh
+ - -c
+ - |
+ FILTER=""
+ case "$BDD_FEATURE" in
+ basic_messaging) FILTER='--filter Category=basic-messaging' ;;
Review Comment:
same `--filter` problem as in `docker-compose.yml` - MTP rejects VSTest
`--filter` with `Unknown option '--filter'` and runs zero tests. switch these
to `--filter-trait Category=...` and update the `$$FILTER` value used on line
84 to match.
##########
bdd/go/tests/suite_test.go:
##########
@@ -18,27 +18,40 @@
package tests
import (
+ "os"
"testing"
"github.com/cucumber/godog"
)
func TestFeatures(t *testing.T) {
- suites := []godog.TestSuite{{
- ScenarioInitializer: initBasicMessagingScenario,
- Options: &godog.Options{
- Format: "pretty",
- Paths:
[]string{"../../scenarios/basic_messaging.feature"},
- TestingT: t,
- },
- }, {
- ScenarioInitializer: initLeaderRedirectionScenario,
- Options: &godog.Options{
- Format: "pretty",
- Paths:
[]string{"../../scenarios/leader_redirection.feature"},
- TestingT: t,
- },
- }}
+ feature := os.Getenv("BDD_FEATURE")
+ if feature == "" {
+ feature = "all"
+ }
+
+ var suites []godog.TestSuite
Review Comment:
if `BDD_FEATURE` is set to anything other than basic_messaging /
leader_redirection / all / empty, `suites` stays empty, the loop below runs
zero iterations, and `go test` exits 0 - a green run that tested nothing. the
script validates the value upstream so the normal flow is safe, but a typo'd
`BDD_FEATURE` passed straight to the container (or a direct `go test`) silently
passes. rust and C# both fall through to "run all" on an unknown value; go is
the odd one out. cheap fix: `if len(suites) == 0 { t.Fatalf("unknown
BDD_FEATURE=%q", feature) }`.
##########
bdd/docker-compose.yml:
##########
@@ -16,204 +16,40 @@
# under the License.
services:
- # Original single server for backward compatibility
- iggy-server:
- platform: linux/amd64
- build:
- context: ..
- dockerfile: core/server/Dockerfile
- target: runtime-prebuilt
- args:
- PREBUILT_IGGY_SERVER: ${IGGY_SERVER_PATH:-target/debug/iggy-server}
- PREBUILT_IGGY_CLI: ${IGGY_CLI_PATH:-target/debug/iggy}
- LIBC: glibc
- PROFILE: debug
- command: [ "--fresh", "--with-default-root-credentials" ]
- cap_add:
- - SYS_NICE
- security_opt:
- - seccomp:unconfined
- ulimits:
- memlock:
- soft: -1
- hard: -1
- healthcheck:
- test: [ "CMD", "/usr/local/bin/iggy", "--tcp-server-address",
"127.0.0.1:8090", "ping" ]
- interval: 20s
- timeout: 3s
- retries: 30
- start_period: 2s
- environment:
- - RUST_LOG=info
- - IGGY_SYSTEM_PATH=local_data
- - IGGY_TCP_ADDRESS=0.0.0.0:8090
- - IGGY_HTTP_ADDRESS=0.0.0.0:3000
- - IGGY_QUIC_ADDRESS=0.0.0.0:8080
- - IGGY_WEBSOCKET_ADDRESS=0.0.0.0:8070
- volumes:
- - iggy_data:/app/local_data
- networks:
- - iggy-bdd-network
-
- # Leader server for cluster testing
- iggy-leader:
- platform: linux/amd64
- build:
- context: ..
- dockerfile: core/server/Dockerfile
- target: runtime-prebuilt
- args:
- PREBUILT_IGGY_SERVER: ${IGGY_SERVER_PATH:-target/debug/iggy-server}
- PREBUILT_IGGY_CLI: ${IGGY_CLI_PATH:-target/debug/iggy}
- LIBC: glibc
- PROFILE: debug
- # Leader runs without --follower flag; --replica-id selects this node's
- # entry (replica_id=0) from the shared cluster.nodes roster below.
- command: [ "--fresh", "--with-default-root-credentials", "--replica-id",
"0" ]
- cap_add:
- - SYS_NICE
- security_opt:
- - seccomp:unconfined
- ulimits:
- memlock:
- soft: -1
- hard: -1
- healthcheck:
- test: [ "CMD", "/usr/local/bin/iggy", "--tcp-server-address",
"127.0.0.1:8091", "ping" ]
- interval: 20s
- timeout: 3s
- retries: 30
- start_period: 2s
- environment:
- - RUST_LOG=info
- - IGGY_SYSTEM_PATH=local_data_leader
- # Server bind addresses for this container.
- - IGGY_TCP_ADDRESS=0.0.0.0:8091
- - IGGY_HTTP_ADDRESS=0.0.0.0:3001
- - IGGY_QUIC_ADDRESS=0.0.0.0:8081
- - IGGY_WEBSOCKET_ADDRESS=0.0.0.0:8071
- # Cluster configuration. The block below is byte-identical on the
- # follower container; the only runtime difference is --replica-id,
- # passed via the command above.
- - IGGY_CLUSTER_ENABLED=true
- - IGGY_CLUSTER_NAME=test-cluster
- - IGGY_CLUSTER_NODES_0_NAME=leader-node
- - IGGY_CLUSTER_NODES_0_IP=iggy-leader
- - IGGY_CLUSTER_NODES_0_REPLICA_ID=0
- - IGGY_CLUSTER_NODES_0_PORTS_TCP=8091
- - IGGY_CLUSTER_NODES_0_PORTS_QUIC=8081
- - IGGY_CLUSTER_NODES_0_PORTS_HTTP=3001
- - IGGY_CLUSTER_NODES_0_PORTS_WEBSOCKET=8071
- - IGGY_CLUSTER_NODES_1_NAME=follower-node
- - IGGY_CLUSTER_NODES_1_IP=iggy-follower
- - IGGY_CLUSTER_NODES_1_REPLICA_ID=1
- - IGGY_CLUSTER_NODES_1_PORTS_TCP=8092
- - IGGY_CLUSTER_NODES_1_PORTS_QUIC=8082
- - IGGY_CLUSTER_NODES_1_PORTS_HTTP=3002
- - IGGY_CLUSTER_NODES_1_PORTS_WEBSOCKET=8072
- volumes:
- - iggy_leader_data:/app/local_data_leader
- networks:
- - iggy-bdd-network
-
- # Follower server for cluster testing
- iggy-follower:
- platform: linux/amd64
- build:
- context: ..
- dockerfile: core/server/Dockerfile
- target: runtime-prebuilt
- args:
- PREBUILT_IGGY_SERVER: ${IGGY_SERVER_PATH:-target/debug/iggy-server}
- PREBUILT_IGGY_CLI: ${IGGY_CLI_PATH:-target/debug/iggy}
- LIBC: glibc
- PROFILE: debug
- # Follower runs with --follower flag; --replica-id selects this node's
- # entry (replica_id=1) from the shared cluster.nodes roster below.
- command: [ "--fresh", "--with-default-root-credentials", "--follower",
"--replica-id", "1" ]
- cap_add:
- - SYS_NICE
- security_opt:
- - seccomp:unconfined
- ulimits:
- memlock:
- soft: -1
- hard: -1
- healthcheck:
- test: [ "CMD", "/usr/local/bin/iggy", "--tcp-server-address",
"127.0.0.1:8092", "ping" ]
- interval: 20s
- timeout: 3s
- retries: 30
- start_period: 2s
- environment:
- - RUST_LOG=info
- - IGGY_SYSTEM_PATH=local_data_follower
- # Server bind addresses for this container.
- - IGGY_TCP_ADDRESS=0.0.0.0:8092
- - IGGY_HTTP_ADDRESS=0.0.0.0:3002
- - IGGY_QUIC_ADDRESS=0.0.0.0:8082
- - IGGY_WEBSOCKET_ADDRESS=0.0.0.0:8072
- # Cluster configuration. The block below is byte-identical on the
- # leader container; the only runtime difference is --replica-id,
- # passed via the command above.
- - IGGY_CLUSTER_ENABLED=true
- - IGGY_CLUSTER_NAME=test-cluster
- - IGGY_CLUSTER_NODES_0_NAME=leader-node
- - IGGY_CLUSTER_NODES_0_IP=iggy-leader
- - IGGY_CLUSTER_NODES_0_REPLICA_ID=0
- - IGGY_CLUSTER_NODES_0_PORTS_TCP=8091
- - IGGY_CLUSTER_NODES_0_PORTS_QUIC=8081
- - IGGY_CLUSTER_NODES_0_PORTS_HTTP=3001
- - IGGY_CLUSTER_NODES_0_PORTS_WEBSOCKET=8071
- - IGGY_CLUSTER_NODES_1_NAME=follower-node
- - IGGY_CLUSTER_NODES_1_IP=iggy-follower
- - IGGY_CLUSTER_NODES_1_REPLICA_ID=1
- - IGGY_CLUSTER_NODES_1_PORTS_TCP=8092
- - IGGY_CLUSTER_NODES_1_PORTS_QUIC=8082
- - IGGY_CLUSTER_NODES_1_PORTS_HTTP=3002
- - IGGY_CLUSTER_NODES_1_PORTS_WEBSOCKET=8072
- volumes:
- - iggy_follower_data:/app/local_data_follower
- networks:
- - iggy-bdd-network
-
rust-bdd:
+ image: iggy-bdd-rust
build:
context: ..
dockerfile: bdd/rust/Dockerfile
- depends_on:
- iggy-server:
- condition: service_healthy
- iggy-leader:
- condition: service_healthy
- iggy-follower:
- condition: service_healthy
environment:
- IGGY_ROOT_USERNAME=iggy
- IGGY_ROOT_PASSWORD=iggy
- - IGGY_TCP_ADDRESS=iggy-server:8090
- # Additional addresses for leader redirection tests
- - IGGY_TCP_ADDRESS_LEADER=iggy-leader:8091
- - IGGY_TCP_ADDRESS_FOLLOWER=iggy-follower:8092
+ - BDD_FEATURE=${BDD_FEATURE:-all}
- RUST_LOG=debug
- RUSTFLAGS=-C linker=gcc
volumes:
-
./scenarios/basic_messaging.feature:/app/features/basic_messaging.feature
-
./scenarios/leader_redirection.feature:/app/features/leader_redirection.feature
- command: [ "cargo", "test", "-p", "bdd", "--features", "bdd" ]
+ command:
+ - sh
+ - -c
+ - |
+ case "$BDD_FEATURE" in
Review Comment:
also line 98 here, and lines 34 / 80 in `docker-compose.coverage.yml`.
single `$` means docker compose interpolates `$BDD_FEATURE` from the host
env at config-parse time, not from the container env at runtime. it works
because `run-bdd-tests.sh` exports the var, but it's inconsistent with the
`$$FILTER` you correctly escaped in coverage.yml, and a bare `docker compose
up` without the host var renders `case ""` plus a "variable is not set"
warning. use `$$BDD_FEATURE` so the container reads its own env (which already
has the `:-all` default). go-bdd already does the right thing by reading the
env in go code, so only the rust/csharp shell `case` blocks need this.
##########
scripts/run-bdd-tests.sh:
##########
@@ -56,42 +85,47 @@ fi
run_suite(){
local svc="$1" emoji="$2" label="$3"
- log "${emoji} ${label}โฆ"
- set +e
- "${COMPOSE_CMD[@]}" up --build --abort-on-container-exit --exit-code-from
"$svc" "$svc"
- local code=$?
- set -e
- "${COMPOSE_CMD[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
+ if [ "$FEATURE" = "leader_redirection" ]; then
+ case "$svc" in
+ rust-bdd|go-bdd|csharp-bdd) ;;
+ *) log " skipping ${svc} (does not support ${FEATURE})"; return 0 ;;
Review Comment:
for an explicitly named unsupported SDK, e.g. `run-bdd-tests.sh python
leader_redirection`, this skips and returns 0, then the script prints "โ
BDD
tests completed ... feature=leader_redirection" and exits 0 - a green no-op for
something the user explicitly asked for. fine for the `all` fan-out, but for a
single named SDK it'd be clearer to warn louder or exit non-zero. low priority
since CI never passes a feature here.
##########
scripts/run-bdd-tests.sh:
##########
@@ -56,42 +85,47 @@ fi
run_suite(){
local svc="$1" emoji="$2" label="$3"
- log "${emoji} ${label}โฆ"
- set +e
- "${COMPOSE_CMD[@]}" up --build --abort-on-container-exit --exit-code-from
"$svc" "$svc"
- local code=$?
- set -e
- "${COMPOSE_CMD[@]}" down -v --remove-orphans >/dev/null 2>&1 || true
+ if [ "$FEATURE" = "leader_redirection" ]; then
+ case "$svc" in
+ rust-bdd|go-bdd|csharp-bdd) ;;
+ *) log " skipping ${svc} (does not support ${FEATURE})"; return 0 ;;
+ esac
+ fi
+
+ log "${emoji} ${label}..."
+ local code=0
+ docker compose "${COMPOSE_FILES[@]}" \
+ up --build --abort-on-container-exit --exit-code-from "$svc" "$svc" \
+ || code=$?
+ docker compose "${COMPOSE_FILES[@]}" \
+ down -v --remove-orphans >/dev/null 2>&1 || true
return "$code"
}
case "$SDK" in
rust) run_suite rust-bdd "๐ฆ" "Running Rust BDD tests" ;;
python) run_suite python-bdd "๐" "Running Python BDD tests" ;;
go) run_suite go-bdd "๐น" "Running Go BDD tests" ;;
- go-race)
- export GO_TEST_EXTRA_FLAGS="-race"
- run_suite go-bdd "๐นโก" "Running Go BDD tests with data race detector"
- ;;
node) run_suite node-bdd "๐ข๐" "Running Node BDD tests" ;;
csharp) run_suite csharp-bdd "๐ท" "Running C# BDD tests" ;;
java) run_suite java-bdd "โ" "Running Java BDD tests" ;;
all)
run_suite rust-bdd "๐ฆ" "Running Rust BDD tests"
|| exit $?
run_suite python-bdd "๐" "Running Python BDD tests"
|| exit $?
run_suite go-bdd "๐น" "Running Go BDD tests"
|| exit $?
- GO_TEST_EXTRA_FLAGS="-race" \
- run_suite go-bdd "๐นโก" "Running Go BDD tests with data race detector"
|| exit $?
run_suite node-bdd "๐ข๐" "Running Node BDD tests"
|| exit $?
run_suite csharp-bdd "๐ท" "Running C# BDD tests"
|| exit $?
run_suite java-bdd "โ" "Running Java BDD tests"
|| exit $?
;;
clean)
- cleanup; exit 0 ;;
+ log "๐งน cleaning up all BDD containers & volumes..."
+ docker compose -f docker-compose.yml -f docker-compose.server.yml -f
docker-compose.cluster.yml -f docker-compose.coverage.yml \
Review Comment:
this hardcodes the full set of four compose files, while the EXIT trap above
uses `${COMPOSE_FILES[@]}` (base+server+cluster for a plain invocation). two
independent encodings of "all the compose files" that can drift apart later.
minor - could hoist the full list into one array reused by both.
##########
bdd/docker-compose.server.yml:
##########
@@ -0,0 +1,105 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Single Iggy server for basic_messaging tests.
Review Comment:
this single server also backs leader_redirection, not just basic_messaging -
`leader_redirection.feature` has a "single server on port 8090" scenario that
resolves to `IGGY_TCP_ADDRESS` / iggy-server:8090, which only this file
supplies. worth saying so here (and in the README line) so nobody later drops
this file from the leader_redirection path and breaks that scenario.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]