[ARVADOS] updated: 2.1.0-2461-gaabea703e

Git user git at public.arvados.org
Wed May 18 21:52:54 UTC 2022


Summary of changes:
 lib/crunchrun/executor_test.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

       via  aabea703ee77ca91da710dd9bce9716e5d35d7b2 (commit)
      from  c78c7272f9ab77297fbb4e521ab09fe9560754fe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit aabea703ee77ca91da710dd9bce9716e5d35d7b2
Author: Tom Clegg <tom at curii.com>
Date:   Wed May 18 17:51:54 2022 -0400

    19099: Ensure host/container port conflict in IPAddress test.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/crunchrun/executor_test.go b/lib/crunchrun/executor_test.go
index 308fb7bfc..393cfff09 100644
--- a/lib/crunchrun/executor_test.go
+++ b/lib/crunchrun/executor_test.go
@@ -177,7 +177,16 @@ func (s *executorSuite) TestExecStdoutStderr(c *C) {
 }
 
 func (s *executorSuite) TestIPAddress(c *C) {
-	s.spec.Command = []string{"nc", "-l", "-p", "1951", "-e", "printf", `HTTP/1.1 418 I'm a teapot\r\n\r\n`}
+	// Listen on an available port on the host.
+	ln, err := net.Listen("tcp", net.JoinHostPort("0.0.0.0", "0"))
+	c.Assert(err, IsNil)
+	defer ln.Close()
+	_, port, err := net.SplitHostPort(ln.Addr().String())
+	c.Assert(err, IsNil)
+
+	// Start a container that listens on the same port number that
+	// is already in use on the host.
+	s.spec.Command = []string{"nc", "-l", "-p", port, "-e", "printf", `HTTP/1.1 418 I'm a teapot\r\n\r\n`}
 	s.spec.EnableNetwork = true
 	c.Assert(s.executor.Create(s.spec), IsNil)
 	c.Assert(s.executor.Start(), IsNil)
@@ -193,9 +202,13 @@ func (s *executorSuite) TestIPAddress(c *C) {
 			break
 		}
 	}
+	// When we connect to the port using s.executor.IPAddress(),
+	// we should reach the nc process running inside the
+	// container, not the net.Listen() running outside the
+	// container, even though both listen on the same port.
 	ip, err := s.executor.IPAddress()
 	if c.Check(err, IsNil) && c.Check(ip, Not(Equals), "") {
-		req, err := http.NewRequest("BREW", "http://"+net.JoinHostPort(ip, "1951"), nil)
+		req, err := http.NewRequest("BREW", "http://"+net.JoinHostPort(ip, port), nil)
 		c.Assert(err, IsNil)
 		resp, err := http.DefaultClient.Do(req)
 		c.Assert(err, IsNil)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list