Skip to content

Commit 0265cf3

Browse files
authored
Merge pull request #625 from JuliaRobotics/3Q20/621_473_filedfg_updates
Additional FileDFG test; fixed CGDFG flag in runtests.jl
2 parents 7a81505 + dc1fa46 commit 0265cf3

File tree

3 files changed

+55
-40
lines changed

3 files changed

+55
-40
lines changed

test/data/0_10_0.tar.gz

1.51 KB
Binary file not shown.

test/fileDFGTests.jl

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,39 @@ using Test
1717
# Same graph as iifInterfaceTests.jl
1818
numNodes = 5
1919

20-
#change ready and solvable for x7,x8 for improved tests on x7x8f1
20+
# Arranging some random data
2121
verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes)
22-
#TODO fix this to use accessors
23-
verts[3].solvable = 1
24-
verts[4].solvable = 0
25-
getSolverData(verts[4]).solveInProgress = 1
26-
#call update to set it on cloud
27-
updateVariable!(dfg, verts[3])
28-
updateVariable!(dfg, verts[4])
22+
map(v -> setSolvable!(v, Int(round(rand()))), verts)
23+
map(v -> getSolverData(verts[4]).solveInProgress=Int(round(rand())), verts)
24+
map(v -> setSolvedCount!(v, Int(round(10*rand()))), verts)
2925

30-
setSolvedCount!(verts[1], 5)
31-
# Add some data entries to x1, x2
26+
# Add some data entries
27+
map(v -> addDataEntry!(v, BlobStoreEntry(:testing, uuid4(), :store, "", "", "", "", now(localzone()))), verts)
28+
map(v -> addDataEntry!(v, BlobStoreEntry(:testing2, uuid4(), :store, "", "", "", "", ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"))), verts)
3229

33-
#FIXME part of broken test at the bottom
34-
# addDataEntry!(verts[1], BlobStoreEntry(:testing, uuid4(), :store, "", "", "", "", now(localzone())))
35-
# addDataEntry!(verts[2], BlobStoreEntry(:testing2, uuid4(), :store, "", "", "", "", now(localzone())))
30+
# Add some PPEs
31+
ppe1 = MeanMaxPPE(:default, [1.0], [0.2], [3.456])
32+
ppe2 = MeanMaxPPE(:other, [1.0], [0.2], [3.456], ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"))
33+
map(v -> addPPE!(dfg, getLabel(v), deepcopy(ppe1)), verts)
34+
map(v -> addPPE!(dfg, getLabel(v), deepcopy(ppe2)), verts)
3635

3736
#call update to set it on cloud
38-
updateVariable!(dfg, verts[1])
39-
updateVariable!(dfg, verts[2])
37+
updateVariable!.(dfg, verts)
4038

41-
facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1))
4239

43-
#FIXME a lot of these makes test fail
44-
# facts[4].solverData.solveInProgress = 1
45-
# facts[4].solverData.multihypo = [1, 0.1, 0.9]
46-
# facts[4].solverData.eliminated = true
47-
# facts[4].solverData.potentialused = true
48-
# updateFactor!(dfg, facts[4])
40+
facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1))
41+
map(f -> setSolvable!(f, Int(round(rand()))), facts)
42+
map(f -> f.solverData.multihypo = [1, 0.1, 0.9], facts)
43+
map(f -> f.solverData.eliminated = rand() > 0.5, facts)
44+
map(f -> f.solverData.potentialused = rand() > 0.5, facts)
45+
updateFactor!.(dfg, facts)
46+
4947
# Save and load the graph to test.
5048
saveDFG(filename, dfg)
5149

52-
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
53-
copyDf2 = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
5450
@info "Going to load $filename"
55-
56-
@test_throws AssertionError loadDFG!(copyDf2,"badfilename")
51+
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
52+
@test_throws AssertionError loadDFG!(DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg),"badfilename")
5753

