@@ -19,6 +19,7 @@ package common
19
19
import (
20
20
"context"
21
21
"io/ioutil"
22
+ "math"
22
23
"os"
23
24
"path/filepath"
24
25
"testing"
@@ -42,9 +43,15 @@ type suiteOpts struct {
42
43
gqlSchema string
43
44
rdfs string
44
45
bulkSuite bool
46
+ bulkOpts bulkOpts
45
47
remote bool
46
48
}
47
49
50
+ type bulkOpts struct {
51
+ alpha string
52
+ forceNs uint64
53
+ }
54
+
48
55
func newSuiteInternal (t * testing.T , opts suiteOpts ) * suite {
49
56
if testing .Short () {
50
57
t .Skip ("Skipping system test with long runtime." )
@@ -54,7 +61,6 @@ func newSuiteInternal(t *testing.T, opts suiteOpts) *suite {
54
61
t : t ,
55
62
opts : opts ,
56
63
}
57
-
58
64
require .NoError (s .t , makeDirEmpty (rootDir ))
59
65
rdfFile := filepath .Join (rootDir , "rdfs.rdf" )
60
66
require .NoError (s .t , ioutil .WriteFile (rdfFile , []byte (opts .rdfs ), 0644 ))
@@ -95,6 +101,7 @@ func newBulkOnlySuite(t *testing.T, schema, rdfs, gqlSchema string) *suite {
95
101
gqlSchema : gqlSchema ,
96
102
rdfs : rdfs ,
97
103
bulkSuite : true ,
104
+ bulkOpts : bulkOpts {alpha : "../bulk/alpha.yml" , forceNs : math .MaxUint64 }, // preserve ns
98
105
}
99
106
return newSuiteInternal (t , opts )
100
107
}
@@ -125,10 +132,11 @@ func (s *suite) setup(t *testing.T, schemaFile, rdfFile, gqlSchemaFile string) {
125
132
GQLSchemaFile : gqlSchemaFile ,
126
133
Dir : rootDir ,
127
134
Env : env ,
135
+ Namespace : s .opts .bulkOpts .forceNs ,
128
136
})
129
137
130
138
require .NoError (t , err )
131
- err = testutil .StartAlphas ("../bulk/alpha.yml" )
139
+ err = testutil .StartAlphas (s . opts . bulkOpts . alpha )
132
140
require .NoError (t , err )
133
141
return
134
142
}
@@ -157,7 +165,7 @@ func (s *suite) cleanup(t *testing.T) {
157
165
// NOTE: Shouldn't raise any errors here or fail a test, since this is
158
166
// called when we detect an error (don't want to mask the original problem).
159
167
if s .opts .bulkSuite {
160
- isRace := testutil .StopAlphasAndDetectRace ("../bulk/alpha.yml" )
168
+ isRace := testutil .StopAlphasAndDetectRace (s . opts . bulkOpts . alpha )
161
169
_ = os .RemoveAll (rootDir )
162
170
if isRace {
163
171
t .Fatalf ("Failing because race condition is detected. " +
@@ -188,3 +196,19 @@ func testCase(query, wantResult string) func(*testing.T) {
188
196
testutil .CompareJSON (t , wantResult , string (resp .GetJson ()))
189
197
}
190
198
}
199
+
200
+ func testCaseWithAcl (query , wantResult , user , password string , ns uint64 ) func (* testing.T ) {
201
+ return func (t * testing.T ) {
202
+ // Check results of the bulk loader.
203
+ dg , err := testutil .DgraphClient (testutil .ContainerAddr ("alpha1" , 9080 ))
204
+ require .NoError (t , err )
205
+ ctx2 , cancel2 := context .WithTimeout (context .Background (), time .Minute )
206
+ defer cancel2 ()
207
+ require .NoError (t , dg .LoginIntoNamespace (ctx2 , user , password , ns ))
208
+
209
+ txn := dg .NewTxn ()
210
+ resp , err := txn .Query (ctx2 , query )
211
+ require .NoError (t , err )
212
+ testutil .CompareJSON (t , wantResult , string (resp .GetJson ()))
213
+ }
214
+ }
0 commit comments