MCPcopy
hub / github.com/dgraph-io/dgraph / TestMain

Function TestMain

query/upgrade_test.go:22–72  ·  view source on GitHub ↗
(m *testing.M)

Source from the content-addressed store, hash-verified

20)
21
22func 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}

Callers

nothing calls this directly

Calls 15

ClientMethod · 0.95
CleanupMethod · 0.95
StartMethod · 0.95
HTTPClientMethod · 0.95
UpgradeMethod · 0.95
PanicFunction · 0.92
NewClusterConfigFunction · 0.92
NewLocalClusterFunction · 0.92
AllUpgradeCombosFunction · 0.92
cleanupFunction · 0.85
LoginIntoNamespaceMethod · 0.80
WithVersionMethod · 0.80

Tested by

no test coverage detected