diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 0b07ff72948..5bb346ff740 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -144,13 +144,17 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { e2elog.Logf("kube-apiserver version: %s", serverVersion.GitVersion) } - // Obtain the (primary if dual stack) ip family of the cluster - framework.TestContext.IPFamily = getClusterIPFamily(c) + // Obtain the default IP family of the cluster + // Some e2e test are designed to work on IPv4 only, this global variable + // allows to adapt those tests to work on both IPv4 and IPv6 + // TODO(dual-stack): dual stack clusters should pass full e2e testing at least with the primary IP family + // the dual stack clusters can be ipv4-ipv6 or ipv6-ipv4, order matters, + // and services use the primary IP family by default + // If we´ll need to provide additional context for dual-stack, we can detect it + // because pods have two addresses (one per family) + framework.TestContext.IPFamily = getDefaultClusterIPFamily(c) e2elog.Logf("Cluster IP family: %s", framework.TestContext.IPFamily) - // TODO(dual-stack): dual-stack clusters use two pods addresses (one per family) - // the cluster can be ipv4-ipv6 or ipv6-ipv4, order matters - // Reference common test to make the import valid. commontest.CurrentSuite = commontest.E2E @@ -285,13 +289,14 @@ func runKubernetesServiceTestContainer(c clientset.Interface, ns string) { } } -// getClusterIPFamily obtains the (primary) ip family of the cluster based -// on the Cluster IP address of the default kubernetes service -func getClusterIPFamily(c clientset.Interface) string { +// getDefaultClusterIPFamily obtains the default IP family of the cluster +// using the Cluster IP address of the kubernetes service created in the default namespace +// This unequivocally identifies the default IP family because services are single family +func getDefaultClusterIPFamily(c clientset.Interface) string { // Get the ClusterIP of the kubernetes service created in the default namespace svc, err := c.CoreV1().Services(metav1.NamespaceDefault).Get("kubernetes", metav1.GetOptions{}) if err != nil { - e2elog.Failf("Failed to get kubernetes endpoints: %v", err) + e2elog.Failf("Failed to get kubernetes service ClusterIP: %v", err) } if utilnet.IsIPv6String(svc.Spec.ClusterIP) { diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 90a9b800112..35ae85c9972 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -165,7 +165,7 @@ type TestContextType struct { // The configuration of NodeKiller. NodeKiller NodeKillerConfig - // The IP Family of the cluster + // The Default IP Family of the cluster ("ipv4" or "ipv6") IPFamily string }