Skip to content

Commit beccbba

Browse files
Cr 1539 add proxy acceptance test (#204)
1 parent 30684fe commit beccbba

File tree

17 files changed

+416
-18
lines changed

17 files changed

+416
-18
lines changed

venona/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.6
1+
1.5.7

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.6
1+
1.5.7

venonactl/cmd/cmdutils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ func extendStoreWithKubeClient(logger logger.Logger) {
130130
}
131131
}
132132

133+
func setVerbosity(verbose bool) {
134+
s := store.GetStore()
135+
s.Verbose = verbose
136+
}
137+
138+
func setInsecure(insecure bool) {
139+
s := store.GetStore()
140+
s.Insecure = insecure
141+
}
142+
133143
func isUsingDefaultStorageClass(sc string) bool {
134144
if sc == "" {
135145
return true

venonactl/cmd/test.go

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,52 @@ var allTestPluginTypes = []string{
2929
plugins.VolumeProvisionerPluginType,
3030
plugins.EnginePluginType,
3131
plugins.RuntimeAttachType,
32+
plugins.NetworkTesterPluginType,
3233
}
3334

3435
var testCommandOptions struct {
3536
kube struct {
3637
namespace string
3738
context string
39+
inCluster bool
3840
}
39-
plugin []string
41+
insecure bool
42+
plugin []string
43+
templateValues []string
44+
templateFileValues []string
45+
templateValueFiles []string
4046
}
4147

4248
var testCommand = &cobra.Command{
4349
Use: "test",
4450
Short: "Run test on the target cluster prior installation",
4551
Run: func(cmd *cobra.Command, args []string) {
52+
// get valuesMap from --values <values.yaml> --set-value k=v --set-file k=<context-of file>
53+
templateValuesMap, err := templateValuesToMap(
54+
testCommandOptions.templateValueFiles,
55+
testCommandOptions.templateValues,
56+
testCommandOptions.templateFileValues)
57+
if err != nil {
58+
dieOnError(err)
59+
}
60+
// Merge cmd options with template
61+
mergeValueStr(templateValuesMap, "ConfigPath", &kubeConfigPath)
62+
mergeValueStr(templateValuesMap, "CodefreshHost", &cfAPIHost)
63+
mergeValueStr(templateValuesMap, "Token", &cfAPIToken)
64+
mergeValueStr(templateValuesMap, "Namespace", &testCommandOptions.kube.namespace)
65+
mergeValueStr(templateValuesMap, "Context", &testCommandOptions.kube.context)
66+
mergeValueBool(templateValuesMap, "InCluster", &testCommandOptions.kube.inCluster)
67+
mergeValueBool(templateValuesMap, "insecure", &testCommandOptions.insecure)
68+
4669
lgr := createLogger("test", verbose, logFormatter)
4770
s := store.GetStore()
71+
buildBasicStore(lgr)
4872
extendStoreWithKubeClient(lgr)
49-
fillKubernetesAPI(lgr, testCommandOptions.kube.context, testCommandOptions.kube.namespace, false)
73+
fillKubernetesAPI(lgr, testCommandOptions.kube.context, testCommandOptions.kube.namespace, testCommandOptions.kube.inCluster)
74+
fillCodefreshAPI(lgr)
75+
extendStoreWithAgentAPI(lgr, "", "")
76+
setVerbosity(verbose)
77+
setInsecure(testCommandOptions.insecure)
5078

5179
builder := plugins.NewBuilder(lgr)
5280
for _, p := range testCommandOptions.plugin {
@@ -68,14 +96,24 @@ var testCommand = &cobra.Command{
6896
if p == plugins.RuntimeAttachType {
6997
builder.Add(plugins.RuntimeAttachType)
7098
}
99+
if p == plugins.NetworkTesterPluginType {
100+
builder.Add(plugins.NetworkTesterPluginType)
101+
}
102+
}
103+
104+
options := plugins.TestOptions{
105+
KubeBuilder: getKubeClientBuilder(s.KubernetesAPI.ContextName, s.KubernetesAPI.Namespace, s.KubernetesAPI.ConfigPath, s.KubernetesAPI.InCluster),
106+
ClusterNamespace: s.KubernetesAPI.Namespace,
71107
}
108+
109+
values := s.BuildValues()
110+
values = mergeMaps(values, templateValuesMap)
111+
72112
var finalerr error
73113
lgr.Info("Testing requirements")
114+
74115
for _, p := range builder.Get() {
75-
err := p.Test(plugins.TestOptions{
76-
KubeBuilder: getKubeClientBuilder(s.KubernetesAPI.ContextName, s.KubernetesAPI.Namespace, s.KubernetesAPI.ConfigPath, false),
77-
ClusterNamespace: s.KubernetesAPI.Namespace,
78-
})
116+
err := p.Test(options, values)
79117
if err != nil && finalerr == nil {
80118
finalerr = err
81119
}
@@ -92,7 +130,13 @@ func init() {
92130

93131
testCommand.Flags().StringVar(&testCommandOptions.kube.namespace, "kube-namespace", viper.GetString("kube-namespace"), "Name of the namespace on which monitor should be installed [$KUBE_NAMESPACE]")
94132
testCommand.Flags().StringVar(&testCommandOptions.kube.context, "kube-context-name", viper.GetString("kube-context"), "Name of the kubernetes context on which monitor should be installed (default is current-context) [$KUBE_CONTEXT]")
133+
testCommand.Flags().BoolVar(&testCommandOptions.insecure, "insecure", false, "Set to true to disable certificate validation when using TLS connections")
134+
testCommand.Flags().BoolVar(&testCommandOptions.kube.inCluster, "in-cluster", false, "Set flag if the command is running inside a cluster")
95135
testCommand.Flags().StringArrayVar(&testCommandOptions.plugin, "installer", allTestPluginTypes, "Which test to run, based on the installer type")
96136

137+
testCommand.Flags().StringArrayVar(&testCommandOptions.templateValues, "set-value", []string{}, "Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes")
138+
testCommand.Flags().StringArrayVar(&testCommandOptions.templateFileValues, "set-file", []string{}, "Set values for templates from file, example: --set-file Storage.GoogleServiceAccount=/path/to/service-account.json")
139+
testCommand.Flags().StringArrayVarP(&testCommandOptions.templateValueFiles, "values", "f", []string{}, "specify values in a YAML file")
140+
97141
rootCmd.AddCommand(testCommand)
98142
}

venonactl/example/values-example.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
### default is: runner
4949
# RuntimeServiceAccount: runner
5050

51+
### SkipClusterTest: only set to true if you want to skip the acceptance tests during the installation
52+
# SkipClusterTest: true
53+
5154
### ClusterId --clusterId: used when installing the monitor component
5255
### this is the name of the cluster integration in codefresh
5356
# ClusterId: cluster-name
@@ -60,10 +63,13 @@
6063
# HTTPS_PROXY: http://123.123.123.123:8080
6164
# NO_PROXY: localhost
6265

63-
### DockerRegistry --docker-registry: the docker registry from which all components
64-
### images will be pulled. default: docker.io
66+
### DockerRegistry --docker-registry: The docker registry from which all components images will be pulled [default: docker.io].
67+
### We will check connectivity from inside the cluster to this domain.
6568
# DockerRegistry: docker.io
6669

70+
# GitProviderURL: api.github.com # (optional) We will check connectivity to this URL when we run our acceptance tests.
71+
72+
6773
###############################################
6874
### Codefresh Runner ###
6975
### ###
@@ -242,3 +248,12 @@
242248
# ServiceAccount: # will be used by the engine and dind pods
243249
# Annotations:
244250
# foo: bar
251+
252+
253+
########################################################
254+
### Logging ###
255+
### ###
256+
### configure build logging solution ###
257+
########################################################
258+
# Logging:
259+
# FirebaseHost: firebase.io # (optional) We will check connectivity to this URL when we run our acceptance tests.

venonactl/pkg/plugins/app-proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (u *appProxyPlugin) Migrate(*MigrateOptions, Values) error {
122122
return fmt.Errorf("not supported")
123123
}
124124

125-
func (u *appProxyPlugin) Test(opt TestOptions) error {
125+
func (u *appProxyPlugin) Test(opt TestOptions, v Values) error {
126126
return nil
127127
}
128128

venonactl/pkg/plugins/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (u *enginePlugin) Migrate(*MigrateOptions, Values) error {
101101
return fmt.Errorf("not supported")
102102
}
103103

104-
func (u *enginePlugin) Test(opt TestOptions) error {
104+
func (u *enginePlugin) Test(opt TestOptions, v Values) error {
105105
return nil
106106
}
107107

venonactl/pkg/plugins/monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (u *monitorAgentPlugin) Migrate(*MigrateOptions, Values) error {
8686
return fmt.Errorf("not supported")
8787
}
8888

89-
func (u *monitorAgentPlugin) Test(opt TestOptions) error {
89+
func (u *monitorAgentPlugin) Test(opt TestOptions, v Values) error {
9090
validationRequest := validationRequest{
9191
rbac: []rbacValidation{
9292
{

0 commit comments

Comments
 (0)