Optimize performance of `TestRunSeccompDefaultProfile`
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"regexp" |
| 13 | 13 |
"strconv" |
| 14 | 14 |
"strings" |
| 15 |
+ "sync" |
|
| 15 | 16 |
"time" |
| 16 | 17 |
|
| 17 | 18 |
"github.com/docker/docker/pkg/homedir" |
| ... | ... |
@@ -867,24 +868,46 @@ func (s *DockerSuite) TestRunSeccompAllowAptKey(c *check.C) {
|
| 867 | 867 |
func (s *DockerSuite) TestRunSeccompDefaultProfile(c *check.C) {
|
| 868 | 868 |
testRequires(c, SameHostDaemon, seccompEnabled, NotUserNamespace) |
| 869 | 869 |
|
| 870 |
- out, _, err := dockerCmdWithError("run", "--cap-add", "ALL", "syscall-test", "acct-test")
|
|
| 871 |
- if err == nil || !strings.Contains(out, "Operation not permitted") {
|
|
| 872 |
- c.Fatalf("expected Operation not permitted, got: %s", out)
|
|
| 873 |
- } |
|
| 870 |
+ var group sync.WaitGroup |
|
| 871 |
+ group.Add(4) |
|
| 872 |
+ errChan := make(chan error, 4) |
|
| 873 |
+ go func() {
|
|
| 874 |
+ out, _, err := dockerCmdWithError("run", "--cap-add", "ALL", "syscall-test", "acct-test")
|
|
| 875 |
+ if err == nil || !strings.Contains(out, "Operation not permitted") {
|
|
| 876 |
+ errChan <- fmt.Errorf("expected Operation not permitted, got: %s", out)
|
|
| 877 |
+ } |
|
| 878 |
+ group.Done() |
|
| 879 |
+ }() |
|
| 874 | 880 |
|
| 875 |
- out, _, err = dockerCmdWithError("run", "--cap-add", "ALL", "syscall-test", "ns-test", "echo", "hello")
|
|
| 876 |
- if err == nil || !strings.Contains(out, "Operation not permitted") {
|
|
| 877 |
- c.Fatalf("expected Operation not permitted, got: %s", out)
|
|
| 878 |
- } |
|
| 881 |
+ go func() {
|
|
| 882 |
+ out, _, err := dockerCmdWithError("run", "--cap-add", "ALL", "syscall-test", "ns-test", "echo", "hello")
|
|
| 883 |
+ if err == nil || !strings.Contains(out, "Operation not permitted") {
|
|
| 884 |
+ errChan <- fmt.Errorf("expected Operation not permitted, got: %s", out)
|
|
| 885 |
+ } |
|
| 886 |
+ group.Done() |
|
| 887 |
+ }() |
|
| 879 | 888 |
|
| 880 |
- out, _, err = dockerCmdWithError("run", "--cap-add", "ALL", "--security-opt", "seccomp:unconfined", "syscall-test", "acct-test")
|
|
| 881 |
- if err == nil || !strings.Contains(out, "No such file or directory") {
|
|
| 882 |
- c.Fatalf("expected No such file or directory, got: %s", out)
|
|
| 883 |
- } |
|
| 889 |
+ go func() {
|
|
| 890 |
+ out, _, err := dockerCmdWithError("run", "--cap-add", "ALL", "--security-opt", "seccomp:unconfined", "syscall-test", "acct-test")
|
|
| 891 |
+ if err == nil || !strings.Contains(out, "No such file or directory") {
|
|
| 892 |
+ errChan <- fmt.Errorf("expected No such file or directory, got: %s", out)
|
|
| 893 |
+ } |
|
| 894 |
+ group.Done() |
|
| 895 |
+ }() |
|
| 896 |
+ |
|
| 897 |
+ go func() {
|
|
| 898 |
+ out, _, err := dockerCmdWithError("run", "--cap-add", "ALL", "--security-opt", "seccomp:unconfined", "syscall-test", "ns-test", "echo", "hello")
|
|
| 899 |
+ if err != nil || !strings.Contains(out, "hello") {
|
|
| 900 |
+ errChan <- fmt.Errorf("expected hello, got: %s, %v", out, err)
|
|
| 901 |
+ } |
|
| 902 |
+ group.Done() |
|
| 903 |
+ }() |
|
| 904 |
+ |
|
| 905 |
+ group.Wait() |
|
| 906 |
+ close(errChan) |
|
| 884 | 907 |
|
| 885 |
- out, _, err = dockerCmdWithError("run", "--cap-add", "ALL", "--security-opt", "seccomp:unconfined", "syscall-test", "ns-test", "echo", "hello")
|
|
| 886 |
- if err != nil || !strings.Contains(out, "hello") {
|
|
| 887 |
- c.Fatalf("expected hello, got: %s, %v", out, err)
|
|
| 908 |
+ for err := range errChan {
|
|
| 909 |
+ c.Assert(err, checker.IsNil) |
|
| 888 | 910 |
} |
| 889 | 911 |
} |
| 890 | 912 |
|