Took out os.Remove() for socketPath and pidfilePath now that os.RemoveAll() is used

This commit is contained in:
Michael Cambria 2018-10-08 16:01:31 -04:00
parent 3d349e4645
commit ef913eadd5

View File

@ -41,7 +41,7 @@ import (
) )
func getTmpDir() (string, error) { func getTmpDir() (string, error) {
tmpDir, err := ioutil.TempDir(tmpPrefix, "dhcp") tmpDir, err := ioutil.TempDir(cniDirPrefix, "dhcp")
if err == nil { if err == nil {
tmpDir = filepath.ToSlash(tmpDir) tmpDir = filepath.ToSlash(tmpDir)
} }
@ -108,7 +108,7 @@ const (
hostVethName string = "dhcp0" hostVethName string = "dhcp0"
contVethName string = "eth0" contVethName string = "eth0"
pidfilePath string = "/var/run/cni/dhcp-client.pid" pidfilePath string = "/var/run/cni/dhcp-client.pid"
tmpPrefix = "/run/cni" cniDirPrefix string = "/var/run/cni"
) )
var socketPath string var socketPath string
@ -116,17 +116,10 @@ var tmpDir string
var err error var err error
var _ = BeforeSuite(func() { var _ = BeforeSuite(func() {
os.Remove(socketPath) err := os.MkdirAll(cniDirPrefix, 0700)
os.Remove(pidfilePath)
err := os.MkdirAll(tmpPrefix, 0700)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
var _ = AfterSuite(func() {
os.Remove(socketPath)
os.Remove(pidfilePath)
})
var _ = Describe("DHCP Operations", func() { var _ = Describe("DHCP Operations", func() {
var originalNS, targetNS ns.NetNS var originalNS, targetNS ns.NetNS
var dhcpServerStopCh chan bool var dhcpServerStopCh chan bool
@ -206,7 +199,6 @@ var _ = Describe("DHCP Operations", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
// Start the DHCP client daemon // Start the DHCP client daemon
os.MkdirAll(pidfilePath, 0755)
dhcpPluginPath, err := exec.LookPath("dhcp") dhcpPluginPath, err := exec.LookPath("dhcp")
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
clientCmd = exec.Command(dhcpPluginPath, "daemon", "-socketpath", socketPath) clientCmd = exec.Command(dhcpPluginPath, "daemon", "-socketpath", socketPath)
@ -229,8 +221,6 @@ var _ = Describe("DHCP Operations", func() {
Expect(originalNS.Close()).To(Succeed()) Expect(originalNS.Close()).To(Succeed())
Expect(targetNS.Close()).To(Succeed()) Expect(targetNS.Close()).To(Succeed())
os.Remove(socketPath)
os.Remove(pidfilePath)
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
}) })