2021-09-14 10:08:12 +00:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
2021-11-02 18:37:16 +00:00
|
|
|
"os"
|
2021-09-14 10:08:12 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2022-03-15 17:29:56 +00:00
|
|
|
testutil "github.com/k3s-io/k3s/tests/integration"
|
2022-02-09 16:22:53 +00:00
|
|
|
. "github.com/onsi/ginkgo/v2"
|
2021-09-14 10:08:12 +00:00
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
2021-10-28 19:35:28 +00:00
|
|
|
var dualStackServer *testutil.K3sServer
|
|
|
|
var dualStackServerArgs = []string{
|
|
|
|
"--cluster-init",
|
|
|
|
"--cluster-cidr 10.42.0.0/16,2001:cafe:42:0::/56",
|
|
|
|
"--service-cidr 10.43.0.0/16,2001:cafe:42:1::/112",
|
|
|
|
"--disable-network-policy",
|
|
|
|
}
|
2022-02-25 16:42:21 +00:00
|
|
|
var testLock int
|
|
|
|
|
2021-09-14 10:08:12 +00:00
|
|
|
var _ = BeforeSuite(func() {
|
2021-11-08 23:27:44 +00:00
|
|
|
if !testutil.IsExistingServer() && os.Getenv("CI") != "true" {
|
2021-09-14 10:08:12 +00:00
|
|
|
var err error
|
2022-02-25 16:42:21 +00:00
|
|
|
testLock, err = testutil.K3sTestLock()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-10-28 19:35:28 +00:00
|
|
|
dualStackServer, err = testutil.K3sStartServer(dualStackServerArgs...)
|
2021-09-14 10:08:12 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-08-31 22:40:17 +00:00
|
|
|
var _ = Describe("dual stack", Ordered, func() {
|
2021-09-14 10:08:12 +00:00
|
|
|
BeforeEach(func() {
|
|
|
|
if testutil.IsExistingServer() && !testutil.ServerArgsPresent(dualStackServerArgs) {
|
|
|
|
Skip("Test needs k3s server with: " + strings.Join(dualStackServerArgs, " "))
|
2021-11-02 18:37:16 +00:00
|
|
|
} else if os.Getenv("CI") == "true" {
|
|
|
|
Skip("Github environment does not support IPv6")
|
2021-09-14 10:08:12 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
When("a ipv4 and ipv6 cidr is present", func() {
|
|
|
|
It("starts up with no problems", func() {
|
2022-06-13 20:32:13 +00:00
|
|
|
Eventually(func() error {
|
|
|
|
return testutil.K3sDefaultDeployments()
|
|
|
|
}, "180s", "10s").Should(Succeed())
|
2021-09-14 10:08:12 +00:00
|
|
|
})
|
|
|
|
It("creates pods with two IPs", func() {
|
2021-10-28 19:35:28 +00:00
|
|
|
podname, err := testutil.K3sCmd("kubectl", "get", "pods", "-n", "kube-system", "-o", "jsonpath={.items[?(@.metadata.labels.app\\.kubernetes\\.io/name==\"traefik\")].metadata.name}")
|
2021-09-14 10:08:12 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2021-10-28 19:35:28 +00:00
|
|
|
Eventually(func() (string, error) {
|
|
|
|
return testutil.K3sCmd("kubectl", "exec", podname, "-n", "kube-system", "--", "ip", "a")
|
|
|
|
}, "5s", "1s").Should(ContainSubstring("2001:cafe:42:"))
|
2021-09-14 10:08:12 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-01-12 21:43:31 +00:00
|
|
|
var failed bool
|
|
|
|
var _ = AfterEach(func() {
|
|
|
|
failed = failed || CurrentSpecReport().Failed()
|
|
|
|
})
|
|
|
|
|
2021-09-14 10:08:12 +00:00
|
|
|
var _ = AfterSuite(func() {
|
2021-11-08 23:27:44 +00:00
|
|
|
if !testutil.IsExistingServer() && os.Getenv("CI") != "true" {
|
2023-01-12 21:43:31 +00:00
|
|
|
if failed {
|
|
|
|
testutil.K3sSaveLog(dualStackServer, false)
|
2022-08-31 22:40:17 +00:00
|
|
|
}
|
2022-02-25 16:42:21 +00:00
|
|
|
Expect(testutil.K3sKillServer(dualStackServer)).To(Succeed())
|
|
|
|
Expect(testutil.K3sCleanup(testLock, "")).To(Succeed())
|
2021-09-14 10:08:12 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
func Test_IntegrationDualStack(t *testing.T) {
|
|
|
|
RegisterFailHandler(Fail)
|
2022-02-09 16:22:53 +00:00
|
|
|
RunSpecs(t, "Dual-Stack Suite")
|
2021-09-14 10:08:12 +00:00
|
|
|
}
|