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

Refactor chaos dir to stacktest dir #830

Merged
merged 15 commits into from
Apr 11, 2018
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- image: circleci/golang:1.10
steps:
- checkout
- run: go test -v -race $(go list ./... | grep -v github.com/grafana/metrictank/chaos)
- run: go test -v -race $(go list ./... | grep -v github.com/grafana/metrictank/stacktest)

qa:
working_directory: /go/src/github.com/grafana/metrictank
Expand All @@ -50,7 +50,7 @@ jobs:
at: .
- run: scripts/qa/docs.sh
- run: docker load -i build_docker/metrictank.tar
- run: scripts/qa/end2end.sh
- run: go test -v ./stacktest/tests/end2end_carbon

deploy:
docker:
Expand Down
56 changes: 0 additions & 56 deletions chaos/ingest.go

This file was deleted.

5 changes: 4 additions & 1 deletion docker/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ cd $basedir/$env
trap ctrl_c INT

function ctrl_c() {
kill -INT "$child" 2>/dev/null
docker-compose down
}

docker-compose down
../extra/populate-grafana.sh $PWD &
docker-compose up --force-recreate
docker-compose up --force-recreate &
child=$!
wait "$child"
33 changes: 0 additions & 33 deletions scripts/qa/end2end.sh

This file was deleted.

31 changes: 0 additions & 31 deletions scripts/qa/generate_test_data.sh

This file was deleted.

89 changes: 0 additions & 89 deletions scripts/qa/verify_metrics_received.py

This file was deleted.

3 changes: 3 additions & 0 deletions stacktest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
here are various go tests that spin up metrictank via a docker stack and assert correct function

see tests directory
17 changes: 9 additions & 8 deletions chaos/docker.go → stacktest/docker/docker.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chaos
package docker

import (
"context"
Expand All @@ -7,6 +7,7 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/grafana/metrictank/stacktest/track"
)

var cli *client.Client
Expand Down Expand Up @@ -61,27 +62,27 @@ func stop(name string) error {
}
*/

// isolate isolates traffic between containers in setA and containers in setB
func isolate(setA, setB []string, dur string) error {
// Isolate isolates traffic between containers in setA and containers in setB
func Isolate(setA, setB []string, dur string) error {
// note: isolateOut should return very fast (order of ms)
// so we can run all this in serial
for _, a := range setA {
err := isolateOut(a, dur, setB...)
err := IsolateOut(a, dur, setB...)
if err != nil {
return err
}
}
for _, b := range setB {
err := isolateOut(b, dur, setA...)
err := IsolateOut(b, dur, setA...)
if err != nil {
return err
}
}
return nil
}

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

// log all pumba's output
_, err = NewTracker(cmd, false, false, "pumba-stdout", "pumba-stderr")
_, err = track.NewTracker(cmd, false, false, "pumba-stdout", "pumba-stderr")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions chaos/path.go → stacktest/docker/path.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chaos
package docker

import (
"os"
Expand All @@ -10,7 +10,7 @@ import (

// path takes a relative path within the metrictank repository and returns the full absolute filepath,
// assuming metrictank repo is in the first directory specified in GOPATH
func path(dst string) string {
func Path(dst string) string {
gopath := os.Getenv("GOPATH")
if gopath == "" {
var err error
Expand Down
Loading