From 5f74a0969fd7173a5be8d719df11b8a2cf9f62c5 Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Fri, 17 Mar 2023 09:26:38 +0100 Subject: [PATCH] Fixed TestHostCgroupNS (#2) testing without github skips after fixing other tests revert Co-authored-by: Tullio Sebastiani --- connector_test.go | 4 ---- tests/common.go | 9 ++++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/connector_test.go b/connector_test.go index eac4cda..97287cf 100644 --- a/connector_test.go +++ b/connector_test.go @@ -307,10 +307,6 @@ func TestPrivateCgroupNs(t *testing.T) { } func TestHostCgroupNs(t *testing.T) { - // get the user cgroup ns - if tests.IsRunningOnGithub() { - t.Skipf("joining host machine cgroup namespace not supported on GitHub actions") - } logger := log.NewTestLogger(t) var wg sync.WaitGroup diff --git a/tests/common.go b/tests/common.go index 3570019..8a0fe2a 100644 --- a/tests/common.go +++ b/tests/common.go @@ -86,13 +86,12 @@ func GetCommmandCgroupNs(logger log.Logger, command string, args []string) strin if err := cmd2.Run(); err != nil { logger.Errorf(err.Error()) } - userCgroupNs = strings.Split(stdout.String(), " ")[10] + stdoutStr:=stdout.String() + regex:=regexp.MustCompile(`.*cgroup:\[(\d+)\]`) + userCgroupNs = regex.ReplaceAllString(stdoutStr,"$1") + userCgroupNs = strings.TrimSuffix(userCgroupNs, "\n") }() wg.Wait() - // removes linux cgroup notation - regex := regexp.MustCompile(`cgroup:\[(\d+)\]`) - userCgroupNs = regex.ReplaceAllString(userCgroupNs, "$1") - userCgroupNs = strings.TrimSuffix(userCgroupNs, "\n") return userCgroupNs }