-
-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for disabled agent injector.
Signed-off-by: Thomas Hallgren <[email protected]>
- Loading branch information
Showing
2 changed files
with
61 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,59 @@ | ||
package integration_test | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
|
||
"github.com/telepresenceio/telepresence/v2/integration_test/itest" | ||
) | ||
|
||
type interceptDisabledSuite struct { | ||
type agentInjectorDisabledSuite struct { | ||
itest.Suite | ||
itest.NamespacePair | ||
logName string | ||
} | ||
|
||
func (s *interceptDisabledSuite) SuiteName() string { | ||
return "InterceptDisabled" | ||
func (s *agentInjectorDisabledSuite) SuiteName() string { | ||
return "AgentInjectorDisabled" | ||
} | ||
|
||
func init() { | ||
itest.AddNamespacePairSuite("", func(h itest.NamespacePair) itest.TestingSuite { | ||
return &interceptDisabledSuite{Suite: itest.Suite{Harness: h}, NamespacePair: h} | ||
return &agentInjectorDisabledSuite{Suite: itest.Suite{Harness: h}, NamespacePair: h} | ||
}) | ||
} | ||
|
||
func (s *interceptDisabledSuite) Test_AgentInjectorDisabled() { | ||
func (s *agentInjectorDisabledSuite) SetupSuite() { | ||
s.Suite.SetupSuite() | ||
s.logName = s.TelepresenceHelmInstallOK(s.Context(), false, "--set", "agentInjector.enabled=false") | ||
} | ||
|
||
func (s *agentInjectorDisabledSuite) TearDownSuite() { | ||
s.UninstallTrafficManager(s.Context(), s.ManagerNamespace()) | ||
} | ||
|
||
func (s *agentInjectorDisabledSuite) Test_AgentInjectorDisabled() { | ||
const svc = "echo-easy" | ||
ctx := s.Context() | ||
tmLogName := func() string { | ||
tmLogName := s.TelepresenceHelmInstallOK(ctx, false, "--set", "agentInjector.enabled=false") | ||
defer s.UninstallTrafficManager(ctx, s.ManagerNamespace()) | ||
|
||
s.TelepresenceConnect(ctx) | ||
defer itest.TelepresenceQuitOk(ctx) | ||
return tmLogName | ||
}() | ||
s.ApplyApp(ctx, svc, "deploy/"+svc) | ||
defer s.DeleteSvcAndWorkload(ctx, "deploy", svc) | ||
|
||
tmLogFile, err := os.Open(tmLogName) | ||
s.TelepresenceConnect(ctx) | ||
_, sErr, err := itest.Telepresence(ctx, "intercept", svc) | ||
s.Error(err) | ||
s.Contains(sErr, "agent-injector is disabled") | ||
itest.TelepresenceQuitOk(ctx) | ||
|
||
logData, err := os.ReadFile(s.logName) | ||
s.Require().NoError(err) | ||
defer tmLogFile.Close() | ||
|
||
sc := bufio.NewScanner(tmLogFile) | ||
t := s.T() | ||
for sc.Scan() { | ||
t.Log(sc.Text()) | ||
} | ||
logs := string(logData) | ||
s.NotContains(logs, "Using traffic-agent image") | ||
s.Contains(logs, "Cluster domain derived from /etc/resolv.conf") | ||
} | ||
|
||
func (s *agentInjectorDisabledSuite) Test_ManualAgent() { | ||
s.TelepresenceConnect(s.Context()) | ||
defer itest.TelepresenceQuitOk(s.Context()) | ||
testManualAgent(&s.Suite, s.NamespacePair) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters