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

Function TestVectorDeadlockwithTimeout

query/vector/vector_test.go:529–569  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

527}
528
529func TestVectorDeadlockwithTimeout(t *testing.T) {
530 pred := "vtest1"
531 dc = dgraphtest.NewComposeCluster()
532 var cleanup func()
533 client, cleanup, err := dc.Client()
534 x.Panic(err)
535 defer cleanup()
536
537 for i := 0; i < 5; i++ {
538 fmt.Println("Testing iteration: ", i)
539 ctx, cancel2 := context.WithTimeout(context.Background(), 5*time.Second)
540 defer cancel2()
541 err = client.LoginIntoNamespace(ctx, dgraphapi.DefaultUser,
542 dgraphapi.DefaultPassword, x.RootNamespace)
543 require.NoError(t, err)
544
545 err = client.Alter(context.Background(), &api.Operation{
546 DropAttr: pred,
547 })
548 dropPredicate(pred)
549 setSchema(fmt.Sprintf(vectorSchemaWithIndex, pred, "4", "euclidean"))
550 numVectors := 10000
551 vectorSize := 1000
552
553 randomVectors, _ := generateRandomVectors(numVectors, vectorSize, pred)
554
555 txn := client.NewTxn()
556 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
557 defer func() { _ = txn.Discard(ctx) }()
558 defer cancel()
559
560 _, err = txn.Mutate(ctx, &api.Mutation{
561 SetNquads: []byte(randomVectors),
562 CommitNow: true,
563 })
564 require.Error(t, err)
565
566 err = txn.Commit(ctx)
567 require.Contains(t, err.Error(), "Transaction has already been committed or discarded")
568 }
569}
570
571func TestVectorMutateDiffrentLengthWithDiffrentIndexes(t *testing.T) {
572 dropPredicate("vtest")

Callers

nothing calls this directly

Calls 11

NewComposeClusterFunction · 0.92
PanicFunction · 0.92
cleanupFunction · 0.85
generateRandomVectorsFunction · 0.85
LoginIntoNamespaceMethod · 0.80
AlterMethod · 0.80
dropPredicateFunction · 0.70
setSchemaFunction · 0.70
ClientMethod · 0.65
MutateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected