Skip to content

Commit b092635

Browse files
Merge pull request #5589 from sergiordlr/migrate_machineconfignode_tests
MCO-2059: migrate machineconfignodes from private repo
2 parents 4994239 + 3922850 commit b092635

12 files changed

Lines changed: 1255 additions & 411 deletions

test/extended-priv/const.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const (
3333
// GenericMCTemplate is the name of a MachineConfig template that can be fully configured by parameters
3434
GenericMCTemplate = "generic-machine-config-template.yml"
3535

36+
// NodeAnnotationState state of the mc
37+
NodeAnnotationState = "machineconfiguration.openshift.io/state"
38+
3639
// AWSPlatform value used to identify aws infrastructure
3740
AWSPlatform = "aws"
3841
// GCPPlatform value used to identify gcp infrastructure
@@ -45,6 +48,9 @@ const (
4548
// ExpirationDockerfileLabel Expiration label in Dockerfile
4649
ExpirationDockerfileLabel = `LABEL maintainer="mco-qe-team" quay.expires-after=24h`
4750

51+
// DefaultExpectTimeout is the default timeout for expect operations
52+
DefaultExpectTimeout = 10 * time.Second
53+
4854
// DefaultMinutesWaitingPerNode is the number of minutes per node that the MCPs will wait to become updated
4955
DefaultMinutesWaitingPerNode = 13
5056

@@ -54,17 +60,13 @@ const (
5460
// ExtensionsChangeIncWait extra minutes that MCPs will wait per node if we change the extensions in a configuration
5561
ExtensionsChangeIncWait = 5
5662

57-
// TrueString string for true value
58-
TrueString = "True"
59-
// FalseString string for false value
60-
FalseString = "False"
61-
62-
// DefaultExpectTimeout is the default timeout for expect operations
63-
DefaultExpectTimeout = 10 * time.Second
64-
6563
// MachineAPINamespace is the MachineAPI namespace
6664
MachineAPINamespace = "openshift-machine-api"
6765

66+
// Machine phase Provisioning
67+
MachinePhaseProvisioning = "Provisioning"
68+
// Machine phase Deleting
69+
MachinePhaseDeleting = "Deleting"
6870
// We use full name to get machineset/machine xref: https://access.redhat.com/solutions/7040368
6971
// MachineSetFullName is the machineset fully qualified name
7072
MachineSetFullName = "machineset.machine.openshift.io"
@@ -76,6 +78,11 @@ const (
7678
// ControlPlaneMachineSetResource is the resource name for controlplanemachinesets
7779
ControlPlaneMachineSetResource = "controlplanemachinesets"
7880

81+
// TrueString string for true value
82+
TrueString = "True"
83+
// FalseString string for false value
84+
FalseString = "False"
85+
7986
// BusyBoxImage the multiplatform busybox image stored in openshifttest
8087
BusyBoxImage = "quay.io/openshifttest/busybox@sha256:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f"
8188
// AlpineImage the multiplatform alpine image stored in openshifttest

test/extended-priv/gomega_matchers.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
8-
97
g "github.com/onsi/ginkgo/v2"
108
gomegamatchers "github.com/onsi/gomega/matchers"
119
"github.com/onsi/gomega/types"
10+
logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
1211
)
1312

1413
// struct implementing gomaega matcher interface
@@ -94,11 +93,21 @@ func HaveConditionField(conditionType, conditionField string, expected interface
9493
return &conditionMatcher{conditionType: conditionType, field: conditionField, expected: expected}
9594
}
9695

97-
// HaveDegradedMessage returns the gomega matcher to check if a resource is reporting the given degraded message
96+
// HaveNodeDegradedMessage returns the gomega matcher to check if a resource is reporting the given degraded message
97+
func HaveNodeDegradedMessage(expected interface{}) types.GomegaMatcher {
98+
return &conditionMatcher{conditionType: "NodeDegraded", field: "message", expected: expected}
99+
}
100+
101+
// HaveDegradedMessage returns the gomega matcher to check if a resource is reporting the given node degraded message
98102
func HaveDegradedMessage(expected interface{}) types.GomegaMatcher {
99103
return &conditionMatcher{conditionType: "Degraded", field: "message", expected: expected}
100104
}
101105

106+
// HaveAvailableMessage returns the gomega matcher to check if a resource is reporting the given node available message
107+
func HaveAvailableMessage(expected interface{}) types.GomegaMatcher {
108+
return &conditionMatcher{conditionType: "Available", field: "message", expected: expected}
109+
}
110+
102111
// DegradedMatcher struct implementing gomaega matcher interface to check Degraded condition
103112
type DegradedMatcher struct {
104113
*conditionMatcher

test/extended-priv/machineconfig.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
o "github.com/onsi/gomega"
1010
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
1111
logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
12-
1312
"k8s.io/apimachinery/pkg/util/wait"
1413
)
1514

@@ -39,6 +38,20 @@ func (mc *MachineConfig) SetTemplate(template Template) *MachineConfig {
3938
return mc
4039
}
4140

41+
// SetMCOTemplate set a template defined in the MCO testdata folder
42+
func (mc *MachineConfig) SetMCOTemplate(templateName string) *MachineConfig {
43+
mc.Template = *NewMCOTemplate(mc.oc, templateName)
44+
return mc
45+
}
46+
47+
// SetParams set parameters defined in template
48+
func (mc *MachineConfig) SetParams(params ...string) *MachineConfig {
49+
if len(params) > 0 {
50+
mc.parameters = append(mc.parameters, params...)
51+
}
52+
return mc
53+
}
54+
4255
func (mc *MachineConfig) create() {
4356
mc.name = mc.name + "-" + exutil.GetRandomString()
4457
params := []string{"-p", "NAME=" + mc.name, "POOL=" + mc.pool}

test/extended-priv/machineconfignode.go

Lines changed: 131 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,150 @@ type MachineConfigNode struct {
99
Resource
1010
}
1111

12+
// MachineConfigNodeList resource type declaration
13+
type MachineConfigNodeList struct {
14+
ResourceList
15+
}
16+
1217
// NewMachineConfigNode constructor to get MCN resource
1318
func NewMachineConfigNode(oc *exutil.CLI, node string) *MachineConfigNode {
1419
return &MachineConfigNode{Resource: *NewResource(oc, "machineconfignode", node)}
1520
}
1621

17-
// IsPinnedImageSetsDegraded returns true if the PinnedImageSetsDegraded condition is true
22+
// NewMachineConfigNodeList constructor to get MCN list
23+
func NewMachineConfigNodeList(oc *exutil.CLI) *MachineConfigNodeList {
24+
return &MachineConfigNodeList{ResourceList: *NewResourceList(oc, "machineconfignodes")}
25+
}
26+
27+
// GetAll get list of MachineConfigNode
28+
func (mcnl *MachineConfigNodeList) GetAll() ([]*MachineConfigNode, error) {
29+
resources, err := mcnl.ResourceList.GetAll()
30+
if err != nil {
31+
return nil, err
32+
}
33+
34+
allMCNs := make([]*MachineConfigNode, 0, len(resources))
35+
for _, mcn := range resources {
36+
allMCNs = append(allMCNs, NewMachineConfigNode(mcnl.oc, mcn.GetName()))
37+
}
38+
39+
return allMCNs, nil
40+
}
41+
42+
// GetDesiredMachineConfigOfSpec get value of `.spec.configVersion.desired`
43+
func (mcn *MachineConfigNode) GetDesiredMachineConfigOfSpec() string {
44+
return mcn.GetOrFail(`{.spec.configVersion.desired}`)
45+
}
46+
47+
// GetDesiredMachineConfigOfStatus get value of `.status.configVersion.desired`
48+
func (mcn *MachineConfigNode) GetDesiredMachineConfigOfStatus() string {
49+
return mcn.GetOrFail(`{.status.configVersion.desired}`)
50+
}
51+
52+
// GetCurrentMachineConfigOfStatus get value of `.status.configVersion.current`
53+
func (mcn *MachineConfigNode) GetCurrentMachineConfigOfStatus() string {
54+
return mcn.GetOrFail(`{.status.configVersion.current}`)
55+
}
56+
57+
// GetPool get value of `.spec.pool.name`
58+
func (mcn *MachineConfigNode) GetPoolName() (string, error) {
59+
return mcn.Get(`{.spec.pool.name}`)
60+
}
61+
62+
// GetNode get value of `.spec.node.name`
63+
func (mcn *MachineConfigNode) GetNode() string {
64+
return mcn.GetOrFail(`{.spec.node.name}`)
65+
}
66+
67+
// GetUpdated get condition status of `Updated`
68+
func (mcn *MachineConfigNode) GetUpdated() string {
69+
return mcn.GetConditionStatusByType("Updated")
70+
}
71+
72+
// GetUpdatePrepared get condition status of `UpdatePrepared`
73+
func (mcn *MachineConfigNode) GetUpdatePrepared() string {
74+
return mcn.GetConditionStatusByType("UpdatePrepared")
75+
}
76+
77+
// GetUpdateExecuted get condition status of `UpdateExecuted`
78+
func (mcn *MachineConfigNode) GetUpdateExecuted() string {
79+
return mcn.GetConditionStatusByType("UpdateExecuted")
80+
}
81+
82+
// GetUpdatePostActionComplete get condition status of `UpdatePostActionComplete`
83+
func (mcn *MachineConfigNode) GetUpdatePostActionComplete() string {
84+
return mcn.GetConditionStatusByType("UpdatePostActionComplete")
85+
}
86+
87+
// GetUpdateComplete get condition status of `UpdateComplete`
88+
func (mcn *MachineConfigNode) GetUpdateComplete() string {
89+
return mcn.GetConditionStatusByType("UpdateComplete")
90+
}
91+
92+
// GetResumed get condition status of `Resumed`
93+
func (mcn *MachineConfigNode) GetResumed() string {
94+
return mcn.GetConditionStatusByType("Resumed")
95+
}
96+
97+
// GetUpdateCompatible get condition status of `UpdateCompatible`
98+
func (mcn *MachineConfigNode) GetUpdateCompatible() string {
99+
return mcn.GetConditionStatusByType("UpdateCompatible")
100+
}
101+
102+
// GetAppliedFilesAndOS get condition status of `AppliedFilesAndOS`
103+
func (mcn *MachineConfigNode) GetAppliedFilesAndOS() string {
104+
return mcn.GetConditionStatusByType("AppliedFilesAndOS")
105+
}
106+
107+
// GetCordoned get condition status of `Cordoned`
108+
func (mcn *MachineConfigNode) GetCordoned() string {
109+
return mcn.GetConditionStatusByType("Cordoned")
110+
}
111+
112+
// GetUncordoned get condition status of `Uncordoned`
113+
func (mcn *MachineConfigNode) GetUncordoned() string {
114+
return mcn.GetConditionStatusByType("Uncordoned")
115+
}
116+
117+
// GetDrained get condition status of `Drained`
118+
func (mcn *MachineConfigNode) GetDrained() string {
119+
return mcn.GetConditionStatusByType("Drained")
120+
}
121+
122+
// GetRebootedNode get condition status of `RebootedNode`
123+
func (mcn *MachineConfigNode) GetRebootedNode() string {
124+
return mcn.GetConditionStatusByType("RebootedNode")
125+
}
126+
127+
// GetReloadedCRIO get condition status of `ReloadedCRIO`
128+
func (mcn *MachineConfigNode) GetReloadedCRIO() string {
129+
return mcn.GetConditionStatusByType("ReloadedCRIO")
130+
}
131+
18132
func (mcn *MachineConfigNode) IsPinnedImageSetsDegraded() bool {
19133
return mcn.IsConditionStatusTrue("PinnedImageSetsDegraded")
20134
}
21135

22-
// IsPinnedImageSetsProgressing returns true if the PinnedImageSetsProgressing condition is true
23136
func (mcn *MachineConfigNode) IsPinnedImageSetsProgressing() bool {
24137
return mcn.IsConditionStatusTrue("PinnedImageSetsProgressing")
25138
}
26139

27-
// GetPinnedImageSetLastFailedError returns the last failed generation error for pinned image sets
140+
// GetDesiredMachineConfigOfSpec get value of `.spec.configVersion.desired`
28141
func (mcn *MachineConfigNode) GetPinnedImageSetLastFailedError() string {
29142
return mcn.GetOrFail(`{.status.pinnedImageSets[*].lastFailedGenerationError}`)
30143
}
144+
145+
// GetDesiredImage get value of `.spec.configImage.desiredImage`
146+
func (mcn *MachineConfigNode) GetSpecDesiredImage() (string, error) {
147+
return mcn.Get(`{.spec.configImage.desiredImage}`)
148+
}
149+
150+
// GetStatusDesiredImage get value of `.status.configImage.desiredImage`
151+
func (mcn *MachineConfigNode) GetStatusDesiredImage() (string, error) {
152+
return mcn.Get(`{.status.configImage.desiredImage}`)
153+
}
154+
155+
// GetStatusCurrentImage get value of `.status.configImage.currentImage`
156+
func (mcn *MachineConfigNode) GetStatusCurrentImage() (string, error) {
157+
return mcn.Get(`{.status.configImage.currentImage}`)
158+
}

0 commit comments

Comments
 (0)