Skip to content

Commit

Permalink
Remove Helm install from kubedns suite
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomcej authored May 22, 2020
1 parent 32aa143 commit 3f9529d
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 97 deletions.
10 changes: 10 additions & 0 deletions integration/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ func (s *HelmSuite) TestACLEnabled(c *check.C) {
s.waitForMaeshControllerStarted(c)
s.waitForMaeshProxyStarted(c)
}

func (s *HelmSuite) TestKubeDNSEnabled(c *check.C) {
err := s.installHelmMaesh(c, false, true)
c.Assert(err, checker.IsNil)

defer s.unInstallHelmMaesh(c)

s.waitForMaeshControllerStarted(c)
s.waitForMaeshProxyStarted(c)
}
31 changes: 23 additions & 8 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func (s *BaseSuite) startAndWaitForKubeDNS(c *check.C) {
c.Assert(s.try.WaitReadyDeployment("kube-dns", metav1.NamespaceSystem, 60*time.Second), checker.IsNil)
}

func (s *BaseSuite) WaitForKubeDNS(c *check.C) {
c.Assert(s.try.WaitReadyDeployment("kube-dns", metav1.NamespaceSystem, 60*time.Second), checker.IsNil)
}

func (s *BaseSuite) waitForMaeshControllerStarted(c *check.C) {
c.Assert(s.try.WaitReadyDeployment("maesh-controller", maeshNamespace, 30*time.Second), checker.IsNil)
}
Expand All @@ -319,10 +323,6 @@ func (s *BaseSuite) waitForTools(c *check.C) {
c.Assert(s.try.WaitReadyDeployment("tiny-tools", testNamespace, 30*time.Second), checker.IsNil)
}

func (s *BaseSuite) waitKubectlExecCommand(c *check.C, argSlice []string, data string) {
c.Assert(s.try.WaitCommandExecute("kubectl", argSlice, data, 10*time.Second), checker.IsNil)
}

func (s *BaseSuite) waitKubectlExecCommandReturn(_ *check.C, argSlice []string) (string, error) {
return s.try.WaitCommandExecuteReturn("kubectl", argSlice, 10*time.Second)
}
Expand Down Expand Up @@ -519,10 +519,25 @@ func (s *BaseSuite) digHost(c *check.C, source, namespace, destination string) {
"exec", "-i", source, "-n", namespace, "--", "dig", destination, "+short",
}

output, err := s.waitKubectlExecCommandReturn(c, argSlice)
c.Assert(err, checker.IsNil)
c.Log(fmt.Sprintf("Dig %s: %s", destination, strings.TrimSpace(output)))
IP := net.ParseIP(strings.TrimSpace(output))
var IP net.IP

ebo := backoff.NewExponentialBackOff()
ebo.MaxElapsedTime = 60 * time.Second

_ = backoff.Retry(safe.OperationWithRecover(func() error {
output, err := s.waitKubectlExecCommandReturn(c, argSlice)
if err != nil {
return err
}
c.Log(fmt.Sprintf("Dig %s: %s", destination, strings.TrimSpace(output)))
IP = net.ParseIP(strings.TrimSpace(output))
if IP == nil {
return fmt.Errorf("could not parse an IP from dig")
}

return nil
}), ebo)

c.Assert(IP, checker.NotNil)
}

Expand Down
33 changes: 19 additions & 14 deletions integration/kubedns_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"time"

"github.com/go-check/check"
checker "github.com/vdemeester/shakers"
)
Expand All @@ -19,30 +21,33 @@ func (s *KubeDNSSuite) SetUpSuite(c *check.C) {
}
s.startk3s(c, requiredImages)
s.startAndWaitForKubeDNS(c)

// Wait for our created coreDNS deployment in the maesh namespace.
c.Assert(s.try.WaitReadyDeployment("coredns", maeshNamespace, 60*time.Second), checker.IsNil)

s.startWhoami(c)
s.installTinyToolsMaesh(c)
s.createResources(c, "testdata/state-table/")
s.createResources(c, "testdata/smi/crds/")
}

func (s *KubeDNSSuite) TearDownSuite(c *check.C) {
s.stopK3s()
}

func (s *KubeDNSSuite) TestKubeDNS(c *check.C) {
pod := s.getToolsPodMaesh(c)
c.Assert(pod, checker.NotNil)
func (s *KubeDNSSuite) TestKubeDNSDig(c *check.C) {
s.WaitForKubeDNS(c)

argSlice := []string{
"exec", "-it", pod.Name, "-n", pod.Namespace, "-c", pod.Spec.Containers[0].Name, "--", "curl", "whoami.whoami.svc.cluster.local", "--max-time", "5",
}
cmd := s.startMaeshBinaryCmd(c, false, false)
err := cmd.Start()

err := s.installHelmMaesh(c, false, true)
c.Assert(err, checker.IsNil)
s.waitForMaeshControllerStarted(c)
s.waitKubectlExecCommand(c, argSlice, "whoami")
defer s.stopMaeshBinary(c, cmd.Process)

argSlice = []string{
"exec", "-it", pod.Name, "-n", pod.Namespace, "-c", pod.Spec.Containers[0].Name, "--", "curl", "whoami.whoami.maesh", "--max-time", "5",
}
s.waitKubectlExecCommand(c, argSlice, "whoami")
s.unInstallHelmMaesh(c)
pod := s.getToolsPodMaesh(c)
c.Assert(pod, checker.NotNil)

// We need to wait for kubeDNS again, as the pods will be restarted by prepare.
s.WaitForKubeDNS(c)
s.digHost(c, pod.Name, pod.Namespace, "whoami.whoami.maesh")
}
28 changes: 0 additions & 28 deletions integration/testdata/build/Dockerfile

This file was deleted.

46 changes: 0 additions & 46 deletions integration/testdata/build/entrypoint.sh

This file was deleted.

Loading

0 comments on commit 3f9529d

Please sign in to comment.