diff --git a/basic_suite_test.go b/basic_suite_test.go index 73ca5a8cc..cc3d5aa84 100644 --- a/basic_suite_test.go +++ b/basic_suite_test.go @@ -53,7 +53,7 @@ func (s *BasicTestsSuite) TearDownSuite() { } func (s *BasicTestsSuite) TearDownTest() { - k8s.ShowLogs(s.options...) + k8s.ShowLogs("default", s.options...) s.Require().NoError(exechelper.Run("kubectl delete serviceaccounts --all")) s.Require().NoError(exechelper.Run("kubectl delete services --all")) diff --git a/k8s/k8s.go b/k8s/k8s.go index c033e5c40..b4ffdd608 100644 --- a/k8s/k8s.go +++ b/k8s/k8s.go @@ -75,12 +75,17 @@ func ApplyDeployment(path string, mutators ...func(deployment *apiv1.Deployment) for _, m := range mutators { m(&d) } + + if d.Namespace == "" { + d.Namespace = namespace + } + _, err = client.AppsV1().Deployments(d.Namespace).Create(&d) return err } // ShowLogs prints logs into console all containers of pods -func ShowLogs(options ...*exechelper.Option) { +func ShowLogs(namespace string, options ...*exechelper.Option) { client, err := Client() if err != nil { diff --git a/test/excluded_prefixes_collector_test.go b/test/excluded_prefixes_collector_test.go index 2b72b8709..1c1db7484 100644 --- a/test/excluded_prefixes_collector_test.go +++ b/test/excluded_prefixes_collector_test.go @@ -74,8 +74,8 @@ func (et *ExcludedPrefixesSuite) SetupSuite() { et.Require().NoError(exechelper.Run("kubectl apply -f ../deployments/prefixes-collector/collector-account.yaml", et.options...)) et.Require().NoError(exechelper.Run("kubectl apply -f ../deployments/prefixes-collector/collector-cluster-role.yaml", et.options...)) - et.Require().NoError(k8s.ApplyDeployment("../deployments/alpine.yaml", func(collector *v1.Deployment) { - collector.Namespace = collectorNamespace + et.Require().NoError(k8s.ApplyDeployment("../deployments/alpine.yaml", func(alpine *v1.Deployment) { + alpine.Namespace = collectorNamespace })) et.waitForPodStart(collectorNamespace, "alpine") @@ -87,7 +87,7 @@ func (et *ExcludedPrefixesSuite) SetupSuite() { } func (et *ExcludedPrefixesSuite) TearDownTest() { - k8s.ShowLogs(et.options...) + k8s.ShowLogs(collectorNamespace, et.options...) et.Require().NoError(exechelper.Run("kubectl delete daemonset -n excluded-prefixes-collector excluded-prefixes-collector")) et.Require().NoError(exechelper.Run("kubectl delete pods -n excluded-prefixes-collector -l app=excluded-prefixes-collector --now")) @@ -96,7 +96,7 @@ func (et *ExcludedPrefixesSuite) TearDownTest() { func (et *ExcludedPrefixesSuite) TearDownSuite() { et.Require().NoError(exechelper.Run("kubectl delete -f ../deployments/prefixes-collector/collector-cluster-role.yaml", et.options...)) - et.Require().NoError(exechelper.Run("kubectl delete -f ../deployments/prefixes-collector/collector-namespace.yaml", et.options...)) + et.Require().NoError(exechelper.Run("kubectl delete -f ../deployments/prefixes-collector/collector-namespace.yaml --now", et.options...)) } func (et *ExcludedPrefixesSuite) TestWithKubeAdmConfigPrefixes() { @@ -150,7 +150,7 @@ func (et *ExcludedPrefixesSuite) TestWithUserConfigPrefixes() { et.Eventually(et.checkPrefixes(kubeAdmPrefixes), time.Second*5, time.Second) } -func (et *ExcludedPrefixesSuite) TestWithEnvPrefixes() { +func (et *ExcludedPrefixesSuite) TestWithCorrectEnvPrefixes() { envPrefixes := []string{ "127.0.0.0/8", "134.65.0.0/16",