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

Function TestDeleteSetWithVarEdgeCorruptsData

worker/sort_test.go:93–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestDeleteSetWithVarEdgeCorruptsData(t *testing.T) {
94 // Setup temporary directory for Badger DB
95 dir, err := os.MkdirTemp("", "storetest_")
96 require.NoError(t, err)
97 defer os.RemoveAll(dir)
98
99 opt := badger.DefaultOptions(dir)
100 ps, err := badger.OpenManaged(opt)
101 require.NoError(t, err)
102 posting.Init(ps, 0, false)
103 Init(ps)
104
105 // Set schema
106 schemaTxt := `
107 room: string @index(hash) @upsert .
108 person: string @index(hash) @upsert .
109 office: uid @reverse @count .
110 `
111 err = schema.ParseBytes([]byte(schemaTxt), 1)
112 require.NoError(t, err)
113
114 ctx := context.Background()
115 attrRoom := x.AttrInRootNamespace("room")
116 attrPerson := x.AttrInRootNamespace("person")
117 attrOffice := x.AttrInRootNamespace("office")
118
119 uidRoom := uint64(1)
120 uidJohn := uint64(2)
121
122 runMutation := func(startTs, commitTs uint64, edges []*pb.DirectedEdge) {
123 txn := posting.Oracle().RegisterStartTs(startTs)
124 for _, edge := range edges {
125 require.NoError(t, runMutation(ctx, edge, txn))
126 }
127 txn.Update()
128 writer := posting.NewTxnWriter(ps)
129 require.NoError(t, txn.CommitToDisk(writer, commitTs))
130 require.NoError(t, writer.Flush())
131 txn.UpdateCachedKeys(commitTs)
132 }
133
134 // Initial mutation: Set John → Leopard
135 runMutation(1, 3, []*pb.DirectedEdge{
136 {
137 Entity: uidJohn,
138 Attr: attrPerson,
139 Value: []byte("John Smith"),
140 ValueType: pb.Posting_STRING,
141 Op: pb.DirectedEdge_SET,
142 },
143 {
144 Entity: uidRoom,
145 Attr: attrRoom,
146 Value: []byte("Leopard"),
147 ValueType: pb.Posting_STRING,
148 Op: pb.DirectedEdge_SET,
149 },
150 {

Callers

nothing calls this directly

Calls 15

FlushMethod · 0.95
InitFunction · 0.92
ParseBytesFunction · 0.92
AttrInRootNamespaceFunction · 0.92
OracleFunction · 0.92
NewTxnWriterFunction · 0.92
DataKeyFunction · 0.92
ReverseKeyFunction · 0.92
rollupFunction · 0.85
RemoveAllMethod · 0.80
RegisterStartTsMethod · 0.80
CommitToDiskMethod · 0.80

Tested by

no test coverage detected