Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of APIServerArgs for testenv #439

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/apis/testharness/v1beta1/test_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type TestSuite struct {
StartControlPlane bool `json:"startControlPlane"`
// ControlPlaneArgs defaults to APIServerDefaultArgs from controller-runtime pkg/internal/testing/integration/internal/apiserver.go
// this allows for control over the args, however these are not serialized from a TestSuite.yaml
// deprecated and is no longer used!
// TODO: remove after v0.16.0 (provide warning message until then)
ControlPlaneArgs []string `json:"controlPlaneArgs"`
// AttachControlPlaneOutput if true, attaches control plane logs (api-server, etcd) into stdout. This is useful for debugging.
// defaults to false
Expand Down
11 changes: 3 additions & 8 deletions pkg/kuttlctl/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func newTestCmd() *cobra.Command { //nolint:gocyclo
skipClusterDelete := false
parallel := 0
artifactsDir := ""
// TODO: remove after v0.16.0 deprecated
mockControllerFile := ""
timeout := 30
reportFormat := ""
Expand Down Expand Up @@ -209,17 +210,10 @@ For more detailed documentation, visit: https://kuttl.dev`,
if len(options.TestDirs) == 0 {
return errors.New("no test directories provided, please provide either --config or test directories on the command line")
}
var APIServerArgs []string
var err error
if mockControllerFile != "" {
APIServerArgs, err = testutils.ReadMockControllerConfig(mockControllerFile)
log.Println("use of --control-plane-config is deprecated and no longer functions")
}

if err != nil {
return err
}
options.ControlPlaneArgs = APIServerArgs

return nil
},
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -240,6 +234,7 @@ For more detailed documentation, visit: https://kuttl.dev`,
testCmd.Flags().StringVar(&testToRun, "test", "", "If set, the specific test case to run.")
testCmd.Flags().BoolVar(&startControlPlane, "start-control-plane", false, "Start a local Kubernetes control plane for the tests (requires etcd and kube-apiserver binaries, cannot be used with --start-kind).")
testCmd.Flags().BoolVar(&attachControlPlaneOutput, "attach-control-plane-output", false, "Attaches control plane to stdout when using --start-control-plane.")
// TODO: remove after v0.16.0 deprecated mockControllerFile is not supported in the latest testenv
testCmd.Flags().StringVar(&mockControllerFile, "control-plane-config", "", "Path to file to load controller-runtime APIServer configuration arguments (only useful when --startControlPlane).")
testCmd.Flags().BoolVar(&startKIND, "start-kind", false, "Start a KIND cluster for the tests (cannot be used with --start-control-plane).")
testCmd.Flags().StringVar(&kindConfig, "kind-config", "", "Specify the KIND configuration file path (implies --start-kind, cannot be used with --start-control-plane).")
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/case_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// Create two test environments, ensure that the second environment is used when
// Kubeconfig is set on a Step.
func TestMultiClusterCase(t *testing.T) {
testenv, err := testutils.StartTestEnvironment(nil, false)
testenv, err := testutils.StartTestEnvironment(false)
if err != nil {
t.Error(err)
return
Expand All @@ -27,7 +27,7 @@ func TestMultiClusterCase(t *testing.T) {
}
})

testenv2, err := testutils.StartTestEnvironment(nil, false)
testenv2, err := testutils.StartTestEnvironment(false)
if err != nil {
t.Error(err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (h *Harness) addNodeCaches(dockerClient testutils.DockerClient, kindCfg *ki
func (h *Harness) RunTestEnv() (*rest.Config, error) {
started := time.Now()

testenv, err := testutils.StartTestEnvironment(h.TestSuite.ControlPlaneArgs, h.TestSuite.AttachControlPlaneOutput)
testenv, err := testutils.StartTestEnvironment(h.TestSuite.AttachControlPlaneOutput)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/harness_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestHarnessRunIntegration(t *testing.T) {
}

func TestHarnessRunIntegrationWithConfig(t *testing.T) {
testenv, err := testutils.StartTestEnvironment(nil, false)
testenv, err := testutils.StartTestEnvironment(false)
if err != nil {
t.Fatalf("fatal error starting environment: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/step_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var testenv testutils.TestEnvironment
func TestMain(m *testing.M) {
var err error

testenv, err = testutils.StartTestEnvironment(nil, false)
testenv, err = testutils.StartTestEnvironment(false)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/utils/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ type TestEnvironment struct {

// StartTestEnvironment is a wrapper for controller-runtime's envtest that creates a Kubernetes API server and etcd
// suitable for use in tests.
func StartTestEnvironment(kubeAPIServerFlags []string, attachControlPlaneOutput bool) (env TestEnvironment, err error) {
func StartTestEnvironment(attachControlPlaneOutput bool) (env TestEnvironment, err error) {
env.Environment = &envtest.Environment{
AttachControlPlaneOutput: attachControlPlaneOutput,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/utils/kubernetes_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var testenv TestEnvironment
func TestMain(m *testing.M) {
var err error

testenv, err = StartTestEnvironment(nil, false)
testenv, err = StartTestEnvironment(false)
if err != nil {
log.Fatal(err)
}
Expand Down
22 changes: 0 additions & 22 deletions pkg/test/utils/mock_control_plane.go

This file was deleted.