Skip to content

Commit

Permalink
Log instance control
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Loskutnikov <anatoly.loskutnikov@gmail.com>
  • Loading branch information
Tiberivs committed Mar 22, 2021
1 parent 0835469 commit 473518c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions extensions/logs/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
configPrefix = "LOG"
)

var instanceExists = false
var initConfig sync.Once
var config Config

Expand All @@ -58,6 +59,7 @@ type Suite struct {

kubeClient kubernetes.Interface

firstInstance bool
testStartTime time.Time
nsmContainers map[types.UID]bool
logQueue chan logItem
Expand All @@ -82,6 +84,12 @@ func (s *Suite) SetupSuite() {
}
})

if instanceExists {
return
}

instanceExists = true
s.firstInstance = true
var err error

s.kubeClient, err = newKubeClient()
Expand All @@ -100,11 +108,20 @@ func (s *Suite) SetupSuite() {
}

func (s *Suite) TearDownSuite() {
if !s.firstInstance {
return
}

instanceExists = false
close(s.logQueue)
s.waitGroup.Wait()
}

func (s *Suite) SetupTest() {
if !s.firstInstance {
return
}

s.testStartTime = time.Now()
s.nsmContainers = make(map[types.UID]bool)

Expand All @@ -124,6 +141,10 @@ func (s *Suite) SetupTest() {
}

func (s *Suite) AfterTest(suiteName, testName string) {
if !s.firstInstance {
return
}

logDir := filepath.Join(config.ArtifactsDir, suiteName, testName)
require.NoError(s.T(), os.MkdirAll(logDir, os.ModePerm))

Expand Down

0 comments on commit 473518c

Please sign in to comment.