Skip to content

Commit f6edcc4

Browse files
committed
cfreate the test and add node
1 parent ecc4e71 commit f6edcc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+9349
-790
lines changed

go.mod

+9-11
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ require (
4444
github.com/sirupsen/logrus v1.9.3
4545
github.com/spf13/cobra v1.8.1
4646
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace
47-
github.com/spf13/viper v1.8.1
47+
github.com/spf13/viper v1.13.0
4848
github.com/stretchr/objx v0.5.2
4949
github.com/stretchr/testify v1.9.0
5050
go.etcd.io/etcd/client/pkg/v3 v3.5.14
@@ -56,7 +56,7 @@ require (
5656
golang.org/x/sync v0.8.0
5757
gonum.org/v1/plot v0.14.0
5858
google.golang.org/grpc v1.65.0
59-
gopkg.in/ini.v1 v1.62.0
59+
gopkg.in/ini.v1 v1.67.0
6060
gopkg.in/src-d/go-git.v4 v4.13.1
6161
gopkg.in/yaml.v2 v2.4.0
6262
gopkg.in/yaml.v3 v3.0.1
@@ -173,9 +173,8 @@ require (
173173
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f // indirect
174174
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect
175175
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
176-
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
177176
github.com/gorilla/websocket v1.5.0 // indirect
178-
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
177+
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
179178
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
180179
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
181180
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
@@ -200,12 +199,12 @@ require (
200199
github.com/lestrrat-go/structinfo v0.0.0-20190212233437-acd51874663b // indirect
201200
github.com/libopenstorage/openstorage v1.0.0 // indirect
202201
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
203-
github.com/magiconair/properties v1.8.5 // indirect
202+
github.com/magiconair/properties v1.8.6 // indirect
204203
github.com/mailru/easyjson v0.7.7 // indirect
205204
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
206205
github.com/mitchellh/go-homedir v1.1.0 // indirect
207206
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
208-
github.com/mitchellh/mapstructure v1.4.1 // indirect
207+
github.com/mitchellh/mapstructure v1.5.0 // indirect
209208
github.com/moby/spdystream v0.4.0 // indirect
210209
github.com/moby/sys/mount v0.2.0 // indirect
211210
github.com/moby/sys/mountinfo v0.7.1 // indirect
@@ -218,11 +217,12 @@ require (
218217
github.com/mrunalp/fileutils v0.5.1 // indirect
219218
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
220219
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
221-
github.com/opencontainers/image-spec v1.0.2 // indirect
220+
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
222221
github.com/opencontainers/runc v1.1.13 // indirect
223222
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 // indirect
224223
github.com/opencontainers/selinux v1.11.0 // indirect
225-
github.com/pelletier/go-toml v1.9.3 // indirect
224+
github.com/pelletier/go-toml v1.9.5 // indirect
225+
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
226226
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
227227
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
228228
github.com/pkg/profile v1.7.0 // indirect
@@ -233,21 +233,19 @@ require (
233233
github.com/russross/blackfriday/v2 v2.1.0 // indirect
234234
github.com/seccomp/libseccomp-golang v0.10.0 // indirect
235235
github.com/sergi/go-diff v1.2.0 // indirect
236-
github.com/smartystreets/assertions v1.1.0 // indirect
237236
github.com/soheilhy/cmux v0.1.5 // indirect
238237
github.com/spf13/afero v1.9.2 // indirect
239238
github.com/spf13/cast v1.5.1 // indirect
240239
github.com/spf13/jwalterweatherman v1.1.0 // indirect
241240
github.com/src-d/gcfg v1.4.0 // indirect
242241
github.com/stoewer/go-strcase v1.3.0 // indirect
243-
github.com/subosito/gotenv v1.2.0 // indirect
242+
github.com/subosito/gotenv v1.4.1 // indirect
244243
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
245244
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 // indirect
246245
github.com/vishvananda/netlink v1.1.0 // indirect
247246
github.com/vishvananda/netns v0.0.4 // indirect
248247
github.com/x448/float16 v0.8.4 // indirect
249248
github.com/xanzy/ssh-agent v0.2.1 // indirect
250-
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
251249
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
252250
github.com/xlab/treeprint v1.2.0 // indirect
253251
go.etcd.io/bbolt v1.3.9 // indirect

go.sum

+18-128
Large diffs are not rendered by default.

test/extended/machine_config/ocl.go

+107-9
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,36 @@ package machine_config
22

33
import (
44
"context"
5+
"fmt"
6+
"io/ioutil"
57
"path/filepath"
8+
"time"
69

10+
"github.com/ghodss/yaml"
711
g "github.com/onsi/ginkgo/v2"
812
o "github.com/onsi/gomega"
13+
//e2e "k8s.io/kubernetes/test/e2e/framework"
914

15+
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
16+
//mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
17+
//ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1018
corev1 "k8s.io/api/core/v1"
1119
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1220

21+
mcClient "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
1322
exutil "github.com/openshift/origin/test/extended/util"
23+
24+
"k8s.io/apimachinery/pkg/util/wait"
1425
)
1526

1627
var (
1728
MCOMachineConfigBaseDir = exutil.FixturePath("testdata", "machine_config")
18-
oc = exutil.NewCLIWithoutNamespace("machine-config")
29+
oc = exutil.NewCLIWithoutNamespace("machine-config")
1930
)
2031

2132
var _ = g.BeforeSuite(func() {
2233
inputPullSecretName := "my-input-pull"
23-
ps, err := oc.AsAdmin().AdminKubeClient().CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
34+
ps, err := oc.AsAdmin().AdminKubeClient().CoreV1().Secrets("openshift-config").Get(context.TODO(), "pull-secret", metav1.GetOptions{})
2435
o.Expect(err).NotTo(o.HaveOccurred(), "Get pull-secret from openshift-config")
2536
localInputPullSecret := &corev1.Secret{
2637
ObjectMeta: metav1.ObjectMeta{
@@ -29,14 +40,14 @@ var _ = g.BeforeSuite(func() {
2940
Data: ps.Data,
3041
Type: ps.Type,
3142
}
32-
_, err = oc.KubeClient().CoreV1().Secrets(mcoNamespace).Create(context.Background(), localInputPullSecret, metav1.CreateOptions{})
43+
_, err = oc.KubeClient().CoreV1().Secrets(mcoNamespace).Create(context.TODO(), localInputPullSecret, metav1.CreateOptions{})
3344
o.Expect(err).NotTo(o.HaveOccurred(), "Create my-input-pull secret in openshift-machine-config")
3445

3546
longLivedTokenName := "long-live-token"
3647
serviceAccountName := "builder"
3748
localTokenPullSecret := &corev1.Secret{
3849
ObjectMeta: metav1.ObjectMeta{
39-
Name: longLivedTokenName,
50+
Name: longLivedTokenName,
4051
Namespace: mcoNamespace,
4152
Annotations: map[string]string{
4253
corev1.ServiceAccountNameKey: serviceAccountName,
@@ -53,27 +64,114 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:OnClusterBuild][Serial] Run tests s
5364
defer g.GinkgoRecover()
5465
var (
5566
moscFixture = filepath.Join(MCOMachineConfigBaseDir, "machineosconfigurations", "machineosconfig.yaml")
56-
mcpFixture = filepath.Join(MCOMachineConfigBaseDir, "machineconfigpool", "machineconfigpool.yaml")
67+
mcpFixture = filepath.Join(MCOMachineConfigBaseDir, "machineconfigpool", "machineconfigpool.yaml")
5768
)
5869

5970
g.BeforeEach(func(ctx context.Context) {
6071
//skip this test on single node platforms
61-
72+
6273
//skipOnSingleNodeTopology(oc)
6374
})
6475

6576
g.AfterEach(func() {
6677
// Clear out boot image configuration between tests
67-
78+
6879
//err := oc.Run("apply").Args("-f", noneMachineSetFixture).Execute()
6980
//o.Expect(err).NotTo(o.HaveOccurred())
7081
})
7182

7283
g.It("Should update opted in MCP with the build image from the dockerfile mentioned in MOSC [apigroup:machineconfiguration.openshift.io]", func() {
73-
OneNodePoolOptInTest(oc, moscFixture, mcpFixture)
84+
AllNodePoolOptInTest(oc, moscFixture, mcpFixture)
7485
})
7586

7687
})
7788

78-
func OneNodePoolOptInTest(oc *exutil.CLI, moscfixture string, mcpFixture string) {
89+
func AllNodePoolOptInTest(oc *exutil.CLI, moscFixture string, mcpFixture string) {
90+
91+
err := oc.Run("apply").Args("-f", mcpFixture).Execute()
92+
o.Expect(err).NotTo(o.HaveOccurred(), "Create MCP Infra")
93+
94+
nodes, err := oc.KubeClient().CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
95+
o.Expect(err).NotTo(o.HaveOccurred(), "Get all nodes")
96+
for _, node := range nodes.Items {
97+
err = oc.AsAdmin().Run("label").Args("node", node.Name, "node-role.kubernetes.io/infra="+"").Execute()
98+
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Add node %s to MCP infra", node.Name))
99+
}
100+
err = oc.Run("apply").Args("-f", moscFixture).Execute()
101+
o.Expect(err).NotTo(o.HaveOccurred(), "Create MOSC Infra and opt in Infra pool into OCL")
102+
103+
machineConfigClient, err := mcClient.NewForConfig(oc.KubeFramework().ClientConfig())
104+
o.Expect(err).NotTo(o.HaveOccurred())
105+
106+
mcp, err := getMCPFromFixture(mcpFixture)
107+
o.Expect(err).NotTo(o.HaveOccurred())
108+
109+
waitTime := time.Minute * 20
110+
ctx, cancel := context.WithTimeout(context.Background(), waitTime)
111+
defer cancel()
112+
113+
// Wait for MOSB to be created
114+
err = waitForBuild(ctx, machineConfigClient, mcp)
115+
o.Expect(err).NotTo(o.HaveOccurred(), "Waiting for MOSB to be created and builder pod to Succeed")
116+
117+
// Wait for the build Image to be applied to all nodes
118+
}
119+
120+
func getMCPFromFixture(path string) (*mcfgv1.MachineConfigPool, error) {
121+
data, err := ioutil.ReadFile(path)
122+
if err != nil {
123+
return nil, err
124+
}
125+
126+
mcp := new(mcfgv1.MachineConfigPool)
127+
err = yaml.Unmarshal(data, mcp)
128+
if err != nil {
129+
return nil, err
130+
}
131+
132+
return mcp, err
133+
}
134+
135+
func waitForBuild(ctx context.Context, clientset *mcClient.Clientset, mcp *mcfgv1.MachineConfigPool) error {
136+
return wait.PollUntilContextCancel(ctx, time.Second, true, func(ctx context.Context) (done bool, err error) {
137+
138+
mosbList, err := clientset.MachineconfigurationV1alpha1().MachineOSBuilds().List(ctx, metav1.ListOptions{})
139+
if err != nil {
140+
return false, err
141+
}
142+
/*
143+
isPending := false
144+
isBuilding := false
145+
isSuccess := false
146+
start := time.Now()
147+
*/
148+
for _, mosb := range mosbList.Items {
149+
if mosb.Spec.DesiredConfig.Name == mcp.Spec.Configuration.Name {
150+
/*
151+
state := ctrlcommon.NewMachineOSBuildState(mosb)
152+
153+
if !isPending && state.IsBuildPending() {
154+
isPending = true
155+
e2e.Logf("Build %s is now pending after %s", mosb.Name, time.Since(start))
156+
}
157+
158+
if !isBuilding && state.IsBuilding() {
159+
isBuilding = true
160+
e2e.Logf("Build %s is now running after %s", mosb.Name, time.Since(start))
161+
}
162+
163+
if !isSuccess && state.IsBuildSuccess() {
164+
isSuccess = true
165+
e2e.Logf("Build %s is complete after %s", mosb.Name, time.Since(start))
166+
return true, nil
167+
}
168+
169+
if state.IsBuildFailure() {
170+
return false, fmt.Errorf("build %s failed after %s", mosb.Name, time.Since(start))
171+
}
172+
*/
173+
}
174+
}
175+
return false, nil
176+
})
79177
}

test/extended/testdata/machine_config/machineconfigpool/machineconfigpool.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
oc create -f - << EOF
21
apiVersion: machineconfiguration.openshift.io/v1
32
kind: MachineConfigPool
43
metadata:

vendor/github.com/gregjones/httpcache/.travis.yml

+6-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gregjones/httpcache/README.md

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gregjones/httpcache/httpcache.go

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/magiconair/properties/lex.go

-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/magiconair/properties/parser.go

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/magiconair/properties/properties.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)