Skip to content

Commit

Permalink
fix cgroup unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekchaudhry committed Nov 29, 2022
1 parent 752716c commit 299e532
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions: read-all
jobs:
unit-tests:
name: Linux unit tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
Expand Down
13 changes: 12 additions & 1 deletion agent/api/task/task_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const (
validTaskArn = "arn:aws:ecs:region:account-id:task/task-id"
invalidTaskArn = "invalid:task::arn"

expectedCgroupRoot = "/ecs/task-id"
expectedCgroupV1Root = "/ecs/task-id"
expectedCgroupV2Root = "ecstasks-task-id.slice"

taskVCPULimit = 2.0
taskMemoryLimit = 512
Expand Down Expand Up @@ -81,6 +82,13 @@ var (
scPauseContainerName = fmt.Sprintf(ServiceConnectPauseContainerNameFormat, scContainerName)
)

func getExpectedCgroupRoot() string {
if config.CgroupV2 {
return expectedCgroupV2Root
}
return expectedCgroupV1Root
}

func TestAddNetworkResourceProvisioningDependencyNop(t *testing.T) {
testTask := &Task{
Containers: []*apicontainer.Container{
Expand Down Expand Up @@ -244,6 +252,7 @@ func TestBuildCgroupRootHappyPath(t *testing.T) {
}

cgroupRoot, err := task.BuildCgroupRoot()
expectedCgroupRoot := getExpectedCgroupRoot()

assert.NoError(t, err)
assert.Equal(t, expectedCgroupRoot, cgroupRoot)
Expand Down Expand Up @@ -450,6 +459,7 @@ func TestOverrideCgroupParentHappyPath(t *testing.T) {
}

hostConfig := &dockercontainer.HostConfig{}
expectedCgroupRoot := getExpectedCgroupRoot()

assert.NoError(t, task.overrideCgroupParent(hostConfig))
assert.NotEmpty(t, hostConfig)
Expand Down Expand Up @@ -482,6 +492,7 @@ func TestPlatformHostConfigOverride(t *testing.T) {
}

hostConfig := &dockercontainer.HostConfig{}
expectedCgroupRoot := getExpectedCgroupRoot()

assert.NoError(t, task.platformHostConfigOverride(hostConfig))
assert.NotEmpty(t, hostConfig)
Expand Down

0 comments on commit 299e532

Please sign in to comment.