@@ -117,13 +117,14 @@ func TestStartSnapshotStreamForSingleNode(t *testing.T) {
117117 require .NoError (t , gc .Login (context .Background (),
118118 dgraphapi .DefaultUser , dgraphapi .DefaultPassword ))
119119
120- pubPort , err := c .GetAlphaGrpcPublicPort ()
120+ url , err := c .GetAlphaGrpcEndpoint (0 )
121+ require .NoError (t , err )
122+ dg , err := newClient (url , grpc .WithTransportCredentials (insecure .NewCredentials ()))
121123 require .NoError (t , err )
122- client , err := NewClient (dgraphtest .GetLocalHostUrl (pubPort , "" ), grpc .WithTransportCredentials (insecure .NewCredentials ()))
123124
124125 require .NoError (t , err )
125126
126- resp , err := client . StartSnapshotStream (context .Background ())
127+ resp , err := startSnapshotStream (context .Background (), dg )
127128 require .NoError (t , err )
128129
129130 require .Equal (t , len (resp .Groups ), 1 )
@@ -141,12 +142,12 @@ func TestStartSnapshotStreamForHA(t *testing.T) {
141142 defer func () { c .Cleanup (t .Failed ()) }()
142143 require .NoError (t , c .Start ())
143144
144- pubPort , err := c .GetAlphaGrpcPublicPort ( )
145+ url , err := c .GetAlphaGrpcEndpoint ( 0 )
145146 require .NoError (t , err )
146- client , err := NewClient ( dgraphtest . GetLocalHostUrl ( pubPort , "" ) , grpc .WithTransportCredentials (insecure .NewCredentials ()))
147+ dg , err := newClient ( url , grpc .WithTransportCredentials (insecure .NewCredentials ()))
147148 require .NoError (t , err )
148149
149- resp , err := client . StartSnapshotStream (context .Background ())
150+ resp , err := startSnapshotStream (context .Background (), dg )
150151 require .NoError (t , err )
151152
152153 require .Equal (t , len (resp .Groups ), 1 )
@@ -169,13 +170,12 @@ func TestStartSnapshotStreamForHASharded(t *testing.T) {
169170 defer func () { c .Cleanup (t .Failed ()) }()
170171 require .NoError (t , c .Start ())
171172
172- pubPort , err := c .GetAlphaGrpcPublicPort ( )
173+ url , err := c .GetAlphaGrpcEndpoint ( 0 )
173174 require .NoError (t , err )
174- client , err := NewClient (dgraphtest .GetLocalHostUrl (pubPort , "" ),
175- grpc .WithTransportCredentials (insecure .NewCredentials ()))
175+ dg , err := newClient (url , grpc .WithTransportCredentials (insecure .NewCredentials ()))
176176 require .NoError (t , err )
177177
178- resp , err := client . StartSnapshotStream (context .Background ())
178+ resp , err := startSnapshotStream (context .Background (), dg )
179179 require .NoError (t , err )
180180 require .Equal (t , len (resp .Groups ), 2 )
181181
@@ -217,18 +217,11 @@ func runImportTest(t *testing.T, bulkAlphas, targetAlphas, replicasFactor int) {
217217 defer func () { targetCluster .Cleanup (t .Failed ()) }()
218218 defer gcCleanup ()
219219
220- importClient , err := createImportClient (t , targetCluster )
221- require .NoError (t , err )
222-
223- resp , err := importClient .StartSnapshotStream (context .Background ())
220+ url , err := targetCluster .GetAlphaGrpcEndpoint (0 )
224221 require .NoError (t , err )
225-
226- _ , err = gc .Query ("schema{}" )
227- require .Error (t , err )
228- require .ErrorContains (t , err , "the server is in draining mode" )
229-
230222 outDir := filepath .Join (baseDir , "out" )
231- err = importClient .SendSnapshot (context .Background (), outDir , resp .Groups )
223+
224+ err = Import (context .Background (), url , grpc .WithTransportCredentials (insecure .NewCredentials ()), outDir )
232225 require .NoError (t , err )
233226
234227 verifyImportResults (t , gc )
@@ -246,17 +239,13 @@ func setupBulkCluster(t *testing.T, numAlphas int) (*dgraphtest.LocalCluster, st
246239 cluster , err := dgraphtest .NewLocalCluster (bulkConf )
247240 require .NoError (t , err )
248241
249- // Download and prepare data files
250- dataPath , err := dgraphtest .DownloadDataFiles ()
251- require .NoError (t , err )
252242 require .NoError (t , cluster .StartZero (0 ))
253243
254244 // Perform bulk load
255- schemaFile := filepath .Join (dataPath , "1million.schema" )
256- rdfFile := filepath .Join (dataPath , "1million.rdf.gz" )
245+ oneMillion := dgraphtest .GetDataset (dgraphtest .OneMillionDataset )
257246 opts := dgraphtest.BulkOpts {
258- DataFiles : []string {rdfFile },
259- SchemaFiles : []string {schemaFile },
247+ DataFiles : []string {oneMillion . DataFilePath () },
248+ SchemaFiles : []string {oneMillion . SchemaPath () },
260249 OutDir : filepath .Join (baseDir , "out" ),
261250 }
262251 require .NoError (t , cluster .BulkLoad (opts ))
@@ -282,15 +271,6 @@ func setupTargetCluster(t *testing.T, numAlphas, replicasFactor int) (*dgraphtes
282271 return cluster , gc , cleanup
283272}
284273
285- // createImportClient creates a new client for import operations
286- func createImportClient (t * testing.T , cluster * dgraphtest.LocalCluster ) (* Client , error ) {
287- pubPort , err := cluster .GetAlphaGrpcPublicPort ()
288- require .NoError (t , err )
289-
290- return NewClient (dgraphtest .GetLocalHostUrl (pubPort , "" ),
291- grpc .WithTransportCredentials (insecure .NewCredentials ()))
292- }
293-
294274// verifyImportResults validates the result of an import operation
295275func verifyImportResults (t * testing.T , gc * dgraphapi.GrpcClient ) {
296276 // Check schema after streaming process
0 commit comments