Skip to content

Commit

Permalink
Fix RuntimeConfigFileTestSuite cleanups
Browse files Browse the repository at this point in the history
On top of fixing the `AfterTest` method signature, a suite teardown has
been added for removing the /tmp/collector-test directory, this is not
strictly needed, but it's good practise to cleanup completely after all
tests.
  • Loading branch information
Molter73 committed Dec 10, 2024
1 parent a979ab4 commit e1d266a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions integration-tests/suites/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,16 @@ func (s *IntegrationTestSuiteBase) createDirectory(dir string) {
s.Require().NoError(err)
}

func (s *IntegrationTestSuiteBase) deleteDirectory(dir string) {
_, err := os.Stat(dir)
if os.IsNotExist(err) {
return
}

err = os.RemoveAll(dir)
s.Require().NoError(err)
}

func (s *IntegrationTestSuiteBase) deleteFile(file string) {
if _, err := os.Stat(file); os.IsNotExist(err) {
return
Expand Down
7 changes: 5 additions & 2 deletions integration-tests/suites/runtime_config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ func (s *RuntimeConfigFileTestSuite) SetupTest() {
}

s.createDirectory(runtimeConfigDir)
s.deleteFile(runtimeConfigFile)
s.StartCollector(false, &collectorOptions)
}

func (s *RuntimeConfigFileTestSuite) AfterTest() {
func (s *RuntimeConfigFileTestSuite) AfterTest(suiteName, testName string) {
s.StopCollector()
s.cleanupContainers("external-connection")
s.WritePerfResults()
s.deleteFile(runtimeConfigFile)
}

func (s *RuntimeConfigFileTestSuite) TearDownSuite() {
s.deleteDirectory(runtimeConfigDir)
}

func (s *RuntimeConfigFileTestSuite) TestRuntimeConfigFileEnable() {
// The runtime config file was deleted before starting collector.
// Default configuration is external IPs disabled.
Expand Down

0 comments on commit e1d266a

Please sign in to comment.