示例#1
0
文件: noop_test.go 项目: achanda/cni
	)

	const reportResult = `{ "ip4": { "ip": "10.1.2.3/24" }, "dns": {} }`

	BeforeEach(func() {
		debug = &noop_debug.Debug{
			ReportResult:         reportResult,
			ReportVersionSupport: []string{"0.1.0", "0.2.0", "0.3.0"},
		}

		debugFile, err := ioutil.TempFile("", "cni_debug")
		Expect(err).NotTo(HaveOccurred())
		Expect(debugFile.Close()).To(Succeed())
		debugFileName = debugFile.Name()

		Expect(debug.WriteDebug(debugFileName)).To(Succeed())

		cmd = exec.Command(pathToPlugin)
		cmd.Env = []string{
			"CNI_COMMAND=ADD",
			"CNI_CONTAINERID=some-container-id",
			"CNI_ARGS=DEBUG=" + debugFileName,
			"CNI_NETNS=/some/netns/path",
			"CNI_IFNAME=some-eth0",
			"CNI_PATH=/some/bin/path",
		}
		cmd.Stdin = strings.NewReader(`{"some":"stdin-json"}`)
		expectedCmdArgs = skel.CmdArgs{
			ContainerID: "some-container-id",
			Netns:       "/some/netns/path",
			IfName:      "some-eth0",
示例#2
0
文件: api_test.go 项目: tomdee/cni
		netConfig     *libcni.NetworkConfig
		runtimeConfig *libcni.RuntimeConf

		expectedCmdArgs skel.CmdArgs
	)

	BeforeEach(func() {
		debugFile, err := ioutil.TempFile("", "cni_debug")
		Expect(err).NotTo(HaveOccurred())
		Expect(debugFile.Close()).To(Succeed())
		debugFilePath = debugFile.Name()

		debug = &noop_debug.Debug{
			ReportResult: `{ "ip4": { "ip": "10.1.2.3/24" }, "dns": {} }`,
		}
		Expect(debug.WriteDebug(debugFilePath)).To(Succeed())

		cniBinPath = filepath.Dir(pathToPlugin)
		pluginConfig = `{ "type": "noop", "some-key": "some-value" }`
		cniConfig = libcni.CNIConfig{Path: []string{cniBinPath}}
		netConfig = &libcni.NetworkConfig{
			Network: &types.NetConf{
				Type: "noop",
			},
			Bytes: []byte(pluginConfig),
		}
		runtimeConfig = &libcni.RuntimeConf{
			ContainerID: "some-container-id",
			NetNS:       "/some/netns/path",
			IfName:      "some-eth0",
			Args:        [][2]string{[2]string{"DEBUG", debugFilePath}},