@@ -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
1517const 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
4888var _ = g .Describe ("[sig-etcd][apigroup:config.openshift.io][OCPFeatureGate:DualReplica] Two Node with Fencing" , func () {
0 commit comments