Skip to content

Commit

Permalink
fix: TestRotateLog (#1246)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan committed Aug 15, 2022
1 parent e2b68f4 commit 356b220
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/ingress/ingress_test.go
Expand Up @@ -170,6 +170,8 @@ func TestRotateLog(t *testing.T) {
cmd.SetArgs([]string{
"--log-rotate-output-path", "./testlog/test.log",
"--log-rotate-max-size", "1",
"--log-level", "debug",
"--log-output", "./testlog/test.log",
"--http-listen", listen,
"--enable-profiling",
"--kubeconfig", "/foo/bar/baz",
Expand All @@ -185,14 +187,20 @@ func TestRotateLog(t *testing.T) {
close(stopCh)
}()

fws := &fakeWriteSyncer{}
logger, err := log.NewLogger(log.WithLogLevel("debug"), log.WithWriteSyncer(fws))
assert.Nil(t, err)
defer logger.Close()
log.DefaultLogger = logger

// fill logs with data until the size > 1m
line := ""
for i := 0; i < 256; i++ {
line += "0"
}

for i := 0; i < 4096; i++ {
log.Info(line)
log.Debug(line)
}

time.Sleep(5 * time.Second)
Expand All @@ -206,5 +214,4 @@ func TestRotateLog(t *testing.T) {
}

assert.Equal(t, true, len(files) >= 2)

}

0 comments on commit 356b220

Please sign in to comment.