Skip to content

Commit c3fc2ae

Browse files
committed
tests: sudo not actually required
The legacy example plugin and its libcni backwards_compatibility_test.go just use the noop plugin, which doesn't do anything with the netns path or make any interfaces inside the netns. So we can remove anything netns related from the test, which means we no longer need sudo.
1 parent 6cddc9a commit c3fc2ae

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: go
2-
sudo: required
32
dist: trusty
43

54
go:

pkg/version/legacy_examples/example_runtime.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,8 @@ var V010_Runtime = ExampleRuntime{
150150
import (
151151
"fmt"
152152
"io/ioutil"
153-
"net"
154153
"os"
155154
156-
"github.com/containernetworking/cni/pkg/ns"
157155
"github.com/containernetworking/cni/libcni"
158156
)
159157
@@ -181,19 +179,10 @@ func exec() int {
181179
return 1
182180
}
183181
184-
targetNs, err := ns.NewNS()
185-
if err != nil {
186-
fmt.Printf("Could not create ns: %+v", err)
187-
return 1
188-
}
189-
defer targetNs.Close()
190-
191-
ifName := "eth0"
192-
193182
runtimeConf := &libcni.RuntimeConf{
194183
ContainerID: "some-container-id",
195-
NetNS: targetNs.Path(),
196-
IfName: ifName,
184+
NetNS: "/some/netns/path",
185+
IfName: "eth0",
197186
}
198187
199188
cniConfig := &libcni.CNIConfig{Path: os.Args[1:]}
@@ -223,18 +212,6 @@ func exec() int {
223212
return 5
224213
}
225214
226-
err = targetNs.Do(func(ns.NetNS) error {
227-
_, err := net.InterfaceByName(ifName)
228-
if err == nil {
229-
return fmt.Errorf("interface was not deleted")
230-
}
231-
return nil
232-
})
233-
if err != nil {
234-
fmt.Println(err)
235-
return 6
236-
}
237-
238215
return 0
239216
}
240217
`,

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cd "$(dirname $0)"
66

77
echo -n "Running tests "
88
function testrun {
9-
sudo -E bash -c "umask 0; PATH=$PATH go test $@"
9+
bash -c "umask 0; PATH=$PATH go test $@"
1010
}
1111
if [ ! -z "${COVERALLS:-""}" ]; then
1212
# coverage profile only works per-package

0 commit comments

Comments
 (0)