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

Function TestVectorDropNamespace

systest/vector/vector_test.go:176–224  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

174}
175
176func TestVectorDropNamespace(t *testing.T) {
177 conf := dgraphtest.NewClusterConfig().WithNumAlphas(1).WithNumZeros(1).WithReplicas(1).WithACL(time.Hour)
178 c, err := dgraphtest.NewLocalCluster(conf)
179 require.NoError(t, err)
180 defer func() { c.Cleanup(t.Failed()) }()
181 require.NoError(t, c.Start())
182
183 gc, cleanup, err := c.Client()
184 require.NoError(t, err)
185 defer cleanup()
186 require.NoError(t, gc.LoginIntoNamespace(context.Background(),
187 dgraphapi.DefaultUser, dgraphapi.DefaultPassword, x.RootNamespace))
188
189 hc, err := c.HTTPClient()
190 require.NoError(t, err)
191 require.NoError(t, hc.LoginIntoNamespace(dgraphapi.DefaultUser,
192 dgraphapi.DefaultPassword, x.RootNamespace))
193
194 numVectors := 500
195 for i := 0; i < 6; i++ {
196 ns, err := hc.AddNamespace()
197 require.NoError(t, err)
198 require.NoError(t, gc.SetupSchema(testSchema))
199 rdfs, vectors := dgraphapi.GenerateRandomVectors(0, numVectors, 100, pred)
200 mu := &api.Mutation{SetNquads: []byte(rdfs), CommitNow: true}
201 _, err = gc.Mutate(mu)
202 require.NoError(t, err)
203
204 query := `{
205 vector(func: has(project_description_v)) {
206 count(uid)
207 }
208 }`
209
210 result, err := gc.Query(query)
211 require.NoError(t, err)
212 require.JSONEq(t, fmt.Sprintf(`{"vector":[{"count":%v}]}`, numVectors), string(result.GetJson()))
213
214 for _, vector := range vectors {
215 similarVectors, err := gc.QueryMultipleVectorsUsingSimilarTo(vector, pred, numVectors)
216 require.NoError(t, err)
217 for _, similarVector := range similarVectors {
218 require.Contains(t, vectors, similarVector)
219 }
220 }
221 _, err = hc.DeleteNamespace(ns)
222 require.NoError(t, err)
223 }
224}
225
226func TestVectorIndexRebuilding(t *testing.T) {
227 conf := dgraphtest.NewClusterConfig().WithNumAlphas(1).WithNumZeros(1).WithReplicas(1).WithACL(time.Hour)

Callers

nothing calls this directly

Calls 15

CleanupMethod · 0.95
StartMethod · 0.95
ClientMethod · 0.95
HTTPClientMethod · 0.95
NewClusterConfigFunction · 0.92
NewLocalClusterFunction · 0.92
GenerateRandomVectorsFunction · 0.92
cleanupFunction · 0.85
WithACLMethod · 0.80
WithReplicasMethod · 0.80
WithNumZerosMethod · 0.80
WithNumAlphasMethod · 0.80

Tested by

no test coverage detected