diff options
author | Kevin Krakauer <krakauer@google.com> | 2020-07-24 15:54:16 -0700 |
---|---|---|
committer | Kevin Krakauer <krakauer@google.com> | 2020-08-10 17:50:01 -0700 |
commit | 805a96d7ba78762a3bb96bb1cc9e32ccc569437a (patch) | |
tree | a31541352b52c28488f979bce3faed50be30f3b4 /test/iptables/runner/main.go | |
parent | 0a8ae4b32f0dbc0b2a84c3f07c8c98e855a8f5fa (diff) |
Speed up iptables tests
//test/iptables:iptables_test runs 30 seconds faster on my machine.
* Using contexts instead of many smaller timeouts makes the tests less
likely to flake and removes unnecessary complexity.
* We also use context to properly shut down concurrent goroutines and
the test container.
* Container logs are always logged.
Diffstat (limited to 'test/iptables/runner/main.go')
-rw-r--r-- | test/iptables/runner/main.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/test/iptables/runner/main.go b/test/iptables/runner/main.go index 69d3ef121..9ae2d1b4d 100644 --- a/test/iptables/runner/main.go +++ b/test/iptables/runner/main.go @@ -16,6 +16,7 @@ package main import ( + "context" "flag" "fmt" "log" @@ -46,7 +47,9 @@ func main() { } // Run the test. - if err := test.ContainerAction(ip, *ipv6); err != nil { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if err := test.ContainerAction(ctx, ip, *ipv6); err != nil { log.Fatalf("Failed running test %q: %v", *name, err) } |