| 1 | // Copyright 2016 CNI authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package main_testscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/" |
| 19 | "netscip-go gomod github.com/golang/go/src go1.24.2 net/" |
| 20 | "os/execscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/" |
| 21 | "stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/" |
| 22 | |
| 23 | . "github.com/onsi/ginkgo/v2scip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/" |
| 24 | . "github.com/onsi/gomegascip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/" |
| 25 | "github.com/onsi/gomega/gbytesscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gbytes`/" |
| 26 | "github.com/onsi/gomega/gexecscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/" |
| 27 | |
| 28 | "github.com/containernetworking/plugins/pkg/nsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/" |
| 29 | "github.com/containernetworking/plugins/pkg/testutilsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/" |
| 30 | ) |
| 31 | |
| 32 | func generateConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/generateConfig().(cniVersion string) *stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.Readerscip-go gomod github.com/golang/go/src go1.24.2 strings/Reader# { |
| 33 | return stringsscip-go gomod github.com/golang/go/src go1.24.2 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.24.2 strings/NewReader().(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().(`{ "name": "loopback-test", "cniVersion": "%s" }`, cniVersion)) |
| 34 | } |
| 35 | |
| 36 | var _ = Describescip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Describe().("Loopback", func() { |
| 37 | var ( |
| 38 | networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS. nsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/.NetNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS# |
| 39 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command. *execscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/.Cmdscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Cmd# |
| 40 | environscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:environ. []string |
| 41 | ) |
| 42 | |
| 43 | BeforeEachscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/BeforeEach().(func() { |
| 44 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command. = execscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/.Commandscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Command().(pathToLoPluginscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/pathToLoPlugin.) |
| 45 | |
| 46 | var errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. error |
| 47 | networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS., errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. = testutilsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/.NewNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/NewNS().() |
| 48 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err.).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 49 | |
| 50 | environscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:environ. = []string{ |
| 51 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_CONTAINERID=%s", "dummy"), |
| 52 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_NETNS=%s", networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS..Pathscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#Path.()), |
| 53 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_IFNAME=%s", "lo"), |
| 54 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_ARGS=%s", "none"), |
| 55 | fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_PATH=%s", "/some/test/path"), |
| 56 | } |
| 57 | }) |
| 58 | |
| 59 | AfterEachscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/AfterEach().(func() { |
| 60 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS..Closescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#Close.()).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Succeedscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Succeed().()) |
| 61 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(testutilsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/.UnmountNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/UnmountNS().(networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS.)).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Succeedscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Succeed().()) |
| 62 | }) |
| 63 | |
| 64 | for _, ver := range testutilsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/.AllSpecVersionsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/testutils`/AllSpecVersions. { |
| 65 | // Redefine ver inside for scope so real value is picked up by each dynamically defined It() |
| 66 | // See Gingkgo's "Patterns for dynamically generating tests" documentation. |
| 67 | ver := ver |
| 68 | |
| 69 | Contextscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Context.("when given a network namespace", func() { |
| 70 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("[%s] sets the lo device to UP", ver), func() { |
| 71 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command..Stdinscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Cmd#Stdin. = generateConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/generateConfig().(ver) |
| 72 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command..Envscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Cmd#Env. = append(environscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:environ., fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_COMMAND=%s", "ADD")) |
| 73 | |
| 74 | session, err := gexecscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/.Startscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/Start().(commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command., GinkgoWriterscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/GinkgoWriter., GinkgoWriterscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/GinkgoWriter.) |
| 75 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 76 | |
| 77 | // "(?s)" turns on the "s" flag, making "." match newlines too. |
| 78 | Eventuallyscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Eventually().(session).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/AsyncAssertion#Should().(gbytesscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gbytes`/.Sayscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gbytes`/Say().(`(?s){.*}`)) |
| 79 | Eventuallyscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Eventually().(session).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/AsyncAssertion#Should().(gexecscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/.Exitscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/Exit().(0)) |
| 80 | |
| 81 | var loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo. *netscip-go gomod github.com/golang/go/src go1.24.2 net/.Interfacescip-go gomod github.com/golang/go/src go1.24.2 net/Interface# |
| 82 | err = networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS..Doscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#Do.(func(nsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/.NetNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#) error { |
| 83 | var errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. error |
| 84 | loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo., errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. = netscip-go gomod github.com/golang/go/src go1.24.2 net/.InterfaceByNamescip-go gomod github.com/golang/go/src go1.24.2 net/InterfaceByName().("lo") |
| 85 | return errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. |
| 86 | }) |
| 87 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 88 | |
| 89 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo..Flagsscip-go gomod github.com/golang/go/src go1.24.2 net/Interface#Flags. & netscip-go gomod github.com/golang/go/src go1.24.2 net/.FlagUpscip-go gomod github.com/golang/go/src go1.24.2 net/FlagUp.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(netscip-go gomod github.com/golang/go/src go1.24.2 net/.FlagUpscip-go gomod github.com/golang/go/src go1.24.2 net/FlagUp.)) |
| 90 | }) |
| 91 | |
| 92 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().(fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("[%s] sets the lo device to DOWN", ver), func() { |
| 93 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command..Stdinscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Cmd#Stdin. = generateConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/generateConfig().(ver) |
| 94 | commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command..Envscip-go gomod github.com/golang/go/src go1.24.2 `os/exec`/Cmd#Env. = append(environscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:environ., fmtscip-go gomod github.com/golang/go/src go1.24.2 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.2 fmt/Sprintf().("CNI_COMMAND=%s", "DEL")) |
| 95 | |
| 96 | session, err := gexecscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/.Startscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/Start().(commandscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:command., GinkgoWriterscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/GinkgoWriter., GinkgoWriterscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/GinkgoWriter.) |
| 97 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 98 | |
| 99 | Eventuallyscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Eventually().(session).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/AsyncAssertion#Should().(gbytesscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gbytes`/.Sayscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gbytes`/Say().(``)) |
| 100 | Eventuallyscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Eventually().(session).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/AsyncAssertion#Should().(gexecscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/.Exitscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/gexec`/Exit().(0)) |
| 101 | |
| 102 | var loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo. *netscip-go gomod github.com/golang/go/src go1.24.2 net/.Interfacescip-go gomod github.com/golang/go/src go1.24.2 net/Interface# |
| 103 | err = networkNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:networkNS..Doscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#Do.(func(nsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/.NetNSscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/pkg/ns`/NetNS#) error { |
| 104 | var errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. error |
| 105 | loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo., errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. = netscip-go gomod github.com/golang/go/src go1.24.2 net/.InterfaceByNamescip-go gomod github.com/golang/go/src go1.24.2 net/InterfaceByName().("lo") |
| 106 | return errscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:err. |
| 107 | }) |
| 108 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 109 | |
| 110 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(loscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/main/loopback_test`/_:lo..Flagsscip-go gomod github.com/golang/go/src go1.24.2 net/Interface#Flags. & netscip-go gomod github.com/golang/go/src go1.24.2 net/.FlagUpscip-go gomod github.com/golang/go/src go1.24.2 net/FlagUp.).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(netscip-go gomod github.com/golang/go/src go1.24.2 net/.FlagUpscip-go gomod github.com/golang/go/src go1.24.2 net/FlagUp.)) |
| 111 | }) |
| 112 | }) |
| 113 | } |
| 114 | }) |