Commit d7bd43d7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 85e32cdc
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"context" "context"
"fmt" "fmt"
"math" "math"
"reflect"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/transaction" "lab.nexedi.com/kirr/neo/go/transaction"
...@@ -648,7 +649,7 @@ func vOid(xvalue interface{}) (zodb.Oid, error) { ...@@ -648,7 +649,7 @@ func vOid(xvalue interface{}) (zodb.Oid, error) {
// xidOf return string representation of object xid. // xidOf return string representation of object xid.
func xidOf(obj zodb.IPersistent) string { func xidOf(obj zodb.IPersistent) string {
if obj == nil { if obj == nil || reflect.ValueOf(obj).IsNil() {
return "ø" return "ø"
} }
xid := zodb.Xid{At: obj.PJar().At(), Oid: obj.POid()} xid := zodb.Xid{At: obj.PJar().At(), Oid: obj.POid()}
......
...@@ -505,7 +505,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -505,7 +505,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
X := exc.Raiseif X := exc.Raiseif
var kadjTracked SetKey = nil var kadjTracked SetKey = nil
var δT map[Key]Δstring = nil var δT, δTok map[Key]Δstring = nil, nil
// badf queues error message to be reported on return. // badf queues error message to be reported on return.
var badv []string var badv []string
...@@ -515,7 +515,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -515,7 +515,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
defer func() { defer func() {
if badv != nil { if badv != nil {
emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys) emsg := fmt.Sprintf("%s ; tracked=%v :\n\n", subj, initialTrackedKeys)
emsg += fmt.Sprintf("d12: %v\nδT: %v\n\n", d12, δT) emsg += fmt.Sprintf("d12: %v\nδTok: %v\nδT: %v\n\n", d12, δTok, δT)
emsg += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj) emsg += fmt.Sprintf("kadj[Tracked]: %v\nkadj: %v\n\n", kadjTracked, kadj)
emsg += strings.Join(badv, "\n") emsg += strings.Join(badv, "\n")
emsg += "\n" emsg += "\n"
...@@ -570,10 +570,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -570,10 +570,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// k ∈ δT <=> // k ∈ δT <=>
// k ∈ U kadj[·] // k ∈ U kadj[·]
// ·∈tracking // ·∈tracking
inδTOK := SetKey{} // all keys that should be present in δT δTok = map[Key]Δstring{} // d12[all keys that should be present in δT]
for k := range d12 { for k,δv := range d12 {
if kadjTracked.Has(k) { if kadjTracked.Has(k) {
inδTOK.Add(k) δTok[k] = δv
} }
} }
...@@ -589,10 +589,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -589,10 +589,10 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// XXX verify δbtail index consistency against @at2 // XXX verify δbtail index consistency against @at2
// assert δB.ByRoot == {treeRoot -> ...} if inδTOK != ø // assert δB.ByRoot == {treeRoot -> ...} if δTok != ø
// == ø if inδTOK == ø // == ø if δTok == ø
rootsOK := SetOid{} rootsOK := SetOid{}
if len(inδTOK) > 0 { if len(δTok) > 0 {
rootsOK.Add(treeRoot) rootsOK.Add(treeRoot)
} }
roots := SetOid{} roots := SetOid{}
...@@ -600,7 +600,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -600,7 +600,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
roots.Add(root) roots.Add(root)
} }
if !reflect.DeepEqual(roots, rootsOK) { if !reflect.DeepEqual(roots, rootsOK) {
badf("δB: roots != rootsOK ; inδTOK=%v roots=%v rootsOK=%v", inδTOK, roots, rootsOK) badf("δB: roots != rootsOK ; roots=%v rootsOK=%v", roots, rootsOK)
return return
} }
...@@ -618,7 +618,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -618,7 +618,7 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
for _, k := range sortedKeys(δT) { for _, k := range sortedKeys(δT) {
_, ind12 := d12[k] _, ind12 := d12[k]
if !ind12 { if !ind12 {
badf("δT: [%v] is not in d12", k) badf("δT[%v] ∉ d12", k)
} }
} }
...@@ -626,17 +626,18 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid, ...@@ -626,17 +626,18 @@ func xverifyΔBTail1(t *testing.T, subj string, db *zodb.DB, treeRoot zodb.Oid,
// k ∉ tracked set -> may be present in δT (kadj gives exact answer) // k ∉ tracked set -> may be present in δT (kadj gives exact answer)
for _, k := range sortedKeys(d12) { for _, k := range sortedKeys(d12) {
_, inδT := δT[k] _, inδT := δT[k]
if inδT && !inδTOK.Has(k) { _, inδTok := δTok[k]
badf("δT: [%v] is extra", k) if inδT && !inδTok {
badf("δT[%v] ∉ δTok", k)
} }
if !inδT && inδTOK.Has(k) { if !inδT && inδTok {
badf("δT: [%v] is missing", k) badf("δT ∌ δTok[%v]", k)
} }
if inδT { if inδT {
if δT[k] != d12[k] { if δT[k] != d12[k] {
badf("δT[%v] != d12[%v]", k, k) badf("δT[%v] ≠ δTok[%v]", k, k)
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment