Skip to content

Commit

Permalink
Fix defaultnetworkfile in unit test
Browse files Browse the repository at this point in the history
rename conf param, 'defaultnetworkfile' to 'readinessindicatorfile'
  • Loading branch information
s1061123 committed May 1, 2024
1 parent 8918802 commit 541a803
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
14 changes: 7 additions & 7 deletions pkg/multus/multus_cni020_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -164,7 +164,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -225,7 +225,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -279,7 +279,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -346,7 +346,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -392,7 +392,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -777,7 +777,7 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down
18 changes: 9 additions & 9 deletions pkg/multus/multus_cni040_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("multus operations cniVersion 0.3.1 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -257,7 +257,7 @@ var _ = Describe("multus operations cniVersion 0.3.1 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -653,7 +653,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -721,7 +721,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -777,7 +777,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -853,7 +853,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -922,7 +922,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -968,7 +968,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -1510,7 +1510,7 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down
16 changes: 8 additions & 8 deletions pkg/multus/multus_cni100_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -210,7 +210,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -266,7 +266,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -331,7 +331,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -407,7 +407,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -476,7 +476,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -522,7 +522,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(fmt.Sprintf(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [%s,%s]
}`, expectedConf1, expectedConf2)),
Expand Down Expand Up @@ -1171,7 +1171,7 @@ var _ = Describe("multus operations cniVersion 1.0.0 config", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down
18 changes: 17 additions & 1 deletion pkg/server/thick_cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ var _ = Describe(suiteName, func() {
containerID = "123456789"
ifaceName = "eth0"
podName = "my-little-pod"
configPath = "/tmp/foo.multus.conf"
)

var (
Expand All @@ -109,6 +110,8 @@ var _ = Describe(suiteName, func() {
BeforeEach(func() {
var err error
K8sClient = fakeK8sClient()
// Touch the default network file.
os.OpenFile(configPath, os.O_RDONLY|os.O_CREATE, 0755)

Expect(FilesystemPreRequirements(thickPluginRunDir)).To(Succeed())

Expand All @@ -126,6 +129,11 @@ var _ = Describe(suiteName, func() {

AfterEach(func() {
cancel()
// Cleanup default network file.
if _, errStat := os.Stat(configPath); errStat == nil {
errRemove := os.Remove(configPath)
Expect(errRemove).NotTo(HaveOccurred())
}
unregisterMetrics(cniServer)
Expect(cniServer.Close()).To(Succeed())
Expect(teardownCNIEnv()).To(Succeed())
Expand All @@ -150,6 +158,7 @@ var _ = Describe(suiteName, func() {
containerID = "123456789"
ifaceName = "eth0"
podName = "my-little-pod"
configPath = "/tmp/foo.multus.conf"
)

var (
Expand All @@ -169,6 +178,8 @@ var _ = Describe(suiteName, func() {
"dummy_key2": "dummy_val2"
}`

// Touch the default network file.
os.OpenFile(configPath, os.O_RDONLY|os.O_CREATE, 0755)
Expect(FilesystemPreRequirements(thickPluginRunDir)).To(Succeed())

ctx, cancel = context.WithCancel(context.TODO())
Expand All @@ -185,6 +196,11 @@ var _ = Describe(suiteName, func() {

AfterEach(func() {
cancel()
// Cleanup default network file.
if _, errStat := os.Stat(configPath); errStat == nil {
errRemove := os.Remove(configPath)
Expect(errRemove).NotTo(HaveOccurred())
}
unregisterMetrics(cniServer)
Expect(cniServer.Close()).To(Succeed())
Expect(teardownCNIEnv()).To(Succeed())
Expand Down Expand Up @@ -286,7 +302,7 @@ func referenceConfig(thickPluginSocketDir string) string {
"name": "node-cni-network",
"type": "multus",
"daemonSocketDir": "%s",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ var _ = Describe("config operations", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down Expand Up @@ -649,7 +649,7 @@ var _ = Describe("config operations", func() {
StdinData: []byte(`{
"name": "node-cni-network",
"type": "multus",
"defaultnetworkfile": "/tmp/foo.multus.conf",
"readinessindicatorfile": "/tmp/foo.multus.conf",
"defaultnetworkwaitseconds": 3,
"delegates": [{
"name": "weave1",
Expand Down

0 comments on commit 541a803

Please sign in to comment.