Skip to content

Commit 03efd05

Browse files
committed
Add new tests for baremetal platform
1 parent 2581158 commit 03efd05

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

test/extended/baremetal/hosts.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package baremetal
2+
3+
import (
4+
"context"
5+
6+
g "github.com/onsi/ginkgo"
7+
o "github.com/onsi/gomega"
8+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
10+
"k8s.io/apimachinery/pkg/runtime/schema"
11+
"k8s.io/client-go/dynamic"
12+
e2e "k8s.io/kubernetes/test/e2e/framework"
13+
14+
configv1 "github.com/openshift/api/config/v1"
15+
exutil "github.com/openshift/origin/test/extended/util"
16+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17+
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
18+
)
19+
20+
func skipIfNotBaremetal(oc *exutil.CLI) {
21+
g.By("checking platform type")
22+
23+
infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get(context.Background(), "cluster", metav1.GetOptions{})
24+
o.Expect(err).NotTo(o.HaveOccurred())
25+
26+
if infra.Status.Platform != configv1.BareMetalPlatformType {
27+
e2eskipper.Skipf("No baremetal platform detected")
28+
}
29+
}
30+
31+
func baremetalClient(dc dynamic.Interface) dynamic.ResourceInterface {
32+
baremetalClient := dc.Resource(schema.GroupVersionResource{Group: "metal3.io", Resource: "baremetalhosts", Version: "v1alpha1"})
33+
return baremetalClient.Namespace("openshift-machine-api")
34+
}
35+
36+
var _ = g.Describe("[sig-cluster-lifecycle][Feature:baremetal] Baremetal platform should", func() {
37+
defer g.GinkgoRecover()
38+
39+
oc := exutil.NewCLI("baremetal")
40+
41+
g.It("have a metal3 deployment", func() {
42+
skipIfNotBaremetal(oc)
43+
44+
c, err := e2e.LoadClientset()
45+
o.Expect(err).ToNot(o.HaveOccurred())
46+
47+
_, err = c.AppsV1().Deployments("openshift-machine-api").Get(context.Background(), "metal3", metav1.GetOptions{})
48+
o.Expect(err).NotTo(o.HaveOccurred())
49+
})
50+
51+
g.It("have baremetalhost resources", func() {
52+
skipIfNotBaremetal(oc)
53+
54+
dc := oc.AdminDynamicClient()
55+
bmc := baremetalClient(dc)
56+
57+
hosts, err := bmc.List(context.Background(), v1.ListOptions{})
58+
o.Expect(err).NotTo(o.HaveOccurred())
59+
o.Expect(hosts.Items).ToNot(o.BeEmpty())
60+
61+
for _, h := range hosts.Items {
62+
status, found, err := unstructured.NestedString(h.Object, "status", "operationalStatus")
63+
o.Expect(err).NotTo(o.HaveOccurred())
64+
o.Expect(found).To(o.BeTrue(), "baremetalhost not ready")
65+
o.Expect(status).To(o.BeEquivalentTo("OK"))
66+
}
67+
})
68+
})

test/extended/include.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
_ "github.com/openshift/origin/test/extended/authentication"
1111
_ "github.com/openshift/origin/test/extended/authorization"
1212
_ "github.com/openshift/origin/test/extended/authorization/rbac"
13+
_ "github.com/openshift/origin/test/extended/baremetal"
1314
_ "github.com/openshift/origin/test/extended/bootstrap_user"
1415
_ "github.com/openshift/origin/test/extended/builds"
1516
_ "github.com/openshift/origin/test/extended/cli"

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.

0 commit comments

Comments
 (0)