Skip to content

Commit d70ecf7

Browse files
Add a rough test for bundle concatenation
Signed-off-by: Dan Jones <[email protected]>
1 parent b5a56e5 commit d70ecf7

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package supportbundle
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
func Test_LoadAndConcatSpec(t *testing.T) {
9+
10+
bundle1doc,err := LoadSupportBundleSpec("test/supportbundle1.yaml")
11+
if err != nil {
12+
t.Error("couldn't load bundle1 from file")
13+
}
14+
15+
bundle2doc,err := LoadSupportBundleSpec("test/supportbundle2.yaml")
16+
if err != nil {
17+
t.Error("couldn't load bundle2 from file")
18+
}
19+
20+
bundle1,err := ParseSupportBundleFromDoc(bundle1doc)
21+
if err != nil {
22+
t.Error("couldn't parse bundle 1")
23+
}
24+
25+
bundle2,err := ParseSupportBundleFromDoc(bundle2doc)
26+
if err != nil {
27+
t.Error("couldn't parse bundle 2")
28+
}
29+
30+
fulldoc,err := LoadSupportBundleSpec("test/completebundle.yaml")
31+
if err != nil {
32+
t.Error("couldn't load full bundle from file")
33+
}
34+
35+
fullbundle,err := ParseSupportBundleFromDoc(fulldoc)
36+
if err != nil {
37+
t.Error("couldn't parse full bundle")
38+
}
39+
40+
bundle3 := ConcatSpec(bundle1,bundle2)
41+
42+
if reflect.DeepEqual(fullbundle, bundle3) == false {
43+
t.Error("Full bundle and concatenated bundle are not the same.")
44+
}
45+
46+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: troubleshoot.sh/v1beta2
2+
kind: SupportBundle
3+
metadata:
4+
name: default
5+
spec:
6+
collectors:
7+
- clusterResources: {}
8+
- clusterInfo: {}
9+
analyzers:
10+
- clusterPodStatuses:
11+
outcomes:
12+
- fail:
13+
when: "!= Healthy"
14+
message: "Status: {{ .Status.Reason }}"
15+
- nodeResources:
16+
checkName: Node status check
17+
outcomes:
18+
- fail:
19+
when: "nodeCondition(Ready) == False"
20+
message: "Not all nodes are online."
21+
- fail:
22+
when: "nodeCondition(Ready) == Unknown"
23+
message: "Not all nodes are online."
24+
- pass:
25+
message: "All nodes are online."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: troubleshoot.sh/v1beta2
2+
kind: SupportBundle
3+
metadata:
4+
name: default
5+
spec:
6+
collectors:
7+
- clusterResources: {}
8+
analyzers:
9+
- clusterPodStatuses:
10+
outcomes:
11+
- fail:
12+
when: "!= Healthy"
13+
message: "Status: {{ .Status.Reason }}"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: troubleshoot.sh/v1beta2
2+
kind: SupportBundle
3+
metadata:
4+
name: default
5+
spec:
6+
collectors:
7+
- clusterInfo: {}
8+
analyzers:
9+
- nodeResources:
10+
checkName: Node status check
11+
outcomes:
12+
- fail:
13+
when: "nodeCondition(Ready) == False"
14+
message: "Not all nodes are online."
15+
- fail:
16+
when: "nodeCondition(Ready) == Unknown"
17+
message: "Not all nodes are online."
18+
- pass:
19+
message: "All nodes are online."

0 commit comments

Comments
 (0)