Skip to content

Commit

Permalink
feat(test) parametrize kuma deploy (#973)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
jakubdyszkiewicz authored and Nikolay Nikolaev committed Oct 1, 2020
1 parent f8bd700 commit 08205ca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
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

0 comments on commit 08205ca

Please sign in to comment.