Describe("Name", func() {
		It("returns the basename of the underlying path", func() {
			ns := namespace.NewNamespace("/var/run/netns/foo")
			Expect(ns.Name()).To(Equal("foo"))

			ns = namespace.NewNamespace("/foo")
			Expect(ns.Name()).To(Equal("foo"))

			ns = namespace.NewNamespace("/foo/bar")
			Expect(ns.Name()).To(Equal("bar"))
		})
	})

	Describe("Open", func() {
		var tempDir string
		var ns namespace.Namespace

		BeforeEach(func() {
			var err error
			tempDir, err = ioutil.TempDir("", "ns")
			Expect(err).NotTo(HaveOccurred())

			nsPath := filepath.Join(tempDir, "namespace")
			nsFile, err := os.Create(nsPath)
			Expect(err).NotTo(HaveOccurred())
			nsFile.Close()

			ns = namespace.NewNamespace(nsPath)
		})

		AfterEach(func() {
Esempio n. 2
0
	Type        string `json:"type"`
	Network     string `json:"network"`
	HostNetwork string `json:"host_network"`
	IPAM        IPAM   `json:"ipam,omitempty"`
}

const vni = 1
const DEFAULT_TIMEOUT = "3s"

var _ = Describe("vxlan", func() {
	var (
		netConfig Config
		session   *gexec.Session

		repoDir       string
		containerID   string
		containerNS   namespace.Namespace
		sandboxNS     namespace.Namespace
		namespaceRepo namespace.Repository

		sandboxRepoDir string
	)

	BeforeEach(func() {
		var err error
		repoDir, err = ioutil.TempDir("", "vxlan")
		Expect(err).NotTo(HaveOccurred())

		namespaceRepo, err = namespace.NewRepository(repoDir)
		Expect(err).NotTo(HaveOccurred())

		containerNS, err = namespaceRepo.Create("container-ns")