Fix cluster bootstrap test

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 54bb65064e)
pull/5273/head
Brad Davidson 2022-02-24 10:55:13 -08:00 committed by Brad Davidson
parent a18c38d63d
commit 58fe28b500
1 changed files with 3 additions and 5 deletions

View File

@ -82,13 +82,13 @@ func Test_isDirEmpty(t *testing.T) {
func TestCluster_certDirsExist(t *testing.T) { func TestCluster_certDirsExist(t *testing.T) {
const testDataDir = "/tmp/k3s/" const testDataDir = "/tmp/k3s/"
testCredDir := filepath.Join(testDataDir, "server", "cred")
testTLSDir := filepath.Join(testDataDir, "server", "tls") testTLSDir := filepath.Join(testDataDir, "server", "tls")
testTLSEtcdDir := filepath.Join(testDataDir, "server", "tls", "etcd") testTLSEtcdDir := filepath.Join(testDataDir, "server", "tls", "etcd")
type fields struct { type fields struct {
clientAccessInfo *clientaccess.Info clientAccessInfo *clientaccess.Info
config *config.Control config *config.Control
runtime *config.ControlRuntime
managedDB managed.Driver managedDB managed.Driver
etcdConfig endpoint.ETCDConfig etcdConfig endpoint.ETCDConfig
shouldBootstrap bool shouldBootstrap bool
@ -110,8 +110,10 @@ func TestCluster_certDirsExist(t *testing.T) {
}, },
}, },
setup: func() error { setup: func() error {
os.MkdirAll(testCredDir, 0700)
os.MkdirAll(testTLSEtcdDir, 0700) os.MkdirAll(testTLSEtcdDir, 0700)
_, _ = os.Create(filepath.Join(testCredDir, "test_file"))
_, _ = os.Create(filepath.Join(testTLSDir, "test_file")) _, _ = os.Create(filepath.Join(testTLSDir, "test_file"))
_, _ = os.Create(filepath.Join(testTLSEtcdDir, "test_file")) _, _ = os.Create(filepath.Join(testTLSEtcdDir, "test_file"))
@ -128,7 +130,6 @@ func TestCluster_certDirsExist(t *testing.T) {
c := &Cluster{ c := &Cluster{
clientAccessInfo: tt.fields.clientAccessInfo, clientAccessInfo: tt.fields.clientAccessInfo,
config: tt.fields.config, config: tt.fields.config,
runtime: tt.fields.runtime,
managedDB: tt.fields.managedDB, managedDB: tt.fields.managedDB,
EtcdConfig: tt.fields.etcdConfig, EtcdConfig: tt.fields.etcdConfig,
storageStarted: tt.fields.storageStarted, storageStarted: tt.fields.storageStarted,
@ -150,7 +151,6 @@ func TestCluster_migrateBootstrapData(t *testing.T) {
type fields struct { type fields struct {
clientAccessInfo *clientaccess.Info clientAccessInfo *clientaccess.Info
config *config.Control config *config.Control
runtime *config.ControlRuntime
managedDB managed.Driver managedDB managed.Driver
etcdConfig endpoint.ETCDConfig etcdConfig endpoint.ETCDConfig
joining bool joining bool
@ -206,7 +206,6 @@ func TestCluster_Snapshot(t *testing.T) {
type fields struct { type fields struct {
clientAccessInfo *clientaccess.Info clientAccessInfo *clientaccess.Info
config *config.Control config *config.Control
runtime *config.ControlRuntime
managedDB managed.Driver managedDB managed.Driver
etcdConfig endpoint.ETCDConfig etcdConfig endpoint.ETCDConfig
joining bool joining bool
@ -238,7 +237,6 @@ func TestCluster_Snapshot(t *testing.T) {
c := &Cluster{ c := &Cluster{
clientAccessInfo: tt.fields.clientAccessInfo, clientAccessInfo: tt.fields.clientAccessInfo,
config: tt.fields.config, config: tt.fields.config,
runtime: tt.fields.runtime,
managedDB: tt.fields.managedDB, managedDB: tt.fields.managedDB,
EtcdConfig: tt.fields.etcdConfig, EtcdConfig: tt.fields.etcdConfig,
joining: tt.fields.joining, joining: tt.fields.joining,