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