5854
retDFG = loadDFG!(copyDfg, filename)
5955

@@ -63,19 +59,39 @@ using Test
6359
@test getVariable(dfg, var) == getVariable(retDFG, var)
6460
end
6561
for fact in lsf(dfg)
66-
@test getFactor(dfg, fact) == getFactor(retDFG, fact)
62+
@test compareFactor(getFactor(dfg, fact),
63+
getFactor(retDFG, fact),
64+
skip=[
65+
:hypotheses, :certainhypo, :multihypo, # Multihypo
66+
:eliminated,
67+
:timezone, :zone, # Timezones
68+
:potentialused])
6769
end
68-
69-
if typeof(dfg) <: CloudGraphsDFG
70-
@warn "TODO: BigData still is being setup in CloudGraphs. Fix here!"
71-
else
72-
@test_broken length(getDataEntries(getVariable(retDFG, :x1))) == 1
73-
@test_broken typeof(getDataEntry(getVariable(retDFG, :x1),:testing)) == BlobStoreEntry
74-
@test_broken length(getDataEntries(getVariable(retDFG, :x2))) == 1
75-
@test_broken typeof(getDataEntry(getVariable(retDFG, :x2),:testing2)) == BlobStoreEntry
70+
71+
# Check data entries
72+
for v in ls(dfg)
73+
@test getDataEntries(getVariable(dfg, v)) == getDataEntries(getVariable(retDFG, v))
74+
@test issetequal(listPPEs(dfg, v), listPPEs(retDFG, v))
75+
for ppe in listPPEs(dfg, v)
76+
@test getPPE(dfg, v, ppe) == getPPE(retDFG, v, ppe)
77+
end
7678
end
77-
79+
7880
# test the duplicate order #581
7981
saveDFG(dfg, filename)
8082
end
8183
end
84+
85+
@testset "FileDFG Regression Tests" begin
86+
@info "If any of these tests fail, we have breaking changes"
87+
for file in readdir(joinpath(@__DIR__, "data"))
88+
loadFile = joinpath(@__DIR__, "data", file)
89+
global dfg
90+
dfgCopy = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
91+
retDFG = loadDFG!(dfgCopy, loadFile)
92+
# It should have failed if there were any issues.
93+
# Trivial check as well
94+
@test issetequal(ls(retDFG), [:x1, :x2, :x3, :x4, :x5])
95+
@test issetequal(lsf(retDFG), [:x3x4f1, :x4x5f1, :x1x2f1, :x2x3f1])
96+
end
97+
end

test/runtests.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,15 @@ if get(ENV, "IIF_TEST", "") == "true"
7878

7979
# Switch to our upstream test branch.
8080
Pkg.add(PackageSpec(name="IncrementalInference", rev="upstream/dfg_integration_test"))
81-
# Pkg.add(PackageSpec(name="IncrementalInference", rev="develop"))
8281
@info "------------------------------------------------------------------------"
8382
@info "These tests are using IncrementalInference to do additional driver tests"
8483
@info "------------------------------------------------------------------------"
8584

8685
using IncrementalInference
8786

88-
apis = [LightDFG(solverParams=SolverParams(), userId="testUserId")]
89-
haskey(ENV, "SKIP_CGDFG_TESTS") && ENV["SKIP_CGDFG_TESTS"] != "true" ? push!(apis, CloudGraphsDFG(solverParams=SolverParams(), userId="testUserId") ) : nothing
90-
# GraphsDFG{SolverParams}()
87+
apis = Vector{AbstractDFG}()
88+
push!(apis, LightDFG(solverParams=SolverParams(), userId="testUserId"))
89+
get(ENV, "SKIP_CGDFG_TESTS", "false") != "true" && push!(apis, CloudGraphsDFG(solverParams=SolverParams(), userId="testUserId"))
9190

9291
for api in apis
9392
@testset "Testing Driver: $(typeof(api))" begin

0 commit comments

Comments
 (0)