Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 5b7785e

Browse files
authored
Merge pull request #830 from grafana/refactor-chaos
Refactor chaos dir to stacktest dir
2 parents c948cad + 337ff41 commit 5b7785e

24 files changed

+462
-312
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- image: circleci/golang:1.10
2626
steps:
2727
- checkout
28-
- run: go test -v -race $(go list ./... | grep -v github.com/grafana/metrictank/chaos)
28+
- run: go test -v -race $(go list ./... | grep -v github.com/grafana/metrictank/stacktest)
2929

3030
qa:
3131
working_directory: /go/src/github.com/grafana/metrictank
@@ -50,7 +50,7 @@ jobs:
5050
at: .
5151
- run: scripts/qa/docs.sh
5252
- run: docker load -i build_docker/metrictank.tar
53-
- run: scripts/qa/end2end.sh
53+
- run: go test -v ./stacktest/tests/end2end_carbon
5454

5555
deploy:
5656
docker:

chaos/ingest.go

-56
This file was deleted.

docker/launch.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ cd $basedir/$env
2626
trap ctrl_c INT
2727

2828
function ctrl_c() {
29+
kill -INT "$child" 2>/dev/null
2930
docker-compose down
3031
}
3132

3233
docker-compose down
3334
../extra/populate-grafana.sh $PWD &
34-
docker-compose up --force-recreate
35+
docker-compose up --force-recreate &
36+
child=$!
37+
wait "$child"

scripts/qa/end2end.sh

-33
This file was deleted.

scripts/qa/generate_test_data.sh

-31
This file was deleted.

scripts/qa/verify_metrics_received.py

-89
This file was deleted.

stacktest/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
here are various go tests that spin up metrictank via a docker stack and assert correct function
2+
3+
see tests directory

chaos/docker.go stacktest/docker/docker.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chaos
1+
package docker
22

33
import (
44
"context"
@@ -7,6 +7,7 @@ import (
77

88
"github.com/docker/docker/api/types"
99
"github.com/docker/docker/client"
10+
"github.com/grafana/metrictank/stacktest/track"
1011
)
1112

1213
var cli *client.Client
@@ -61,27 +62,27 @@ func stop(name string) error {
6162
}
6263
*/
6364

64-
// isolate isolates traffic between containers in setA and containers in setB
65-
func isolate(setA, setB []string, dur string) error {
65+
// Isolate isolates traffic between containers in setA and containers in setB
66+
func Isolate(setA, setB []string, dur string) error {
6667
// note: isolateOut should return very fast (order of ms)
6768
// so we can run all this in serial
6869
for _, a := range setA {
69-
err := isolateOut(a, dur, setB...)
70+
err := IsolateOut(a, dur, setB...)
7071
if err != nil {
7172
return err
7273
}
7374
}
7475
for _, b := range setB {
75-
err := isolateOut(b, dur, setA...)
76+
err := IsolateOut(b, dur, setA...)
7677
if err != nil {
7778
return err
7879
}
7980
}
8081
return nil
8182
}
8283

83-
// isolateOut isolates traffic from the given docker container to all others matching the expression
84-
func isolateOut(name, dur string, targets ...string) error {
84+
// IsolateOut isolates traffic from the given docker container to all others matching the expression
85+
func IsolateOut(name, dur string, targets ...string) error {
8586
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
8687
if err != nil {
8788
return err
@@ -108,7 +109,7 @@ func isolateOut(name, dur string, targets ...string) error {
108109
}
109110

110111
// log all pumba's output
111-
_, err = NewTracker(cmd, false, false, "pumba-stdout", "pumba-stderr")
112+
_, err = track.NewTracker(cmd, false, false, "pumba-stdout", "pumba-stderr")
112113
if err != nil {
113114
return err
114115
}

chaos/path.go stacktest/docker/path.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package chaos
1+
package docker
22

33
import (
44
"os"
@@ -10,7 +10,7 @@ import (
1010

1111
// path takes a relative path within the metrictank repository and returns the full absolute filepath,
1212
// assuming metrictank repo is in the first directory specified in GOPATH
13-
func path(dst string) string {
13+
func Path(dst string) string {
1414
gopath := os.Getenv("GOPATH")
1515
if gopath == "" {
1616
var err error

0 commit comments

Comments
 (0)