Skip to content

Commit

Permalink
feat/dev: OPCT-32 enable dev-count flag to limit e2e in Dev env (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtulio committed Jan 24, 2023
1 parent 3fe6c15 commit 938fd19
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
5 changes: 5 additions & 0 deletions manifests/openshift-conformance-validated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: DEV_MODE_COUNT
valueFrom:
configMapKeyRef:
name: plugins-config
key: dev-count
5 changes: 5 additions & 0 deletions manifests/openshift-kube-conformance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: DEV_MODE_COUNT
valueFrom:
configMapKeyRef:
name: plugins-config
key: dev-count
10 changes: 10 additions & 0 deletions pkg/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type RunOptions struct {
sonobuoyImage string
timeout int
watch bool
devCount string
}

const runTimeoutSeconds = 21600
Expand Down Expand Up @@ -119,9 +120,11 @@ func NewCmdRun() *cobra.Command {
cmd.Flags().StringVar(&o.sonobuoyImage, "sonobuoy-image", fmt.Sprintf("quay.io/ocp-cert/sonobuoy:%s", buildinfo.Version), "Image override for the Sonobuoy worker and aggregator")
cmd.Flags().IntVar(&o.timeout, "timeout", runTimeoutSeconds, "Execution timeout in seconds")
cmd.Flags().BoolVarP(&o.watch, "watch", "w", false, "Keep watch status after running")
cmd.Flags().StringVar(&o.devCount, "dev-count", "0", "Developer Mode only: run small random set of tests. Default: 0 (disabled)")

// Hide dedicated flag since this is for development only
cmd.Flags().MarkHidden("dedicated")
cmd.Flags().MarkHidden("dev-count")

return cmd
}
Expand Down Expand Up @@ -311,6 +314,15 @@ func (r *RunOptions) PreRunCheck(kclient kubernetes.Interface) error {
return nil
}

// createConfigMap generic way to create the configMap on the certification namespace.
func (r *RunOptions) createConfigMap(kclient kubernetes.Interface, sclient sonobuoyclient.Interface, cm *v1.ConfigMap) error {
_, err := kclient.CoreV1().ConfigMaps(pkg.CertificationNamespace).Create(context.TODO(), cm, metav1.CreateOptions{})
if err != nil {
return err
}
return nil
}

func (r *RunOptions) Run(kclient kubernetes.Interface, sclient sonobuoyclient.Interface) error {
var manifests []*manifest.Manifest

Expand All @@ -329,7 +341,7 @@ func (r *RunOptions) Run(kclient kubernetes.Interface, sclient sonobuoyclient.In
}

// Create version information ConfigMap
configMap := &v1.ConfigMap{
if err := r.createConfigMap(kclient, sclient, &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: pkg.VersionInfoConfigMapName,
Namespace: pkg.CertificationNamespace,
Expand All @@ -340,9 +352,19 @@ func (r *RunOptions) Run(kclient kubernetes.Interface, sclient sonobuoyclient.In
"sonobuoy-version": buildinfo.Version,
"sonobuoy-image": r.sonobuoyImage,
},
}); err != nil {
return err
}
_, err := kclient.CoreV1().ConfigMaps(pkg.CertificationNamespace).Create(context.TODO(), configMap, metav1.CreateOptions{})
if err != nil {

if err := r.createConfigMap(kclient, sclient, &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: pkg.PluginsVarsConfigMapName,
Namespace: pkg.CertificationNamespace,
},
Data: map[string]string{
"dev-count": r.devCount,
},
}); err != nil {
return err
}

Expand Down Expand Up @@ -401,7 +423,7 @@ func (r *RunOptions) Run(kclient kubernetes.Interface, sclient sonobuoyclient.In
},
}

err = sclient.Run(runConfig)
err := sclient.Run(runConfig)
return err
}

Expand Down
1 change: 1 addition & 0 deletions pkg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
PrivilegedClusterRoleBinding = "opct-scc-privileged"
CertificationNamespace = "openshift-provider-certification"
VersionInfoConfigMapName = "openshift-provider-certification-version"
PluginsVarsConfigMapName = "plugins-config"
DedicatedNodeRoleLabel = "node-role.kubernetes.io/tests"
DedicatedNodeRoleLabelSelector = "node-role.kubernetes.io/tests="
SonobuoyServiceAccountName = "sonobuoy-serviceaccount"
Expand Down

0 comments on commit 938fd19

Please sign in to comment.