/
log-steps.go
75 lines (55 loc) · 1.72 KB
/
log-steps.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package steps
import (
"fmt"
"strings"
"github.com/ess/jamaica"
"github.com/ess/kennel"
"github.com/ess/mockable"
)
type LogSteps struct{}
func (steps *LogSteps) StepUp(s kennel.Suite) {
s.Step(`^a scaling failure is logged$`, func() error {
found := 0
output := jamaica.LastCommandStdout()
if strings.Contains(output, "FAILURE : Group[mygroup]: Could not be scaled up - Errors occurred while starting servers, please contact support. ") {
found += 1
}
if strings.Contains(output, "FAILURE : Group[mygroup]: Could not be scaled down - Errors occurred while stopping servers, please contact support. ") {
found += 1
}
if found == 0 {
return fmt.Errorf("Failure not found")
}
return nil
})
s.Step(`^a chef failure is logged$`, func() error {
found := 0
output := jamaica.LastCommandStdout()
if strings.Contains(output, "FAILURE : Group[mygroup]: Could not be scaled up - A Chef error occurred while upscaling the group. Please contact support.") {
found += 1
}
if strings.Contains(output, "FAILURE : Group[mygroup]: Could not be scaled down - A Chef error occurred while downscaling the group. Please contact support.") {
found += 1
}
if found == 0 {
return fmt.Errorf("Chef failure not found")
}
return nil
})
s.Step(`^a locking failure is logged$`, func() error {
output := jamaica.LastCommandStdout()
if strings.Contains(output, "FAILURE : Group[mygroup]: Cannot be scaled - Another scaley process has locked the group and may still be in-progress") {
return nil
}
return fmt.Errorf("Locking failure not found")
})
s.BeforeSuite(func() {
mockable.Enable()
})
s.AfterSuite(func() {
mockable.Disable()
})
}
func init() {
kennel.Register(new(LogSteps))
}