Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: test ipv6 connectivity for bridge network #23740

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions e2e/networking/inputs/docker_bridged_ipv6.nomad.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

job "bridge-ipv6" {
group "g" {
network {
mode = "bridge"
port "http" {
to = 8000
static = 8000
}

}
service {
name = "a-web"
port = "http"
provider = "nomad"
address_mode = "alloc"
}
task "t" {
template {
data = <<EOH
#!/usr/bin/env bash

apt update
apt install curl -y
EOH
destination = "local/bridge_ipv6.sh"
}
template {
data = "hellooo-thereee:P"
destination = "local/index.html"
}

driver = "docker"
config {
image = "python:slim"
command = "python3"
args = ["-m", "http.server", "--directory=local", "--bind=::"]
ports = ["http"]
}
}
}
}
24 changes: 24 additions & 0 deletions e2e/networking/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,27 @@ func (tc *NetworkingE2ETest) TestNetworking_DockerBridgedCNIEnvVars(f *framework
f.Contains(envOutput, "NOMAD_ALLOC_PORT_dummy", "namespace port env var not found")
f.Contains(envOutput, "NOMAD_ALLOC_ADDR_dummy", "namespace addr env var not found")
}

func (tc *NetworkingE2ETest) TestNetworking_DockerBridgedDefaultIPv6(f *framework.F) {

jobID := "test-networking-" + uuid.Generate()[0:8]
f.NoError(e2eutil.Register(jobID, "networking/inputs/docker_bridged_ipv6.nomad.hcl"))
tc.jobIDs = append(tc.jobIDs, jobID)
f.NoError(e2eutil.WaitForAllocStatusExpected(jobID, "default", []string{"running"}),
"job should be running with 1 alloc")

// Grab the allocations for the job.
allocs, _, err := tc.Nomad().Jobs().Allocations(jobID, false, nil)
f.NoError(err, "failed to get allocs for job")
f.Len(allocs, 1, "job should have one alloc")

// check that within bridge network we can curl IPv6 address
_, err = e2eutil.AllocExec(allocs[0].ID, "t", "chmod +x /local/bridge_ipv6.sh", "default", nil)
f.NoError(err, "failed to run chmod exec command")
_, err = e2eutil.AllocExec(allocs[0].ID, "t", "./local/bridge_ipv6.sh", "default", nil)
f.NoError(err, "failed to run script exec command")
curlOutput, err := e2eutil.AllocExec(allocs[0].ID, "t", "curl -s [::]:8000", "default", nil)
f.NoError(err, "failed to run curl IPv6 exec command")
f.Equal("hellooo-thereee:P", strings.TrimSpace(curlOutput), "incorrect IPv6 response")

}
Loading