Skip to content

Commit 893b346

Browse files
committed
MCO-1930: migrate ControlPlaneMachineset tests
1 parent 8dc0f4d commit 893b346

19 files changed

+2426
-178
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ require (
4646
github.com/spf13/cobra v1.9.1
4747
github.com/spf13/pflag v1.0.6
4848
github.com/stretchr/testify v1.10.0
49+
github.com/tidwall/gjson v1.14.2
4950
github.com/tidwall/sjson v1.2.5
5051
github.com/vincent-petithory/dataurl v1.0.0
5152
github.com/vmware/govmomi v0.45.1
@@ -179,7 +180,6 @@ require (
179180
github.com/sigstore/rekor v1.3.10 // indirect
180181
github.com/sourcegraph/conc v0.3.0 // indirect
181182
github.com/stoewer/go-strcase v1.3.0 // indirect
182-
github.com/tidwall/gjson v1.14.2 // indirect
183183
github.com/tidwall/match v1.1.1 // indirect
184184
github.com/tidwall/pretty v1.2.0 // indirect
185185
github.com/timonwong/loggercheck v0.10.1 // indirect

test/extended-priv/configmap.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package extended
22

33
import (
44
"encoding/json"
5+
"fmt"
56

67
o "github.com/onsi/gomega"
78
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
@@ -27,6 +28,24 @@ func NewConfigMapList(oc *exutil.CLI, namespace string) *ConfigMapList {
2728
return &ConfigMapList{ResourceList: *NewNamespacedResourceList(oc, "ConfigMap", namespace)}
2829
}
2930

31+
// GetDataValue returns the value of a specific key in the .data field
32+
func (cm *ConfigMap) GetDataValue(key string) (string, error) {
33+
// We cant use the "resource.Get" method, because exutil.client will trim the output, removing spaces and newlines that could be important in a configuration.
34+
dataMap, err := cm.GetDataMap()
35+
36+
if err != nil {
37+
return "", err
38+
}
39+
40+
data, ok := dataMap[key]
41+
if !ok {
42+
return "", fmt.Errorf("Key %s does not exist in the .data in Configmap -n %s %s",
43+
key, cm.GetNamespace(), cm.GetName())
44+
}
45+
46+
return data, nil
47+
}
48+
3049
// GetDataMap returns the valus in the .data field as a map[string][string]
3150
func (cm *ConfigMap) GetDataMap() (map[string]string, error) {
3251
data := map[string]string{}
@@ -42,6 +61,16 @@ func (cm *ConfigMap) GetDataMap() (map[string]string, error) {
4261
return data, nil
4362
}
4463

64+
// GetDataValueOrFail returns the value of a specific key in the .data field and fails the test if any error happens
65+
func (cm *ConfigMap) GetDataValueOrFail(key string) string {
66+
value, err := cm.GetDataValue(key)
67+
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(),
68+
"Could get the value for key %s in configmap -n %s %s",
69+
key, cm.GetNamespace(), cm.GetName())
70+
71+
return value
72+
}
73+
4574
// GetAll returns a []ConfigMap list with all existing pinnedimageset sorted by creation timestamp
4675
func (cml *ConfigMapList) GetAll() ([]ConfigMap, error) {
4776
cml.ResourceList.SortByTimestamp()

test/extended-priv/const.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package extended
33
import "time"
44

55
const (
6+
// Ignition default version
7+
IgnitionDefaultVersion = "3.5.0"
8+
69
// MachineConfigNamespace mco namespace
710
MachineConfigNamespace = "openshift-machine-config-operator"
811
// MachineConfigDaemon mcd container name
@@ -27,7 +30,17 @@ const (
2730

2831
// LayeringBaseImageReleaseInfo is the name of the layering base image in release info
2932
LayeringBaseImageReleaseInfo = "rhel-coreos"
30-
GenericMCTemplate = "generic-machine-config-template.yml"
33+
// GenericMCTemplate is the name of a MachineConfig template that can be fully configured by parameters
34+
GenericMCTemplate = "generic-machine-config-template.yml"
35+
36+
// AWSPlatform value used to identify aws infrastructure
37+
AWSPlatform = "aws"
38+
// GCPPlatform value used to identify gcp infrastructure
39+
GCPPlatform = "gcp"
40+
// AzurePlatform value used to identify azure infrastructure
41+
AzurePlatform = "azure"
42+
// VspherePlatform value used to identify Vsphere infrastructure
43+
VspherePlatform = "vsphere"
3144

3245
// ExpirationDockerfileLabel Expiration label in Dockerfile
3346
ExpirationDockerfileLabel = `LABEL maintainer="mco-qe-team" quay.expires-after=24h`
@@ -48,4 +61,18 @@ const (
4861

4962
// DefaultExpectTimeout is the default timeout for expect operations
5063
DefaultExpectTimeout = 10 * time.Second
64+
65+
// MachineAPINamespace is the MachineAPI namespace
66+
MachineAPINamespace = "openshift-machine-api"
67+
68+
// We use full name to get machineset/machine xref: https://access.redhat.com/solutions/7040368
69+
// MachineSetFullName is the machineset fully qualified name
70+
MachineSetFullName = "machineset.machine.openshift.io"
71+
// MachineFullName is the machine fully qualified name
72+
MachineFullName = "machine.machine.openshift.io"
73+
74+
// MachineSetResource is the resource name for machinesets
75+
MachineSetResource = "machinesets"
76+
// ControlPlaneMachineSetResource is the resource name for controlplanemachinesets
77+
ControlPlaneMachineSetResource = "controlplanemachinesets"
5178
)

0 commit comments

Comments
 (0)