|
1 | 1 | using DistributedFactorGraphs
|
2 | 2 | using IncrementalInference
|
3 | 3 | using Test
|
4 |
| -dfg = LightDFG{SolverParams}() |
5 | 4 |
|
6 | 5 | @testset "FileDFG Tests" begin
|
7 |
| - |
8 |
| - if typeof(dfg) <: CloudGraphsDFG |
9 |
| - @warn "TEST: Nuking all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!" |
10 |
| - clearRobot!!(dfg) |
11 |
| - end |
12 |
| - |
13 |
| - # Same graph as iifInterfaceTests.jl |
14 |
| - numNodes = 10 |
15 |
| - |
16 |
| - #change ready and solvable for x7,x8 for improved tests on x7x8f1 |
17 |
| - verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes) |
18 |
| - #TODO fix this to use accessors |
19 |
| - verts[7].solvable = 1 |
20 |
| - verts[8].solvable = 0 |
21 |
| - getSolverData(verts[8]).solveInProgress = 1 |
22 |
| - setSolvedCount!(verts[1], 5) |
23 |
| - #call update to set it on cloud |
24 |
| - updateVariable!(dfg, verts[7]) |
25 |
| - updateVariable!(dfg, verts[8]) |
26 |
| - |
27 |
| - # Add some bigData to x1, x2 |
28 |
| - addBigDataEntry!(verts[1], GeneralBigDataEntry(:testing, :testing; mimeType="application/nuthin!")) |
29 |
| - addBigDataEntry!(verts[2], FileBigDataEntry(:testing2, "/dev/null")) |
30 |
| - #call update to set it on cloud |
31 |
| - updateVariable!(dfg, verts[1]) |
32 |
| - updateVariable!(dfg, verts[2]) |
33 |
| - |
34 |
| - facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1)) |
35 |
| - |
36 |
| - # Save and load the graph to test. |
37 |
| - saveFolder = "/tmp/fileDFG" |
38 |
| - saveDFG(dfg, saveFolder) |
39 |
| - |
40 |
| - copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg) |
41 |
| - @info "Going to load $saveFolder" |
42 |
| - retDFG = loadDFG(saveFolder*".tar.gz", Main, copyDfg, loaddir="/tmp") |
43 |
| - |
44 |
| - @test issetequal(ls(dfg), ls(retDFG)) |
45 |
| - @test issetequal(lsf(dfg), lsf(retDFG)) |
46 |
| - for var in ls(dfg) |
47 |
| - @test getVariable(dfg, var) == getVariable(retDFG, var) |
| 6 | + for filename in ["/tmp/fileDFG", "/tmp/FileDFGExtension.tar.gz"] |
| 7 | + global dfg |
| 8 | + dfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg) |
| 9 | + |
| 10 | + if typeof(dfg) <: CloudGraphsDFG |
| 11 | + @warn "TEST: Nuking all data for user '$(dfg.userId)', robot '$(dfg.robotId)'!" |
| 12 | + clearRobot!!(dfg) |
| 13 | + end |
| 14 | + |
| 15 | + # Same graph as iifInterfaceTests.jl |
| 16 | + numNodes = 5 |
| 17 | + |
| 18 | + #change ready and solvable for x7,x8 for improved tests on x7x8f1 |
| 19 | + verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:POSE]), 1:numNodes) |
| 20 | + #TODO fix this to use accessors |
| 21 | + verts[3].solvable = 1 |
| 22 | + verts[4].solvable = 0 |
| 23 | + getSolverData(verts[4]).solveInProgress = 1 |
| 24 | + #call update to set it on cloud |
| 25 | + updateVariable!(dfg, verts[3]) |
| 26 | + updateVariable!(dfg, verts[4]) |
| 27 | + |
| 28 | + setSolvedCount!(verts[1], 5) |
| 29 | + # Add some bigData to x1, x2 |
| 30 | + addBigDataEntry!(verts[1], GeneralBigDataEntry(:testing, :testing; mimeType="application/nuthin!")) |
| 31 | + addBigDataEntry!(verts[2], FileBigDataEntry(:testing2, "/dev/null")) |
| 32 | + #call update to set it on cloud |
| 33 | + updateVariable!(dfg, verts[1]) |
| 34 | + updateVariable!(dfg, verts[2]) |
| 35 | + |
| 36 | + facts = map(n -> addFactor!(dfg, [verts[n], verts[n+1]], LinearConditional(Normal(50.0,2.0))), 1:(numNodes-1)) |
| 37 | + |
| 38 | + # Save and load the graph to test. |
| 39 | + saveDFG(dfg, filename) |
| 40 | + |
| 41 | + copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg) |
| 42 | + @info "Going to load $filename" |
| 43 | + retDFG = loadDFG(filename, Main, copyDfg, loaddir="/tmp") |
| 44 | + |
| 45 | + @test issetequal(ls(dfg), ls(retDFG)) |
| 46 | + @test issetequal(lsf(dfg), lsf(retDFG)) |
| 47 | + for var in ls(dfg) |
| 48 | + @test getVariable(dfg, var) == getVariable(retDFG, var) |
| 49 | + end |
| 50 | + for fact in lsf(dfg) |
| 51 | + @test getFactor(dfg, fact) == getFactor(retDFG, fact) |
| 52 | + end |
| 53 | + |
| 54 | + @test length(getBigDataEntries(getVariable(retDFG, :x1))) == 1 |
| 55 | + @test typeof(getBigDataEntry(getVariable(retDFG, :x1),:testing)) == GeneralBigDataEntry |
| 56 | + @test length(getBigDataEntries(getVariable(retDFG, :x2))) == 1 |
| 57 | + @test typeof(getBigDataEntry(getVariable(retDFG, :x2),:testing2)) == FileBigDataEntry |
48 | 58 | end
|
49 |
| - for fact in lsf(dfg) |
50 |
| - @test getFactor(dfg, fact) == getFactor(retDFG, fact) |
51 |
| - end |
52 |
| - |
53 |
| - @test length(getBigDataEntries(getVariable(retDFG, :x1))) == 1 |
54 |
| - @test typeof(getBigDataEntry(getVariable(retDFG, :x1),:testing)) == GeneralBigDataEntry |
55 |
| - @test length(getBigDataEntries(getVariable(retDFG, :x2))) == 1 |
56 |
| - @test typeof(getBigDataEntry(getVariable(retDFG, :x2),:testing2)) == FileBigDataEntry |
57 |
| - |
58 | 59 | end
|
0 commit comments