Skip to content

Commit 2759b06

Browse files
committed
MCO-1930: migrate ControlPlaneMachineset tests
1 parent e0a76a2 commit 2759b06

16 files changed

+2279
-175
lines changed

test/extended/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/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/const.go

Lines changed: 22 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`
@@ -64,4 +77,12 @@ const (
6477

6578
// DefaultExpectTimeout is the default timeout for expect operations
6679
DefaultExpectTimeout = 10 * time.Second
80+
81+
// MachineAPINamespace is the MachineAPI namespace (alias for MAPINamespace)
82+
MachineAPINamespace = MAPINamespace
83+
84+
// MachineSetResource is the resource name for machinesets
85+
MachineSetResource = "machinesets"
86+
// ControlPlaneMachineSetResource is the resource name for controlplanemachinesets
87+
ControlPlaneMachineSetResource = "controlplanemachinesets"
6788
)

0 commit comments

Comments
 (0)