mirror of https://github.com/linkerd/linkerd2.git
Add integration tests for single-namespace mode (#2247)
Add integration tests for single-namespace mode Fixes #2127 Signed-off-by: Alejandro Pedraza <alejandro.pedraza@gmail.com>
This commit is contained in:
parent
0c50749990
commit
0c4039a671
|
@ -58,6 +58,7 @@ exit_code=0
|
|||
|
||||
run_test "$test_directory/install_test.go" || exit_code=$?
|
||||
run_test "$test_directory/install_test.go" "-enable-tls" || exit_code=$?
|
||||
run_test "$test_directory/install_test.go" "-single-namespace" || exit_code=$?
|
||||
for test in $(find "$test_directory" -mindepth 2 -name '*_test.go'); do
|
||||
run_test "$test" || exit_code=$?
|
||||
done
|
||||
|
|
|
@ -54,12 +54,22 @@ func TestVersionPreInstall(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckPreInstall(t *testing.T) {
|
||||
out, _, err := TestHelper.LinkerdRun("check", "--pre", "--expected-version", TestHelper.GetVersion())
|
||||
cmd := []string{"check", "--pre", "--expected-version", TestHelper.GetVersion()}
|
||||
golden := "check.pre.golden"
|
||||
if TestHelper.SingleNamespace() {
|
||||
cmd = append(cmd, "--single-namespace")
|
||||
golden = "check.pre.single_namespace.golden"
|
||||
err := TestHelper.CreateNamespaceIfNotExists(TestHelper.GetLinkerdNamespace())
|
||||
if err != nil {
|
||||
t.Fatalf("Namespace creation failed\n%s", err.Error())
|
||||
}
|
||||
}
|
||||
out, _, err := TestHelper.LinkerdRun(cmd...)
|
||||
if err != nil {
|
||||
t.Fatalf("Check command failed\n%s", out)
|
||||
}
|
||||
|
||||
err = TestHelper.ValidateOutput(out, "check.pre.golden")
|
||||
err = TestHelper.ValidateOutput(out, golden)
|
||||
if err != nil {
|
||||
t.Fatalf("Received unexpected output\n%s", err.Error())
|
||||
}
|
||||
|
@ -75,6 +85,9 @@ func TestInstall(t *testing.T) {
|
|||
cmd = append(cmd, []string{"--tls", "optional"}...)
|
||||
linkerdDeployReplicas["linkerd-ca"] = 1
|
||||
}
|
||||
if TestHelper.SingleNamespace() {
|
||||
cmd = append(cmd, "--single-namespace")
|
||||
}
|
||||
|
||||
out, _, err := TestHelper.LinkerdRun(cmd...)
|
||||
if err != nil {
|
||||
|
@ -118,18 +131,19 @@ func TestVersionPostInstall(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckPostInstall(t *testing.T) {
|
||||
out, _, err := TestHelper.LinkerdRun(
|
||||
"check",
|
||||
"--expected-version",
|
||||
TestHelper.GetVersion(),
|
||||
"--wait=0",
|
||||
)
|
||||
cmd := []string{"check", "--expected-version", TestHelper.GetVersion(), "--wait=0"}
|
||||
golden := "check.golden"
|
||||
if TestHelper.SingleNamespace() {
|
||||
cmd = append(cmd, "--single-namespace")
|
||||
golden = "check.single_namespace.golden"
|
||||
}
|
||||
out, _, err := TestHelper.LinkerdRun(cmd...)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Check command failed\n%s", out)
|
||||
}
|
||||
|
||||
err = TestHelper.ValidateOutput(out, "check.golden")
|
||||
err = TestHelper.ValidateOutput(out, golden)
|
||||
if err != nil {
|
||||
t.Fatalf("Received unexpected output\n%s", err.Error())
|
||||
}
|
||||
|
@ -215,21 +229,19 @@ func TestInject(t *testing.T) {
|
|||
|
||||
func TestCheckProxy(t *testing.T) {
|
||||
prefixedNs := TestHelper.GetTestNamespace("smoke-test")
|
||||
out, _, err := TestHelper.LinkerdRun(
|
||||
"check",
|
||||
"--proxy",
|
||||
"--expected-version",
|
||||
TestHelper.GetVersion(),
|
||||
"--namespace",
|
||||
prefixedNs,
|
||||
"--wait=0",
|
||||
)
|
||||
cmd := []string{"check", "--proxy", "--expected-version", TestHelper.GetVersion(), "--namespace", prefixedNs, "--wait=0"}
|
||||
golden := "check.proxy.golden"
|
||||
if TestHelper.SingleNamespace() {
|
||||
cmd = append(cmd, "--single-namespace")
|
||||
golden = "check.proxy.single_namespace.golden"
|
||||
}
|
||||
out, _, err := TestHelper.LinkerdRun(cmd...)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Check command failed\n%s", out)
|
||||
}
|
||||
|
||||
err = TestHelper.ValidateOutput(out, "check.proxy.golden")
|
||||
err = TestHelper.ValidateOutput(out, golden)
|
||||
if err != nil {
|
||||
t.Fatalf("Received unexpected output\n%s", err.Error())
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
kubernetes-api
|
||||
--------------
|
||||
√ can initialize the client
|
||||
√ can query the Kubernetes API
|
||||
|
||||
kubernetes-version
|
||||
------------------
|
||||
√ is running the minimum Kubernetes API version
|
||||
|
||||
pre-kubernetes-single-namespace-setup
|
||||
-------------------------------------
|
||||
√ control plane namespace exists
|
||||
√ can create Roles
|
||||
√ can create RoleBindings
|
||||
|
||||
pre-kubernetes-setup
|
||||
--------------------
|
||||
√ can create ServiceAccounts
|
||||
√ can create Services
|
||||
√ can create Deployments
|
||||
√ can create ConfigMaps
|
||||
|
||||
linkerd-version
|
||||
---------------
|
||||
√ can determine the latest version
|
||||
√ cli is up-to-date
|
||||
|
||||
Status check results are √
|
|
@ -0,0 +1,37 @@
|
|||
kubernetes-api
|
||||
--------------
|
||||
√ can initialize the client
|
||||
√ can query the Kubernetes API
|
||||
|
||||
kubernetes-version
|
||||
------------------
|
||||
√ is running the minimum Kubernetes API version
|
||||
|
||||
linkerd-existence
|
||||
-----------------
|
||||
√ control plane namespace exists
|
||||
√ controller pod is running
|
||||
√ can initialize the client
|
||||
√ can query the control plane API
|
||||
|
||||
linkerd-api
|
||||
-----------
|
||||
√ control plane pods are ready
|
||||
√ can query the control plane API
|
||||
√ [kubernetes] control plane can talk to Kubernetes
|
||||
√ [prometheus] control plane can talk to Prometheus
|
||||
|
||||
linkerd-version
|
||||
---------------
|
||||
√ can determine the latest version
|
||||
√ cli is up-to-date
|
||||
|
||||
linkerd-data-plane
|
||||
------------------
|
||||
√ data plane namespace exists
|
||||
√ data plane proxies are ready
|
||||
√ data plane proxy metrics are present in Prometheus
|
||||
√ data plane is up-to-date
|
||||
√ data plane and cli versions match
|
||||
|
||||
Status check results are √
|
|
@ -0,0 +1,34 @@
|
|||
kubernetes-api
|
||||
--------------
|
||||
√ can initialize the client
|
||||
√ can query the Kubernetes API
|
||||
|
||||
kubernetes-version
|
||||
------------------
|
||||
√ is running the minimum Kubernetes API version
|
||||
|
||||
linkerd-existence
|
||||
-----------------
|
||||
√ control plane namespace exists
|
||||
√ controller pod is running
|
||||
√ can initialize the client
|
||||
√ can query the control plane API
|
||||
|
||||
linkerd-api
|
||||
-----------
|
||||
√ control plane pods are ready
|
||||
√ can query the control plane API
|
||||
√ [kubernetes] control plane can talk to Kubernetes
|
||||
√ [prometheus] control plane can talk to Prometheus
|
||||
|
||||
linkerd-version
|
||||
---------------
|
||||
√ can determine the latest version
|
||||
√ cli is up-to-date
|
||||
|
||||
control-plane-version
|
||||
---------------------
|
||||
√ control plane is up-to-date
|
||||
√ control plane and cli versions match
|
||||
|
||||
Status check results are √
|
|
@ -17,11 +17,12 @@ import (
|
|||
|
||||
// TestHelper provides helpers for running the linkerd integration tests.
|
||||
type TestHelper struct {
|
||||
linkerd string
|
||||
version string
|
||||
namespace string
|
||||
tls bool
|
||||
httpClient http.Client
|
||||
linkerd string
|
||||
version string
|
||||
namespace string
|
||||
singleNamespace bool
|
||||
tls bool
|
||||
httpClient http.Client
|
||||
KubernetesHelper
|
||||
}
|
||||
|
||||
|
@ -35,6 +36,7 @@ func NewTestHelper() *TestHelper {
|
|||
|
||||
linkerd := flag.String("linkerd", "", "path to the linkerd binary to test")
|
||||
namespace := flag.String("linkerd-namespace", "l5d-integration", "the namespace where linkerd is installed")
|
||||
singleNamespace := flag.Bool("single-namespace", false, "configure the control plane to only operate in the installed namespace")
|
||||
tls := flag.Bool("enable-tls", false, "enable TLS in tests")
|
||||
runTests := flag.Bool("integration-tests", false, "must be provided to run the integration tests")
|
||||
verbose := flag.Bool("verbose", false, "turn on debug logging")
|
||||
|
@ -67,11 +69,15 @@ func NewTestHelper() *TestHelper {
|
|||
if *tls {
|
||||
ns += "-tls"
|
||||
}
|
||||
if *singleNamespace {
|
||||
ns += "-single-namespace"
|
||||
}
|
||||
|
||||
testHelper := &TestHelper{
|
||||
linkerd: *linkerd,
|
||||
namespace: ns,
|
||||
tls: *tls,
|
||||
linkerd: *linkerd,
|
||||
namespace: ns,
|
||||
singleNamespace: *singleNamespace,
|
||||
tls: *tls,
|
||||
}
|
||||
|
||||
version, _, err := testHelper.LinkerdRun("version", "--client", "--short")
|
||||
|
@ -109,6 +115,9 @@ func (h *TestHelper) GetLinkerdNamespace() string {
|
|||
// GetTestNamespace returns the namespace for the given test. The test namespace
|
||||
// is prefixed with the linkerd namespace.
|
||||
func (h *TestHelper) GetTestNamespace(testName string) string {
|
||||
if h.SingleNamespace() {
|
||||
return h.namespace
|
||||
}
|
||||
return h.namespace + "-" + testName
|
||||
}
|
||||
|
||||
|
@ -117,6 +126,11 @@ func (h *TestHelper) TLS() bool {
|
|||
return h.tls
|
||||
}
|
||||
|
||||
// SingleNamespace returns whether --single-namespace is enabled for the given test or not.
|
||||
func (h *TestHelper) SingleNamespace() bool {
|
||||
return h.singleNamespace
|
||||
}
|
||||
|
||||
// CombinedOutput executes a shell command and returns the output.
|
||||
func (h *TestHelper) CombinedOutput(name string, arg ...string) (string, string, error) {
|
||||
command := exec.Command(name, arg...)
|
||||
|
|
Loading…
Reference in New Issue