-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Remote flags in containers.conf
Signed-off-by: Daniel J Walsh <[email protected]>
- Loading branch information
Showing
8 changed files
with
339 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,7 @@ func (c *ContainersConfig) validateUlimits() error { | |
} | ||
return nil | ||
} | ||
|
||
func isRemote() bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// +build !remote | ||
|
||
package config | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
|
||
. "github.com/onsi/ginkgo" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Config Local", func() { | ||
BeforeEach(beforeEach) | ||
|
||
It("should fail on invalid NetworkConfigDir", func() { | ||
// Given | ||
tmpfile := path.Join(os.TempDir(), "wrong-file") | ||
file, err := os.Create(tmpfile) | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
file.Close() | ||
defer os.Remove(tmpfile) | ||
sut.Network.NetworkConfigDir = tmpfile | ||
sut.Network.CNIPluginDirs = []string{} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid CNIPluginDirs", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail in validating invalid PluginDir", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).ToNot(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid CNIPluginDirs", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail during runtime", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
tmpDir := path.Join(os.TempDir(), "cni-test") | ||
sut.Network.CNIPluginDirs = []string{tmpDir} | ||
defer os.RemoveAll(tmpDir) | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).ToNot(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid device mode", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"/dev/null:/dev/null:abc"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid first device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"wrong:/dev/null:rw"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid second device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"/dev/null:wrong:rw"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on invalid device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{invalidPath} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on wrong invalid device specification", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"::::"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("should fail on wrong DefaultUlimits", func() { | ||
// Given | ||
sut.Containers.DefaultUlimits = []string{invalidPath} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).NotTo(gomega.BeNil()) | ||
}) | ||
|
||
It("Expect Remote to be False", func() { | ||
// Given | ||
// When | ||
config, err := NewConfig("") | ||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
gomega.Expect(config.Engine.Remote).To(gomega.BeFalse()) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// +build remote | ||
|
||
package config | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Config Remote", func() { | ||
BeforeEach(beforeEach) | ||
|
||
It("should succeed on invalid CNIPluginDirs", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on invalid device mode", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"/dev/null:/dev/null:abc"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on invalid first device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"wrong:/dev/null:rw"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on invalid second device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"/dev/null:wrong:rw"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on invalid device", func() { | ||
// Given | ||
sut.Containers.Devices = []string{invalidPath} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on wrong invalid device specification", func() { | ||
// Given | ||
sut.Containers.Devices = []string{"::::"} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("Expect Remote to be true", func() { | ||
// Given | ||
// When | ||
config, err := NewConfig("") | ||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
gomega.Expect(config.Engine.Remote).To(gomega.BeTrue()) | ||
}) | ||
|
||
It("should succeed on wrong DefaultUlimits", func() { | ||
// Given | ||
sut.Containers.DefaultUlimits = []string{invalidPath} | ||
|
||
// When | ||
err := sut.Containers.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed on invalid CNIPluginDirs", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
It("should succeed in validating invalid PluginDir", func() { | ||
validDirPath, err := ioutil.TempDir("", "config-empty") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer os.RemoveAll(validDirPath) | ||
// Given | ||
sut.Network.NetworkConfigDir = validDirPath | ||
sut.Network.CNIPluginDirs = []string{invalidPath} | ||
|
||
// When | ||
err = sut.Network.Validate() | ||
|
||
// Then | ||
gomega.Expect(err).To(gomega.BeNil()) | ||
}) | ||
|
||
}) |
Oops, something went wrong.