Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Chandler <wchandler@gitlab.com>2023-11-09 06:41:58 +0300
committerWill Chandler <wchandler@gitlab.com>2023-11-10 17:57:39 +0300
commitc9cdf8c3bd20f7c9af37dacb4acb0227128f073d (patch)
tree8a8528150bd98a1a482713668db4a91d461bb375
parenteac2abe91d875d4852bacc69fefb33560cfc543f (diff)
cgroups: Unify TestCleanup
Convert the v1 and v2 versions of TestCleanup to a single unified test.
-rw-r--r--internal/cgroups/handler_linux_test.go24
-rw-r--r--internal/cgroups/v1_linux_test.go21
-rw-r--r--internal/cgroups/v2_linux_test.go18
3 files changed, 24 insertions, 39 deletions
diff --git a/internal/cgroups/handler_linux_test.go b/internal/cgroups/handler_linux_test.go
index 9e8b7395c..4f61ab7f6 100644
--- a/internal/cgroups/handler_linux_test.go
+++ b/internal/cgroups/handler_linux_test.go
@@ -328,6 +328,30 @@ func TestAddCommand(t *testing.T) {
}
}
+func TestCleanup(t *testing.T) {
+ for _, version := range []int{1, 2} {
+ t.Run("cgroups-v"+strconv.Itoa(version), func(t *testing.T) {
+ mock := newMock(t, version)
+
+ pid := 1
+ cfg := defaultCgroupsConfig()
+ cfg.Mountpoint = mock.rootPath()
+
+ manager := mock.newCgroupManager(cfg, testhelper.SharedLogger(t), pid)
+ mock.setupMockCgroupFiles(t, manager, []uint{0, 1, 2})
+
+ require.NoError(t, manager.Setup())
+ require.NoError(t, manager.Cleanup())
+
+ for i := uint(0); i < 3; i++ {
+ for _, path := range mock.repoPaths(pid, i) {
+ require.NoDirExists(t, path)
+ }
+ }
+ })
+ }
+}
+
func requireCgroupComponents(t *testing.T, version int, root string, cgroupPath string, expected expectedCgroup) {
t.Helper()
diff --git a/internal/cgroups/v1_linux_test.go b/internal/cgroups/v1_linux_test.go
index 531b42aca..25c835dcf 100644
--- a/internal/cgroups/v1_linux_test.go
+++ b/internal/cgroups/v1_linux_test.go
@@ -33,27 +33,6 @@ func defaultCgroupsConfig() cgroups.Config {
}
}
-func TestCleanup(t *testing.T) {
- mock := newMockV1(t)
-
- pid := 1
- cfg := defaultCgroupsConfig()
- cfg.Mountpoint = mock.root
-
- v1Manager := mock.newCgroupManager(cfg, testhelper.SharedLogger(t), pid)
-
- require.NoError(t, v1Manager.Setup())
- require.NoError(t, v1Manager.Cleanup())
-
- for i := 0; i < 3; i++ {
- memoryPath := filepath.Join(mock.root, "memory", "gitaly", fmt.Sprintf("gitaly-%d", pid), fmt.Sprintf("repos-%d", i))
- cpuPath := filepath.Join(mock.root, "cpu", "gitaly", fmt.Sprintf("gitaly-%d", pid), fmt.Sprintf("repos-%d", i))
-
- require.NoDirExists(t, memoryPath)
- require.NoDirExists(t, cpuPath)
- }
-}
-
func TestMetrics(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/cgroups/v2_linux_test.go b/internal/cgroups/v2_linux_test.go
index f9c5f7bee..f1cb82d28 100644
--- a/internal/cgroups/v2_linux_test.go
+++ b/internal/cgroups/v2_linux_test.go
@@ -33,24 +33,6 @@ func defaultCgroupsV2Config() cgroups.Config {
}
}
-func TestCleanupV2(t *testing.T) {
- mock := newMockV2(t)
-
- pid := 1
- cfg := defaultCgroupsV2Config()
- cfg.Mountpoint = mock.root
-
- v2Manager := mock.newCgroupManager(cfg, testhelper.SharedLogger(t), pid)
- mock.setupMockCgroupFiles(t, v2Manager, []uint{0, 1, 2})
-
- require.NoError(t, v2Manager.Setup())
- require.NoError(t, v2Manager.Cleanup())
-
- for i := 0; i < 3; i++ {
- require.NoDirExists(t, filepath.Join(mock.root, "gitaly", fmt.Sprintf("gitaly-%d", pid), fmt.Sprintf("repos-%d", i)))
- }
-}
-
func TestMetricsV2(t *testing.T) {
tests := []struct {
name string