github.com/pingcap/chaos@v0.0.0-20190710112158-c86faf4b3719/pkg/control/control_test.go (about) 1 package control 2 3 import ( 4 "context" 5 "os" 6 "testing" 7 "time" 8 9 "github.com/pingcap/chaos/pkg/core" 10 "github.com/pingcap/chaos/pkg/history" 11 "github.com/pingcap/chaos/pkg/verify" 12 ) 13 14 func TestControl(t *testing.T) { 15 t.Log("test can only be run in the chaos docker") 16 17 cfg := &Config{ 18 RequestCount: 10, 19 RunTime: 10 * time.Second, 20 RunRound: 3, 21 DB: "noop", 22 History: "/tmp/chaos/a.log", 23 Nodes: []string{"n1", "n2"}, 24 } 25 26 defer os.Remove("/tmp/chaos/a.log") 27 28 ngs := []core.NemesisGenerator{ 29 core.NoopNemesisGenerator{}, 30 } 31 client := core.NoopClientCreator{} 32 33 verifySuit := verify.Suit{ 34 Model: &core.NoopModel{}, 35 Checker: core.NoopChecker{}, 36 Parser: history.NoopParser{}, 37 } 38 ctx, cancel := context.WithCancel(context.Background()) 39 c := NewController(ctx, cfg, client, ngs, verifySuit) 40 c.Run() 41 c.Close() 42 cancel() 43 }