AfterEach(func() {
		os.RemoveAll(dir)
	})

	Describe("PathOf", func() {
		It("returns the full path of a namespace in the repository", func() {
			Expect(repo.PathOf("some-namespace")).To(Equal(filepath.Join(dir, "some-namespace")))
		})
	})

	Describe("Destroy", func() {
		It("removes the namespace bind mount and file and logs the operation", func() {
			ns, err := repo.Create("destroy-ns-test")
			Expect(err).NotTo(HaveOccurred())

			err = repo.Destroy(ns)
			Expect(err).NotTo(HaveOccurred())

			Expect(path.Join(dir, "destroy-ns-test")).NotTo(BeAnExistingFile())
			Expect(logger).To(gbytes.Say("destroy.destroying.*destroy-ns-test"))
		})

		Context("when the namespace is not located within this repository", func() {
			var (
				ns          namespace.Namespace
				anotherRepo namespace.Repository
				repoDir     string
			)

			BeforeEach(func() {
				var err error
		spaceID = fmt.Sprintf("some-space-id-%x", GinkgoParallelNode())
		networkID = spaceID
		containerID = fmt.Sprintf("some-container-id-%x", rand.Int())
		appID = fmt.Sprintf("some-app-id-%x", rand.Int())

		networkMapper := &network.FixedNetworkMapper{DefaultNetworkID: "default"}
		vni, err = networkMapper.GetVNI(spaceID)
		Expect(err).NotTo(HaveOccurred())

		sandboxName = fmt.Sprintf("vni-%d", vni)
	})

	AfterEach(func() {
		session.Interrupt()
		Eventually(session, DEFAULT_TIMEOUT).Should(gexec.Exit(0))
		Expect(containerRepo.Destroy(containerNamespace)).To(Succeed())
	})

	var serverIsAvailable = func() error {
		return VerifyTCPConnection(address)
	}

	Context("ducatid server restarts", func() {
		var (
			upSpec       models.CNIAddPayload
			downSpec     models.CNIDelPayload
			daemonClient *client.DaemonClient
			ipamResult   types.Result
		)

		BeforeEach(func() {
			err = unix.Stat(nsPath, &repoStat)
			Expect(err).NotTo(HaveOccurred())

			var namespaceInode string
			callback := func(_ *os.File) error {
				output, err := exec.Command("stat", "-L", "-c", "%i", "/proc/self/ns/net").CombinedOutput()
				namespaceInode = strings.TrimSpace(string(output))
				return err
			}

			err = ns.Execute(callback)
			Expect(err).NotTo(HaveOccurred())

			Expect(namespaceInode).To(Equal(fmt.Sprintf("%d", repoStat.Ino)))

			err = repo.Destroy(ns)
			Expect(err).NotTo(HaveOccurred())
		})

		It("logs the operation", func() {
			ns, err := repo.Create(name)
			Expect(err).NotTo(HaveOccurred())

			Expect(logger).To(gbytes.Say("create.created.*namespace.*test-ns"))

			err = repo.Destroy(ns)
			Expect(err).NotTo(HaveOccurred())
		})

		It("should not show up in ip netns list", func() {
			nsName := filepath.Base(repoDir)