(m *testing.M)
| 20 | ) |
| 21 | |
| 22 | func TestMain(m *testing.M) { |
| 23 | mutate := func(c dgraphapi.Cluster) { |
| 24 | dg, cleanup, err := c.Client() |
| 25 | x.Panic(err) |
| 26 | defer cleanup() |
| 27 | x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, |
| 28 | dgraphapi.DefaultPassword, x.RootNamespace)) |
| 29 | |
| 30 | client = dg |
| 31 | dc = c |
| 32 | populateCluster(dc) |
| 33 | } |
| 34 | |
| 35 | query := func(c dgraphapi.Cluster) int { |
| 36 | dg, cleanup, err := c.Client() |
| 37 | x.Panic(err) |
| 38 | defer cleanup() |
| 39 | x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphapi.DefaultUser, |
| 40 | dgraphapi.DefaultPassword, x.RootNamespace)) |
| 41 | |
| 42 | client = dg |
| 43 | dc = c |
| 44 | return m.Run() |
| 45 | } |
| 46 | |
| 47 | runTest := func(uc dgraphtest.UpgradeCombo) { |
| 48 | var code int = 2 // it will be set to 0 when tests complete successfully |
| 49 | conf := dgraphtest.NewClusterConfig().WithNumAlphas(1).WithNumZeros(1). |
| 50 | WithReplicas(1).WithACL(time.Hour).WithVersion(uc.Before) |
| 51 | c, err := dgraphtest.NewLocalCluster(conf) |
| 52 | x.Panic(err) |
| 53 | defer func() { c.Cleanup(code != 0) }() |
| 54 | x.Panic(c.Start()) |
| 55 | |
| 56 | hc, err := c.HTTPClient() |
| 57 | x.Panic(err) |
| 58 | x.Panic(hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace)) |
| 59 | |
| 60 | mutate(c) |
| 61 | x.Panic(c.Upgrade(uc.After, uc.Strategy)) |
| 62 | code = query(c) |
| 63 | if code != 0 { |
| 64 | panic(fmt.Sprintf("query upgrade tests failed for [%v -> %v]", uc.Before, uc.After)) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | for _, uc := range dgraphtest.AllUpgradeCombos(false) { |
| 69 | log.Printf("running upgrade tests for confg: %+v", uc) |
| 70 | runTest(uc) |
| 71 | } |
| 72 | } |
nothing calls this directly
no test coverage detected