Skip to content

Commit 378bf9b

Browse files
committed
feat: add tests to validate DualReplica topology effects
added test to check platform type is set to baremetal or none added test to check baremetal hosts are set to detached Signed-off-by: ehila <[email protected]>
1 parent 9810f24 commit 378bf9b

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

test/extended/two_node/tnf_topology.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
v1 "github.com/openshift/api/config/v1"
1111
exutil "github.com/openshift/origin/test/extended/util"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
14+
"k8s.io/apimachinery/pkg/runtime/schema"
1315
)
1416

1517
const ensurePodmanEtcdContainerIsRunning = "podman inspect --format '{{.State.Running}}' etcd"
@@ -43,6 +45,44 @@ var _ = g.Describe("[sig-node][apigroup:config.openshift.io][OCPFeatureGate:Dual
4345
o.Expect(err).ShouldNot(o.HaveOccurred(), "Expected to retrieve arbiter nodes without error")
4446
o.Expect(len(arbiterNodes.Items)).To(o.Equal(expectedArbiters), fmt.Sprintf("Expected %d Arbiter Nodes, found %d", expectedArbiters, len(arbiterNodes.Items)))
4547
})
48+
49+
g.It("should have infrastructure platform type set correctly", func() {
50+
g.By("Checking that the infrastructure platform is set to baremetal or none or external")
51+
infrastructure, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(context.Background(), "cluster", metav1.GetOptions{})
52+
o.Expect(err).ShouldNot(o.HaveOccurred(), "Expected to retrieve infrastructure configuration without error")
53+
54+
platformType := infrastructure.Status.PlatformStatus.Type
55+
o.Expect(platformType).To(o.Or(o.Equal(v1.BareMetalPlatformType), o.Equal(v1.NonePlatformType), o.Equal(v1.ExternalPlatformType)),
56+
fmt.Sprintf("Expected infrastructure platform to be baremetal or none or external, but found %s", platformType))
57+
})
58+
59+
g.It("should have BareMetalHost operational status set to detached if they exist", func() {
60+
g.By("Checking that BareMetalHost objects have operational status set to detached")
61+
dc := oc.AdminDynamicClient()
62+
63+
// Use Dynamic Client to get BareMetalHost objects
64+
// Note: move this to common.go if this is used in other tests
65+
baremetalGVR := schema.GroupVersionResource{Group: "metal3.io", Resource: "baremetalhosts", Version: "v1alpha1"}
66+
baremetalClient := dc.Resource(baremetalGVR).Namespace("openshift-machine-api")
67+
68+
hosts, err := baremetalClient.List(context.Background(), metav1.ListOptions{})
69+
o.Expect(err).ShouldNot(o.HaveOccurred(), "Expected to retrieve BareMetalHost objects without error")
70+
71+
// If no BareMetalHost objects exist, skip the test, this is valid for TNF deployments
72+
if len(hosts.Items) == 0 {
73+
g.Skip("No BareMetalHost objects found in openshift-machine-api namespace")
74+
}
75+
76+
// Check each BareMetalHost has operational status set to detached
77+
for _, host := range hosts.Items {
78+
operationalStatus, found, err := unstructured.NestedString(host.Object, "status", "operationalStatus")
79+
o.Expect(err).ShouldNot(o.HaveOccurred(), fmt.Sprintf("Expected to parse operational status for BareMetalHost %s without error", host.GetName()))
80+
o.Expect(found).To(o.BeTrue(), fmt.Sprintf("Expected operational status field to exist for BareMetalHost %s", host.GetName()))
81+
o.Expect(operationalStatus).To(o.Equal("detached"),
82+
fmt.Sprintf("Expected BareMetalHost %s operational status to be 'detached', but found '%s'", host.GetName(), operationalStatus))
83+
}
84+
})
85+
4686
})
4787

4888
var _ = g.Describe("[sig-etcd][apigroup:config.openshift.io][OCPFeatureGate:DualReplica] Two Node with Fencing", func() {

test/extended/util/annotate/generated/zz_generated.annotations.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zz_generated.manifests/test-reporting.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ spec:
194194
- testName: '[sig-etcd][apigroup:config.openshift.io][OCPFeatureGate:DualReplica][Suite:openshift/two-node][Disruptive]
195195
Two Node with Fencing etcd recovery Should recover from ungraceful node shutdown
196196
with etcd member re-addition'
197+
- testName: '[sig-node][apigroup:config.openshift.io][OCPFeatureGate:DualReplica]
198+
Two Node with Fencing topology should have BareMetalHost operational status
199+
set to detached if they exist'
200+
- testName: '[sig-node][apigroup:config.openshift.io][OCPFeatureGate:DualReplica]
201+
Two Node with Fencing topology should have infrastructure platform type set
202+
correctly'
197203
- testName: '[sig-node][apigroup:config.openshift.io][OCPFeatureGate:DualReplica]
198204
Two Node with Fencing topology should only have two control plane nodes and
199205
no arbiter nodes'

0 commit comments

Comments
 (0)