forked from deis/deis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
limits_test.go
49 lines (43 loc) · 1.82 KB
/
limits_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// +build integration
package tests
import (
"strings"
"testing"
"github.com/deis/deis/tests/utils"
)
var (
limitsListCmd = "limits:list --app={{.AppName}}"
limitsSetMemCmd = "limits:set --app={{.AppName}} web=256M"
limitsSetCPUCmd = "limits:set --app={{.AppName}} -c web=512"
limitsUnsetMemCmd = "limits:unset --app={{.AppName}} --memory web"
limitsUnsetCPUCmd = "limits:unset --app={{.AppName}} -c web"
output1 = `(?s)"CpuShares": 512,.*"Memory": 0,`
output2 = `(?s)"CpuShares": 512,.*"Memory": 268435456,`
output3 = `(?s)"CpuShares": 0,.*"Memory": 268435456,`
output4 = `(?s)"CpuShares": 0,.*"Memory": 0,`
)
func limitsSetTest(t *testing.T, cfg *utils.DeisTestConfig, ver int) {
cpuCmd, memCmd := limitsSetCPUCmd, limitsSetMemCmd
// regression test for https://github.com/deis/deis/issues/1563
// previously the client would throw a stack trace with empty limits
utils.Execute(t, limitsListCmd, cfg, false, "Unlimited")
if strings.Contains(cfg.ExampleApp, "dockerfile") {
cpuCmd = strings.Replace(cpuCmd, "web", "cmd", 1)
memCmd = strings.Replace(memCmd, "web", "cmd", 1)
}
utils.Execute(t, cpuCmd, cfg, false, "512")
utils.Execute(t, limitsListCmd, cfg, false, "512")
utils.Execute(t, memCmd, cfg, false, "256M")
utils.Execute(t, limitsListCmd, cfg, false, "256M")
}
func limitsUnsetTest(t *testing.T, cfg *utils.DeisTestConfig, ver int) {
cpuCmd, memCmd := limitsUnsetCPUCmd, limitsUnsetMemCmd
if strings.Contains(cfg.ExampleApp, "dockerfile") {
cpuCmd = strings.Replace(cpuCmd, "web", "cmd", 1)
memCmd = strings.Replace(memCmd, "web", "cmd", 1)
}
utils.Execute(t, cpuCmd, cfg, false, "Unlimited")
utils.Execute(t, limitsListCmd, cfg, false, "Unlimited")
utils.Execute(t, memCmd, cfg, false, "Unlimited")
utils.Execute(t, limitsListCmd, cfg, false, "Unlimited")
}