未验证 提交 44217360 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #10532 from medyagh/break_start_test

move audit test
...@@ -92,16 +92,14 @@ func TestErrorSpam(t *testing.T) { ...@@ -92,16 +92,14 @@ func TestErrorSpam(t *testing.T) {
t.Logf("minikube stderr:\n%s", stderr) t.Logf("minikube stderr:\n%s", stderr)
} }
t.Run("KubeadmSteps", func(t *testing.T) { steps := []string{
steps := []string{ "Generating certificates and keys ...",
"Generating certificates and keys ...", "Booting up control plane ...",
"Booting up control plane ...", "Configuring RBAC rules ...",
"Configuring RBAC rules ...", }
} for _, step := range steps {
for _, step := range steps { if !strings.Contains(stdout, step) {
if !strings.Contains(stdout, step) { t.Errorf("missing kubeadm init sub-step %q", step)
t.Errorf("missing kubeadm init sub-step %q", step)
}
} }
}) }
} }
...@@ -84,6 +84,7 @@ func TestFunctional(t *testing.T) { ...@@ -84,6 +84,7 @@ func TestFunctional(t *testing.T) {
}{ }{
{"CopySyncFile", setupFileSync}, // Set file for the file sync test case {"CopySyncFile", setupFileSync}, // Set file for the file sync test case
{"StartWithProxy", validateStartWithProxy}, // Set everything else up for success {"StartWithProxy", validateStartWithProxy}, // Set everything else up for success
{"AuditLog", validateAuditAfterStart}, // check audit feature works
{"SoftStart", validateSoftStart}, // do a soft start. ensure config didnt change. {"SoftStart", validateSoftStart}, // do a soft start. ensure config didnt change.
{"KubeContext", validateKubeContext}, // Racy: must come immediately after "minikube start" {"KubeContext", validateKubeContext}, // Racy: must come immediately after "minikube start"
{"KubectlGetPods", validateKubectlGetPods}, // Make sure apiserver is up {"KubectlGetPods", validateKubectlGetPods}, // Make sure apiserver is up
...@@ -290,15 +291,16 @@ func validateStartWithProxy(ctx context.Context, t *testing.T, profile string) { ...@@ -290,15 +291,16 @@ func validateStartWithProxy(ctx context.Context, t *testing.T, profile string) {
t.Errorf("start stderr=%s, want: *%s*", rr.Stderr.String(), want) t.Errorf("start stderr=%s, want: *%s*", rr.Stderr.String(), want)
} }
t.Run("Audit", func(t *testing.T) { }
got, err := auditContains(profile)
if err != nil { func validateAuditAfterStart(ctx context.Context, t *testing.T, profile string) {
t.Fatalf("failed to check audit log: %v", err) got, err := auditContains(profile)
} if err != nil {
if !got { t.Fatalf("failed to check audit log: %v", err)
t.Errorf("audit.json does not contain the profile %q", profile) }
} if !got {
}) t.Errorf("audit.json does not contain the profile %q", profile)
}
} }
// validateSoftStart validates that after minikube already started, a "minikube start" should not change the configs. // validateSoftStart validates that after minikube already started, a "minikube start" should not change the configs.
...@@ -331,16 +333,6 @@ func validateSoftStart(ctx context.Context, t *testing.T, profile string) { ...@@ -331,16 +333,6 @@ func validateSoftStart(ctx context.Context, t *testing.T, profile string) {
if afterCfg.Config.KubernetesConfig.NodePort != apiPortTest { if afterCfg.Config.KubernetesConfig.NodePort != apiPortTest {
t.Errorf("expected node port in the config not change after soft start. exepceted node port to be %d but got %d.", apiPortTest, afterCfg.Config.KubernetesConfig.NodePort) t.Errorf("expected node port in the config not change after soft start. exepceted node port to be %d but got %d.", apiPortTest, afterCfg.Config.KubernetesConfig.NodePort)
} }
t.Run("Audit", func(t *testing.T) {
got, err := auditContains(profile)
if err != nil {
t.Fatalf("failed to check audit log: %v", err)
}
if !got {
t.Errorf("audit.json does not contain the profile %q", profile)
}
})
} }
// validateKubeContext asserts that kubectl is properly configured (race-condition prone!) // validateKubeContext asserts that kubectl is properly configured (race-condition prone!)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册