Skip to content

Commit 789cce1

Browse files
author
Juan-Luis de Sousa-Valadas Castaño
authored
Merge pull request #7561 from juanluisvaladas/enable-conformance-tests
Improve network conformance tests flakyness
2 parents ce3ebc8 + 7b5c202 commit 789cce1

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

inttest/network-conformance/network_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package network
55

66
import (
7+
"context"
78
"fmt"
89
"io"
910
"os"
@@ -12,7 +13,11 @@ import (
1213
"time"
1314

1415
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
16+
"github.com/k0sproject/k0s/pkg/kubernetes/watch"
17+
"k8s.io/client-go/kubernetes"
1518

19+
appsv1 "k8s.io/api/apps/v1"
20+
corev1 "k8s.io/api/core/v1"
1621
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1722

1823
sc "github.com/vmware-tanzu/sonobuoy/pkg/client"
@@ -86,6 +91,9 @@ func (s *networkSuite) TestK0sGetsUp() {
8691
s.T().Log("waiting to see CNI pods ready for", daemonSetName)
8792
s.NoErrorf(common.WaitForDaemonSet(s.Context(), kc, daemonSetName, metav1.NamespaceSystem), "%s did not start", daemonSetName)
8893

94+
s.T().Log("waiting for CoreDNS to be ready")
95+
s.Require().NoError(waitForCoreDNS(s.Context(), kc), "While waiting for CoreDNS to become ready")
96+
8997
s.T().Log("waiting for konnectivity-agent to be ready")
9098
s.NoErrorf(common.WaitForDaemonSet(s.Context(), kc, "konnectivity-agent", metav1.NamespaceSystem), "konnectivity-agent did not start")
9199

@@ -97,6 +105,13 @@ func (s *networkSuite) TestK0sGetsUp() {
97105
client, err := sc.NewSonobuoyClient(restConfig, skc)
98106
s.Require().NoError(err)
99107

108+
e2eExtraArgs := ""
109+
110+
// kube-router's ipv6 tests are flaky, so we skip some
111+
if s.cni == "kuberouter" && s.isIPv6Only {
112+
e2eExtraArgs = "--ginkgo.flake-attempts=2"
113+
}
114+
100115
deadline, _ := s.Context().Deadline()
101116
err = client.Run(&sc.RunConfig{
102117
GenConfig: sc.GenConfig{
@@ -114,6 +129,7 @@ func (s *networkSuite) TestK0sGetsUp() {
114129
"E2E_SKIP": "\\[Serial\\]|(Services\\ should.*session\\ affinity\\ .*for\\ service\\ with\\ type\\ clusterIP)",
115130
"E2E_PARALLEL": "y",
116131
"E2E_USE_GO_RUNNER": "true",
132+
"E2E_EXTRA_ARGS": e2eExtraArgs,
117133
},
118134
},
119135
KubeVersion: semver.Canonical(k8sVersion.String()),
@@ -163,6 +179,24 @@ func retrieveResults(r io.Reader, ec <-chan error) error {
163179
return eg.Wait()
164180
}
165181

182+
func waitForCoreDNS(ctx context.Context, kc kubernetes.Interface) error {
183+
return watch.Deployments(kc.AppsV1().Deployments(metav1.NamespaceSystem)).
184+
WithObjectName("coredns").
185+
Until(ctx, func(deployment *appsv1.Deployment) (bool, error) {
186+
for _, c := range deployment.Status.Conditions {
187+
if c.Type == appsv1.DeploymentAvailable {
188+
if c.Status == corev1.ConditionTrue && deployment.Status.ReadyReplicas >= 2 {
189+
return true, nil
190+
}
191+
192+
break
193+
}
194+
}
195+
196+
return false, nil
197+
})
198+
}
199+
166200
func TestNetworkSuite(t *testing.T) {
167201
s := networkSuite{
168202
common.BootlooseSuite{
@@ -188,6 +222,12 @@ func TestNetworkSuite(t *testing.T) {
188222
s.K0sExtraImageBundleMountPoints = []string{"/var/lib/k0s/images/ipv6.tar"}
189223
}
190224

225+
// With less than 4 replicas the kube-router ipv6 tests are flaky due to
226+
// coredns and konnectivity timeouts.
227+
if s.isIPv6Only && s.cni == "kuberouter" {
228+
s.WorkerCount = 4
229+
}
230+
191231
t.Logf("Testing %s using %s", s.cni, s.proxyMode)
192232
suite.Run(t, &s)
193233
}

0 commit comments

Comments
 (0)