chengxilo opened a new issue, #3883:
URL: https://github.com/apache/iggy/issues/3883
## Summary
Every BDD step-definition file resolves the server address and root
credentials with an "env var or hardcoded default" helper. If the env variable
is absent, misspelled, or dropped from a compose overlay, the suite does not
fail. Instead, it quietly connects to the default value. Test should be loud
when it is broken, we don't need safety or robust here; a fallback turns a
configuration bug into either a misleading connection error or, worse, a green
run against the wrong server.
The fallbacks also disagree with each other across SDKs, so the *same*
missing variable produces eight different behaviours.
Examples:
https://github.com/apache/iggy/blob/2a8a5c96925f8b96a7e8718448079a63ce57980c/bdd/rust/tests/helpers/cluster.rs#L23-L35
https://github.com/apache/iggy/blob/2a8a5c96925f8b96a7e8718448079a63ce57980c/bdd/go/tests/basic_messaging.go#L53-L61
https://github.com/apache/iggy/blob/2a8a5c96925f8b96a7e8718448079a63ce57980c/foreign/php/tests/bootstrap.php#L87-L95
## Proposed Change
only use the enviroment varaible, if it's not available, just panic.
For example:
```rust
pub fn resolve_server_address(role: &str, port: u16) -> String {
match (role.to_lowercase().as_str(), port) {
("leader", 8091) => required_env("IGGY_TCP_ADDRESS_LEADER"),
("follower", 8092) => required_env("IGGY_TCP_ADDRESS_FOLLOWER"),
("single", 8090) | (_, 8090) => required_env("IGGY_TCP_ADDRESS"),
_ => panic!("no address mapping for role '{role}' on port {port}"),
}
}
fn required_env(name: &str) -> String {
match env::var(name) {
Ok(value) if !value.is_empty() => value,
_ => panic!("{name} must be set; run the suite via
scripts/run-bdd-tests.sh"),
}
}
```
--
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]