kunaldevxxx commented on code in PR #4218:
URL: https://github.com/apache/iggy/pull/4218#discussion_r4045872959


##########
core/configs/src/server_config/validators.rs:
##########
@@ -534,6 +623,116 @@ mod tests {
         assert!(config.validate().is_ok());
     }
 
+    #[test]
+    fn given_loopback_bind_in_container_when_validating_should_warn_and_pass() 
{
+        let config = config_with_override(
+            "[tcp]\naddress = \"127.0.0.1:8090\"\n[cluster]\nenabled = 
false\n",
+        );
+        let warning = config
+            .validate_client_facing_address_in_env(true)
+            .expect("validation should pass");
+        assert!(
+            warning.is_some(),
+            "loopback inside container must produce a warning"
+        );
+        let message = warning.unwrap();
+        assert!(message.contains("IGGY_TCP_ADDRESS=0.0.0.0:8090"));
+        assert!(message.contains("together with 
IGGY_NODE_ADVERTISED_ADDRESS"));
+    }
+
+    #[test]
+    fn 
given_loopback_bind_outside_container_when_validating_should_pass_without_warning()
 {
+        let config = config_with_override(
+            "[tcp]\naddress = \"127.0.0.1:8090\"\n[cluster]\nenabled = 
false\n",
+        );
+        let warning = config
+            .validate_client_facing_address_in_env(false)
+            .expect("validation should pass");
+        assert!(
+            warning.is_none(),
+            "loopback outside container must not produce a warning"
+        );
+    }
+
+    #[test]
+    fn 
given_loopback_bind_in_container_with_advertised_address_when_validating_should_warn_and_pass()
+     {
+        let config = config_with_override(
+            "[tcp]\naddress = \"127.0.0.1:8090\"\n[cluster]\nenabled = false\n\
+             [node]\nadvertised_address = \"broker-1.example.com\"\n",
+        );
+        let warning = config
+            .validate_client_facing_address_in_env(true)
+            .expect("validation should pass");
+        assert!(
+            warning.is_some(),
+            "loopback inside container must produce a warning"
+        );
+        let message = warning.unwrap();
+        assert!(message.contains("IGGY_TCP_ADDRESS=0.0.0.0:8090"));
+        assert!(!message.contains("together with 
IGGY_NODE_ADVERTISED_ADDRESS"));
+    }
+
+    #[test]
+    fn given_dockerenv_file_when_checking_container_should_return_true() {

Review Comment:
   Added 
`given_cgroup_with_docker_marker_when_checking_container_should_return_true` 
with a real Docker cgroup entry (`0::/system.slice/docker-...scope`), as well 
as a negative test 
`given_host_cgroup_without_markers_when_checking_container_should_return_false`.



-- 
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]

Reply via email to