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

feat(test) parametrize kuma deploy #973

Merged
merged 4 commits into from
Aug 17, 2020
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
10 changes: 10 additions & 0 deletions test/framework/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type deployOptions struct {
installationMode InstallationMode
helmReleaseName string
helmOpts map[string]string
ctlOpts map[string]string
}

type DeployOptionsFunc func(*deployOptions)
Expand Down Expand Up @@ -53,6 +54,15 @@ func WithHelmOpt(name, value string) DeployOptionsFunc {
}
}

func WithCtlOpt(name, value string) DeployOptionsFunc {
return func(o *deployOptions) {
if o.ctlOpts == nil {
o.ctlOpts = map[string]string{}
}
o.ctlOpts[name] = value
}
}

func newDeployOpt(fs ...DeployOptionsFunc) *deployOptions {
rv := &deployOptions{
installationMode: KumactlInstallationMode,
Expand Down
28 changes: 24 additions & 4 deletions test/framework/k8s_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,22 @@ func (c *K8sCluster) GetPodLogs(pod v1.Pod) (string, error) {
// deployKumaViaKubectl uses kubectl to install kuma
// using the resources from the `kumactl install control-plane` command
func (c *K8sCluster) deployKumaViaKubectl(mode string, opts *deployOptions) error {
var args []string
argsMap := map[string]string{
"--control-plane-image": kumaCPImage,
"--dataplane-image": kumaDPImage,
"--dataplane-init-image": kumaInitImage,
}
switch mode {
case core.Remote:
args = append(args, "--kds-global-address", opts.globalAddress)
argsMap["--kds-global-address"] = opts.globalAddress
}
for opt, value := range opts.ctlOpts {
argsMap[opt] = value
}

var args []string
for k, v := range argsMap {
args = append(args, k, v)
}
yaml, err := c.controlplane.InstallCP(args...)
if err != nil {
Expand Down Expand Up @@ -471,11 +483,19 @@ func (c *K8sCluster) deleteKumaViaHelm(opts *deployOptions) (errs error) {
}

func (c *K8sCluster) deleteKumaViaKumactl(opts *deployOptions) error {
args := []string{}
argsMap := map[string]string{}
switch c.controlplane.mode {
case core.Remote:
// kumactl remote deployment will fail if GlobalAddress is not specified
args = append(args, "--kds-global-address", "grpcs://0.0.0.0:5685")
argsMap["--kds-global-address"] = "grpcs://0.0.0.0:5685"
}
for opt, value := range opts.ctlOpts {
argsMap[opt] = value
}

var args []string
for k, v := range argsMap {
args = append(args, k, v)
}
yaml, err := c.controlplane.InstallCP(args...)
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions test/framework/kumactl.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ func storeConfigToTempFile(name string, configData string) (string, error) {
func (o *KumactlOptions) KumactlInstallCP(mode string, args ...string) (string, error) {
cmd := []string{
"install", "control-plane",
"--control-plane-image", kumaCPImage,
"--dataplane-image", kumaDPImage,
"--dataplane-init-image", kumaInitImage,
}

cmd = append(cmd, "--mode", mode)
Expand Down