fix-external-etcd

This commit is contained in:
fabriziopandini
2019-03-28 23:25:18 +01:00
parent 7dfcacd1cf
commit f09d6388b2
4 changed files with 34 additions and 14 deletions

View File

@@ -186,9 +186,11 @@ func (pfct preflightCheckTest) Check() (warning, errorList []error) {
func TestRunInitNodeChecks(t *testing.T) {
var tests = []struct {
name string
cfg *kubeadmapi.InitConfiguration
expected bool
name string
cfg *kubeadmapi.InitConfiguration
expected bool
isSecondaryControlPlane bool
downloadCerts bool
}{
{name: "Test valid advertised address",
cfg: &kubeadmapi.InitConfiguration{
@@ -197,7 +199,7 @@ func TestRunInitNodeChecks(t *testing.T) {
expected: false,
},
{
name: "Test CA file exists if specfied",
name: "Test CA file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CAFile: "/foo"}},
@@ -206,7 +208,18 @@ func TestRunInitNodeChecks(t *testing.T) {
expected: false,
},
{
name: "Test Cert file exists if specfied",
name: "Skip test CA file exists if specified/download certs",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CAFile: "/foo"}},
},
},
expected: true,
isSecondaryControlPlane: true,
downloadCerts: true,
},
{
name: "Test Cert file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CertFile: "/foo"}},
@@ -215,7 +228,7 @@ func TestRunInitNodeChecks(t *testing.T) {
expected: false,
},
{
name: "Test Key file exists if specfied",
name: "Test Key file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CertFile: "/foo"}},
@@ -232,7 +245,7 @@ func TestRunInitNodeChecks(t *testing.T) {
}
for _, rt := range tests {
// TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString(), false)
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString(), rt.isSecondaryControlPlane, rt.downloadCerts)
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",