コード例 #1
0
ファイル: livereplica_test.go プロジェクト: subnr01/epaxos
// This function tests the equality of two replicas'log
// for Instance[row]
func livetestlibLogCmpForTwo(t *testing.T, a, b *replica.Replica, row int) bool {
	if a.Size != b.Size {
		t.Fatal("Replica size not equal, this shouldn't happen")
	}

	end := b.MaxInstanceNum[row]
	if a.MaxInstanceNum[row] > b.MaxInstanceNum[row] {
		end = a.MaxInstanceNum[row]
	}

	for i := 0; i < int(end); i++ {
		if a.IsCheckpoint(uint64(i)) {
			continue
		}

		if a.InstanceMatrix[row][i] == nil {
			t.Logf("WARNING: Instance doesn't exist for replica[%d]:Instance[%d][%d]",
				a.Id, row, i)
		}

		if b.InstanceMatrix[row][i] == nil {
			t.Logf("WARNING: Instance doesn't exist for replica[%d]:Instance[%d][%d]",
				b.Id, row, i)
		}

		if a.InstanceMatrix[row][i].StatusString() != "Committed" {
			t.Logf("WARNING: Instance is not committed for replica[%d]:Instance[%d][%d]",
				a.Id, row, i)
		}

		if b.InstanceMatrix[row][i].StatusString() != "Committed" {
			t.Logf("WARNING: Instance is not committed for replica[%d]:Instance[%d][%d]",
				b.Id, row, i)
		}

		ca := a.InstanceMatrix[row][i].Commands()
		cb := b.InstanceMatrix[row][i].Commands()
		if !reflect.DeepEqual(ca, cb) {
			t.Logf("Cmds are not equal for replica[%d]:Instance[%d][%d] and replica[%d]:Instance[%d][%d]\n",
				a.Id, row, i, b.Id, row, i)
			t.Logf("%v, %v\n", ca, cb)
			return false
		}

		da := a.InstanceMatrix[row][i].Dependencies()
		db := b.InstanceMatrix[row][i].Dependencies()
		if !reflect.DeepEqual(da, db) {
			t.Logf("Deps are not equal for replica[%d]:Instance[%d][%d] and replica[%d]:Instance[%d][%d]\n",
				a.Id, row, i, b.Id, row, i)
			t.Logf("%v, %v\n", da, db)
			return false
		}
	}
	return true
}
コード例 #2
0
ファイル: livereplica_test.go プロジェクト: subnr01/epaxos
// This func tests if the log has correctly record the conflicts
// return true if dep[row] == instanceId or dep[row] is a checkpoint
// r is just for check if instanceId is a checkpoint
func liveTestlibHaveConflicts(r *replica.Replica, deps message.Dependencies, row int, instanceId uint64) bool {
	if deps[row] == instanceId || r.IsCheckpoint(deps[row]) {
		return true
	}
	return false
}