Skip to content

Commit b9669ac

Browse files
committed
fix: update tests to account for tnf
currently for two node fencing we do not support extra workers, skipping these tests for DualReplica topology updated test to account for correct baremetal operator state during tnf deployments Signed-off-by: ehila <ehila@redhat.com>
1 parent 3521349 commit b9669ac

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

test/extended/baremetal/common.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"strings"
7+
"sync"
78

89
g "github.com/onsi/ginkgo/v2"
910
o "github.com/onsi/gomega"
@@ -16,17 +17,48 @@ import (
1617
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
1718
)
1819

20+
var (
21+
clusterInfraMu sync.Mutex
22+
clusterInfra *configv1.Infrastructure
23+
clusterInfraFetched bool
24+
)
25+
26+
// clusterInfrastructure returns the cluster Infrastructure object. A successful fetch is cached for
27+
// the rest of the process; if Get fails, nothing is cached and the next call retries.
28+
func clusterInfrastructure(oc *exutil.CLI) (*configv1.Infrastructure, error) {
29+
clusterInfraMu.Lock()
30+
defer clusterInfraMu.Unlock()
31+
if clusterInfraFetched {
32+
return clusterInfra, nil
33+
}
34+
infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(
35+
context.Background(), "cluster", metav1.GetOptions{})
36+
if err == nil {
37+
clusterInfra = infra
38+
clusterInfraFetched = true
39+
}
40+
return infra, err
41+
}
42+
1943
func skipIfNotBaremetal(oc *exutil.CLI) {
2044
g.By("checking platform type")
2145

22-
infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(context.Background(), "cluster", metav1.GetOptions{})
46+
infra, err := clusterInfrastructure(oc)
2347
o.Expect(err).NotTo(o.HaveOccurred())
2448

2549
if infra.Status.PlatformStatus.Type != configv1.BareMetalPlatformType {
2650
e2eskipper.Skipf("No baremetal platform detected")
2751
}
2852
}
2953

54+
func skipIfTwoNode(oc *exutil.CLI) {
55+
infra, err := clusterInfrastructure(oc)
56+
o.Expect(err).NotTo(o.HaveOccurred())
57+
if infra.Status.ControlPlaneTopology == configv1.DualReplicaTopologyMode {
58+
e2eskipper.Skipf("This test does not apply to two-node")
59+
}
60+
}
61+
3062
// Starting from 4.10, metal3 resources could be created in the vSphere, OpenStack and None
3163
// Platforms in addition to the Baremetal Platform.
3264
// Starting from 4.12, metal3 resources could be created in the AWS Platform too.
@@ -35,7 +67,7 @@ func skipIfNotBaremetal(oc *exutil.CLI) {
3567
func skipIfUnsupportedPlatformOrConfig(oc *exutil.CLI, dc dynamic.Interface) {
3668
g.By("checking supported platforms")
3769

38-
infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(context.Background(), "cluster", metav1.GetOptions{})
70+
infra, err := clusterInfrastructure(oc)
3971
o.Expect(err).NotTo(o.HaveOccurred())
4072

4173
switch infra.Status.PlatformStatus.Type {

test/extended/baremetal/high_availability.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,20 @@ var _ = g.Describe("[sig-installer][Feature:baremetal][Serial] Baremetal platfor
149149
func checkMetal3DeploymentHealthy(oc *exutil.CLI) {
150150
dc := oc.AdminDynamicClient()
151151
bmc := baremetalClient(dc)
152+
operationalStatus := "OK"
153+
infra, err := clusterInfrastructure(oc)
154+
o.Expect(err).NotTo(o.HaveOccurred())
155+
156+
if infra.Status.ControlPlaneTopology == configv1.DualReplicaTopologyMode {
157+
operationalStatus = "detached"
158+
}
152159

153160
hosts, err := bmc.List(context.Background(), v1.ListOptions{})
154161
o.Expect(err).NotTo(o.HaveOccurred())
155162
o.Expect(hosts.Items).ToNot(o.BeEmpty())
156163

157164
for _, h := range hosts.Items {
158-
expectStringField(h, "baremetalhost", "status.operationalStatus").To(o.BeEquivalentTo("OK"))
165+
expectStringField(h, "baremetalhost", "status.operationalStatus").To(o.BeEquivalentTo(operationalStatus))
159166
expectStringField(h, "baremetalhost", "status.provisioning.state").To(o.Or(o.BeEquivalentTo("provisioned"), o.BeEquivalentTo("externally provisioned")))
160167
expectBoolField(h, "baremetalhost", "spec.online").To(o.BeTrue())
161168
}

test/extended/baremetal/hosts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ var _ = g.Describe("[sig-installer][Feature:baremetal][Serial] Baremetal platfor
165165

166166
g.BeforeEach(func() {
167167
skipIfNotBaremetal(oc)
168+
skipIfTwoNode(oc)
168169
helper = NewBaremetalTestHelper(oc.AdminDynamicClient())
169170
helper.Setup()
170171
})

0 commit comments

Comments
 (0)