Merge pull request #108986 from gnufied/use-temp-dir-shutdown-tests

Use tempdir for shutdown tests
This commit is contained in:
Kubernetes Prow Robot 2022-03-25 05:17:51 -07:00 committed by GitHub
commit e7845861a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ package nodeshutdown
import (
"bytes"
"fmt"
"os"
"strings"
"sync"
"testing"
@ -251,6 +252,7 @@ func TestManager(t *testing.T) {
ShutdownGracePeriodRequested: tc.shutdownGracePeriodRequested,
ShutdownGracePeriodCriticalPods: tc.shutdownGracePeriodCriticalPods,
Clock: testingclock.NewFakeClock(time.Now()),
StateDirectory: os.TempDir(),
})
err := manager.Start()
@ -345,8 +347,8 @@ func TestFeatureEnabled(t *testing.T) {
SyncNodeStatusFunc: func() {},
ShutdownGracePeriodRequested: tc.shutdownGracePeriodRequested,
ShutdownGracePeriodCriticalPods: 0,
StateDirectory: os.TempDir(),
})
assert.Equal(t, tc.expectEnabled, manager != managerStub{})
})
}
@ -399,6 +401,7 @@ func TestRestart(t *testing.T) {
SyncNodeStatusFunc: syncNodeStatus,
ShutdownGracePeriodRequested: shutdownGracePeriodRequested,
ShutdownGracePeriodCriticalPods: shutdownGracePeriodCriticalPods,
StateDirectory: os.TempDir(),
})
err := manager.Start()