@@ -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,55 @@ 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 set to baremetal or none" , func () {
50+ g .By ("Checking that the infrastructure platform is set to baremetal or none" )
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 )),
56+ fmt .Sprintf ("Expected infrastructure platform to be baremetal or none, but found %s" , platformType ))
57+ })
58+
59+ g .It ("should have etcd operator configured for external etcd support" , func () {
60+ g .By ("Checking that the etcd operator has useExternalEtcdSupport set to true" )
61+ etcdOperator , err := oc .AdminOperatorClient ().OperatorV1 ().Etcds ().Get (context .Background (), "cluster" , metav1.GetOptions {})
62+ o .Expect (err ).ShouldNot (o .HaveOccurred (), "Expected to retrieve etcd operator configuration without error" )
63+
64+ // Check if useExternalEtcdSupport is set to true in unsupported config overrides
65+ useExternalEtcdSupport , err := getUseExternalEtcdSupport (& etcdOperator .Spec .StaticPodOperatorSpec )
66+ o .Expect (err ).ShouldNot (o .HaveOccurred (), "Expected to parse etcd operator unsupported config overrides without error" )
67+ o .Expect (useExternalEtcdSupport ).To (o .BeTrue (), "Expected useExternalEtcdSupport to be set to true in etcd operator configuration" )
68+ })
69+
70+ g .It ("should have BareMetalHost operational status set to detached if they exist" , func () {
71+ g .By ("Checking that BareMetalHost objects have operational status set to detached" )
72+ dc := oc .AdminDynamicClient ()
73+
74+ // Use Dynamic Client to get BareMetalHost objects
75+ // Note: move this to common.go if this is used in other tests
76+ baremetalGVR := schema.GroupVersionResource {Group : "metal3.io" , Resource : "baremetalhosts" , Version : "v1alpha1" }
77+ baremetalClient := dc .Resource (baremetalGVR ).Namespace ("openshift-machine-api" )
78+
79+ hosts , err := baremetalClient .List (context .Background (), metav1.ListOptions {})
80+ o .Expect (err ).ShouldNot (o .HaveOccurred (), "Expected to retrieve BareMetalHost objects without error" )
81+
82+ // If no BareMetalHost objects exist, skip the test, this is valid for TNF deployments
83+ if len (hosts .Items ) == 0 {
84+ g .Skip ("No BareMetalHost objects found in openshift-machine-api namespace" )
85+ }
86+
87+ // Check each BareMetalHost has operational status set to detached
88+ for _ , host := range hosts .Items {
89+ operationalStatus , found , err := unstructured .NestedString (host .Object , "status" , "operationalStatus" )
90+ o .Expect (err ).ShouldNot (o .HaveOccurred (), fmt .Sprintf ("Expected to parse operational status for BareMetalHost %s without error" , host .GetName ()))
91+ o .Expect (found ).To (o .BeTrue (), fmt .Sprintf ("Expected operational status field to exist for BareMetalHost %s" , host .GetName ()))
92+ o .Expect (operationalStatus ).To (o .Equal ("detached" ),
93+ fmt .Sprintf ("Expected BareMetalHost %s operational status to be 'detached', but found '%s'" , host .GetName (), operationalStatus ))
94+ }
95+ })
96+
4697})
4798
4899var _ = g .Describe ("[sig-etcd][apigroup:config.openshift.io][OCPFeatureGate:DualReplica] Two Node with Fencing" , func () {
0 commit comments