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

Function TestBulkLoaderNoDqlSchema

systest/integration2/bulk_loader_test.go:125–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func TestBulkLoaderNoDqlSchema(t *testing.T) {
126 conf := dgraphtest.NewClusterConfig().WithNumAlphas(2).WithNumZeros(1).
127 WithACL(time.Hour).WithReplicas(1).WithBulkLoadOutDir(t.TempDir())
128 c, err := dgraphtest.NewLocalCluster(conf)
129 require.NoError(t, err)
130 defer func() { c.Cleanup(t.Failed()) }()
131
132 // start zero
133 require.NoError(t, c.StartZero(0))
134 require.NoError(t, c.HealthCheck(true))
135
136 baseDir := t.TempDir()
137 gqlSchemaFile := filepath.Join(baseDir, "gql.schema")
138 require.NoError(t, os.WriteFile(gqlSchemaFile, []byte(gqlSchema), os.ModePerm))
139 dataFile := filepath.Join(baseDir, "data.json")
140 require.NoError(t, os.WriteFile(dataFile, []byte(jsonData), os.ModePerm))
141
142 opts := dgraphtest.BulkOpts{
143 DataFiles: []string{dataFile},
144 GQLSchemaFiles: []string{gqlSchemaFile},
145 }
146 require.NoError(t, c.BulkLoad(opts))
147
148 // start Alphas
149 require.NoError(t, c.Start())
150
151 // run some queries and ensure everything looks good
152 hc, err := c.HTTPClient()
153 require.NoError(t, err)
154 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser,
155 dgraphapi.DefaultPassword, x.RootNamespace))
156
157 params := dgraphapi.GraphQLParams{
158 Query: `query {
159 getMessage(uniqueId: 3) {
160 content
161 author
162 }
163 }`,
164 }
165 data, err := hc.RunGraphqlQuery(params, false)
166 require.NoError(t, err)
167 dgraphapi.CompareJSON(`{
168 "getMessage": {
169 "content": "DVTCTXCVYI",
170 "author": "USYMVFJYXA"
171 }
172 }`, string(data))
173
174 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser, dgraphapi.DefaultPassword, 1))
175 params = dgraphapi.GraphQLParams{
176 Query: `query {
177 getTemplate(uniqueId: 2) {
178 content
179 }
180 }`,
181 }
182 data, err = hc.RunGraphqlQuery(params, false)

Callers

nothing calls this directly

Calls 15

CleanupMethod · 0.95
StartZeroMethod · 0.95
HealthCheckMethod · 0.95
BulkLoadMethod · 0.95
StartMethod · 0.95
HTTPClientMethod · 0.95
NewClusterConfigFunction · 0.92
NewLocalClusterFunction · 0.92
CompareJSONFunction · 0.92
WithBulkLoadOutDirMethod · 0.80
WithReplicasMethod · 0.80
WithACLMethod · 0.80

Tested by

no test coverage detected