This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1872 from hashicorp/aws-ecs-validate-memory-cpu
AWS ECS: validate memory + cpu pairs
- Loading branch information
Showing
5 changed files
with
187 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:bug | ||
serverinstall/ecs: validate memory and cpu values | ||
``` | ||
|
||
```release-note:bug | ||
plugin/aws/ecs: validate memory and cpu values | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestValidateEcsMemCPUPair(t *testing.T) { | ||
// test values based off of | ||
// https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html | ||
// circa July 15, 2021 | ||
|
||
cases := map[string]struct { | ||
mem int | ||
cpu int | ||
shouldErr bool | ||
}{ | ||
"zeros": { | ||
shouldErr: true, | ||
}, | ||
"512/0": { | ||
mem: 512, | ||
}, | ||
"512/256": { | ||
mem: 512, | ||
cpu: 256, | ||
}, | ||
"4096": { | ||
mem: 4096, | ||
}, | ||
"4096/512": { | ||
mem: 4096, | ||
cpu: 512, | ||
}, | ||
"4096/256": { | ||
mem: 4096, | ||
cpu: 256, | ||
shouldErr: true, | ||
}, | ||
"512/512": { | ||
mem: 512, | ||
cpu: 512, | ||
shouldErr: true, | ||
}, | ||
"nonsense": { | ||
mem: 7, | ||
shouldErr: true, | ||
}, | ||
"bad_pair": { | ||
mem: 512, | ||
cpu: 512, | ||
shouldErr: true, | ||
}, | ||
"zero_mem": { | ||
cpu: 7, | ||
shouldErr: true, | ||
}, | ||
} | ||
|
||
for name, c := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
if err := ValidateEcsMemCPUPair(c.mem, c.cpu); err != nil { | ||
if !c.shouldErr { | ||
t.Error(err) | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters