Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
biopet.biopet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Mirrors
biopet.biopet
Commits
f3963eee
Commit
f3963eee
authored
Mar 02, 2017
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a lot of testing to summaryDB
parent
5c5cb42d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
218 additions
and
2 deletions
+218
-2
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
...cala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
+1
-1
biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
.../nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
+217
-1
No files found.
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDb.scala
View file @
f3963eee
...
...
@@ -414,7 +414,7 @@ class SummaryDb(val db: Database) extends Closeable {
}
/** Returns all [[Files]] with the given criteria */
def
getFiles
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]],
def
getFiles
(
runId
:
Option
[
Int
]
=
None
,
pipeline
:
Option
[
Either
[
Int
,
String
]]
=
None
,
module
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
sample
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
library
:
Option
[
Option
[
Either
[
Int
,
String
]]]
=
None
,
key
:
Option
[
String
]
=
None
)
:
Future
[
Seq
[
Schema.File
]]
=
{
db
.
run
(
filesFilter
(
runId
,
pipeline
,
module
,
sample
,
library
,
key
).
result
)
...
...
biopet-utils/src/test/scala/nl/lumc/sasc/biopet/utils/summary/db/SummaryDbTest.scala
View file @
f3963eee
...
...
@@ -15,6 +15,116 @@ import scala.concurrent.duration.Duration
*/
class
SummaryDbTest
extends
TestNGSuite
with
Matchers
{
@Test
def
testRuns
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
date
=
new
Date
(
System
.
currentTimeMillis
())
Await
.
result
(
db
.
getRuns
(),
Duration
.
Inf
)
shouldBe
empty
val
runId
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
Await
.
result
(
db
.
getRuns
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Run
(
runId
,
"name"
,
"dir"
,
"version"
,
"hash"
,
date
))
val
runId2
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
Await
.
result
(
db
.
getRuns
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Run
(
runId
,
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Schema
.
Run
(
runId2
,
"name"
,
"dir"
,
"version"
,
"hash"
,
date
))
db
.
close
()
}
@Test
def
testSamples
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
date
=
new
Date
(
System
.
currentTimeMillis
())
val
runId
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
Await
.
result
(
db
.
getSamples
(),
Duration
.
Inf
)
shouldBe
empty
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
runId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getSamples
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Sample
(
sampleId
,
"test_sample"
,
runId
,
None
))
Await
.
result
(
db
.
getSampleName
(
sampleId
),
Duration
.
Inf
)
shouldBe
Some
(
"test_sample"
)
Await
.
result
(
db
.
getSampleId
(
runId
,
"test_sample"
),
Duration
.
Inf
)
shouldBe
Some
(
sampleId
)
Await
.
result
(
db
.
getSampleTags
(
sampleId
),
Duration
.
Inf
)
shouldBe
None
val
sampleId2
=
Await
.
result
(
db
.
createSample
(
"test_sample2"
,
runId
,
Some
(
"""{"test": "test"}"""
)),
Duration
.
Inf
)
Await
.
result
(
db
.
getSampleTags
(
sampleId2
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"test"
->
"test"
))
Await
.
result
(
db
.
getSamples
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Sample
(
sampleId
,
"test_sample"
,
runId
,
None
),
Schema
.
Sample
(
sampleId2
,
"test_sample2"
,
runId
,
Some
(
"""{"test": "test"}"""
)))
db
.
close
()
}
@Test
def
testLibraries
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
date
=
new
Date
(
System
.
currentTimeMillis
())
val
runId
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
runId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getLibraries
(),
Duration
.
Inf
)
shouldBe
empty
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_lib"
,
runId
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getLibraries
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Library
(
libraryId
,
"test_lib"
,
runId
,
sampleId
,
None
))
Await
.
result
(
db
.
getLibraryName
(
libraryId
),
Duration
.
Inf
)
shouldBe
Some
(
"test_lib"
)
Await
.
result
(
db
.
getLibraryId
(
runId
,
sampleId
,
"test_lib"
),
Duration
.
Inf
)
shouldBe
Some
(
libraryId
)
Await
.
result
(
db
.
getLibraryTags
(
sampleId
),
Duration
.
Inf
)
shouldBe
None
val
sampleId2
=
Await
.
result
(
db
.
createLibrary
(
"test_lib2"
,
runId
,
sampleId
,
Some
(
"""{"test": "test"}"""
)),
Duration
.
Inf
)
Await
.
result
(
db
.
getLibraryTags
(
sampleId2
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"test"
->
"test"
))
Await
.
result
(
db
.
getLibraries
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Library
(
sampleId
,
"test_lib"
,
runId
,
sampleId
,
None
),
Schema
.
Library
(
sampleId2
,
"test_lib2"
,
runId
,
sampleId
,
Some
(
"""{"test": "test"}"""
)))
db
.
close
()
}
@Test
def
testPipelines
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
date
=
new
Date
(
System
.
currentTimeMillis
())
val
runId
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
Await
.
result
(
db
.
getPipelines
(),
Duration
.
Inf
)
shouldBe
empty
val
pipelineId
=
Await
.
result
(
db
.
createPipeline
(
"test"
,
runId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getPipelines
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Pipeline
(
pipelineId
,
"test"
,
runId
))
Await
.
result
(
db
.
getPipelineId
(
runId
,
"test"
),
Duration
.
Inf
)
shouldBe
Some
(
pipelineId
)
Await
.
result
(
db
.
createPipeline
(
"test"
,
runId
),
Duration
.
Inf
)
shouldBe
pipelineId
Await
.
result
(
db
.
getPipelines
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Pipeline
(
pipelineId
,
"test"
,
runId
))
db
.
close
()
}
@Test
def
testModules
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
date
=
new
Date
(
System
.
currentTimeMillis
())
val
runId
=
Await
.
result
(
db
.
createRun
(
"name"
,
"dir"
,
"version"
,
"hash"
,
date
),
Duration
.
Inf
)
val
pipelineId
=
Await
.
result
(
db
.
createPipeline
(
"test"
,
runId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getModules
(),
Duration
.
Inf
)
shouldBe
empty
val
moduleId
=
Await
.
result
(
db
.
createModule
(
"test"
,
runId
,
pipelineId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getmoduleId
(
runId
,
"test"
,
pipelineId
),
Duration
.
Inf
)
shouldBe
Some
(
moduleId
)
Await
.
result
(
db
.
getModules
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Module
(
pipelineId
,
"test"
,
runId
,
pipelineId
))
Await
.
result
(
db
.
createModule
(
"test"
,
runId
,
pipelineId
),
Duration
.
Inf
)
shouldBe
pipelineId
Await
.
result
(
db
.
getModules
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
Module
(
pipelineId
,
"test"
,
runId
,
pipelineId
))
db
.
close
()
}
@Test
def
testSettings
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
...
...
@@ -23,13 +133,85 @@ class SummaryDbTest extends TestNGSuite with Matchers {
db
.
createTables
()
Await
.
result
(
db
.
createOrUpdateSetting
(
0
,
0
,
None
,
None
,
None
,
"""{"content": "test" }"""
),
Duration
.
Inf
)
val
bla
=
Await
.
result
(
db
.
getSettings
(
Some
(
0
)),
Duration
.
Inf
)
Await
.
result
(
db
.
getSetting
(
0
,
Left
(
0
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test"
))
Await
.
result
(
db
.
createOrUpdateSetting
(
0
,
0
,
None
,
None
,
None
,
"""{"content": "test2" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getSetting
(
0
,
Left
(
0
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test2"
))
db
.
close
()
}
@Test
def
testSettingKeys
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
Await
.
result
(
db
.
createOrUpdateSetting
(
0
,
0
,
Some
(
0
),
Some
(
0
),
Some
(
0
),
"""
|{
|"content": "test",
|"content2": {
| "key": "value"
|}
| }"""
.
stripMargin
),
Duration
.
Inf
)
db
.
getSettingKeys
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
keyValues
=
Map
())
shouldBe
Map
()
db
.
getSettingKeys
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
keyValues
=
Map
(
"content"
->
List
(
"content"
)))
shouldBe
Map
(
"content"
->
Some
(
"test"
))
db
.
getSettingKeys
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
Some
(
Left
(
0
)),
keyValues
=
Map
(
"content"
->
List
(
"content2"
,
"key"
)))
shouldBe
Map
(
"content"
->
Some
(
"value"
))
db
.
close
()
}
@Test
def
testSettingsForSamples
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
0
),
Duration
.
Inf
)
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_library"
,
0
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
createOrUpdateSetting
(
0
,
0
,
Some
(
0
),
Some
(
sampleId
),
None
,
"""
|{
|"content": "test",
|"content2": {
| "key": "value"
|}
| }"""
.
stripMargin
),
Duration
.
Inf
)
db
.
getSettingsForSamples
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
keyValues
=
Map
())
shouldBe
Map
(
0
->
Map
())
db
.
getSettingsForSamples
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
keyValues
=
Map
(
"content"
->
List
(
"content"
)))
shouldBe
Map
(
0
->
Map
(
"content"
->
Some
(
"test"
)))
db
.
close
()
}
@Test
def
testSettingsForLibraries
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
0
),
Duration
.
Inf
)
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_library"
,
0
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
createOrUpdateSetting
(
0
,
0
,
Some
(
0
),
Some
(
sampleId
),
Some
(
libraryId
),
"""
|{
|"content": "test",
|"content2": {
| "key": "value"
|}
| }"""
.
stripMargin
),
Duration
.
Inf
)
db
.
getSettingsForLibraries
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
keyValues
=
Map
())
shouldBe
Map
((
0
,
0
)
->
Map
())
db
.
getSettingsForLibraries
(
0
,
Left
(
0
),
Some
(
Left
(
0
)),
keyValues
=
Map
(
"content"
->
List
(
"content"
)))
shouldBe
Map
((
0
,
0
)
->
Map
(
"content"
->
Some
(
"test"
)))
db
.
close
()
}
@Test
def
testStats
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
...
...
@@ -43,14 +225,19 @@ class SummaryDbTest extends TestNGSuite with Matchers {
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
runId
),
Duration
.
Inf
)
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_library"
,
runId
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStatsSize
(),
Duration
.
Inf
)
shouldBe
0
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
None
,
None
,
None
,
"""{"content": "test" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test"
))
Await
.
result
(
db
.
getStatsSize
(),
Duration
.
Inf
)
shouldBe
1
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
None
,
None
,
None
,
"""{"content": "test2" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test2"
))
Await
.
result
(
db
.
getStatsSize
(),
Duration
.
Inf
)
shouldBe
1
// Test join queries
Await
.
result
(
db
.
createOrUpdateStat
(
runId
,
pipelineId
,
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libraryId
),
"""{"content": "test3" }"""
),
Duration
.
Inf
)
Await
.
result
(
db
.
getStat
(
runId
,
Right
(
"test_pipeline"
),
Some
(
Right
(
"test_module"
)),
Some
(
Right
(
"test_sample"
)),
Some
(
Right
(
"test_library"
))),
Duration
.
Inf
)
shouldBe
Some
(
Map
(
"content"
->
"test3"
))
Await
.
result
(
db
.
getStatsSize
(),
Duration
.
Inf
)
shouldBe
2
db
.
close
()
}
...
...
@@ -128,6 +315,35 @@ class SummaryDbTest extends TestNGSuite with Matchers {
db
.
close
()
}
@Test
def
testFiles
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
dbFile
.
deleteOnExit
()
val
db
=
SummaryDb
.
openSqliteSummary
(
dbFile
)
db
.
createTables
()
val
runId
=
Await
.
result
(
db
.
createRun
(
"test"
,
""
,
""
,
""
,
new
Date
(
System
.
currentTimeMillis
())),
Duration
.
Inf
)
val
pipelineId
=
Await
.
result
(
db
.
createPipeline
(
"test_pipeline"
,
runId
),
Duration
.
Inf
)
val
moduleId
=
Await
.
result
(
db
.
createModule
(
"test_module"
,
runId
,
pipelineId
),
Duration
.
Inf
)
val
sampleId
=
Await
.
result
(
db
.
createSample
(
"test_sample"
,
runId
),
Duration
.
Inf
)
val
libraryId
=
Await
.
result
(
db
.
createLibrary
(
"test_library"
,
runId
,
sampleId
),
Duration
.
Inf
)
Await
.
result
(
db
.
createOrUpdateFile
(
runId
,
pipelineId
,
None
,
None
,
None
,
"key"
,
"path"
,
"md5"
,
false
,
1
),
Duration
.
Inf
)
Await
.
result
(
db
.
getFile
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
,
"key"
),
Duration
.
Inf
)
shouldBe
Some
(
Schema
.
File
(
0
,
0
,
None
,
None
,
None
,
"key"
,
"path"
,
"md5"
,
false
,
1
))
Await
.
result
(
db
.
getFiles
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
File
(
0
,
0
,
None
,
None
,
None
,
"key"
,
"path"
,
"md5"
,
false
,
1
))
Await
.
result
(
db
.
createOrUpdateFile
(
runId
,
pipelineId
,
None
,
None
,
None
,
"key"
,
"path2"
,
"md5"
,
false
,
1
),
Duration
.
Inf
)
Await
.
result
(
db
.
getFile
(
runId
,
Left
(
pipelineId
),
None
,
None
,
None
,
"key"
),
Duration
.
Inf
)
shouldBe
Some
(
Schema
.
File
(
0
,
0
,
None
,
None
,
None
,
"key"
,
"path2"
,
"md5"
,
false
,
1
))
Await
.
result
(
db
.
getFiles
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
File
(
0
,
0
,
None
,
None
,
None
,
"key"
,
"path2"
,
"md5"
,
false
,
1
))
// Test join queries
Await
.
result
(
db
.
createOrUpdateFile
(
runId
,
pipelineId
,
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libraryId
),
"key"
,
"path3"
,
"md5"
,
false
,
1
),
Duration
.
Inf
)
Await
.
result
(
db
.
getFile
(
runId
,
Right
(
"test_pipeline"
),
Some
(
Right
(
"test_module"
)),
Some
(
Right
(
"test_sample"
)),
Some
(
Right
(
"test_library"
)),
"key"
),
Duration
.
Inf
)
shouldBe
Some
(
Schema
.
File
(
0
,
0
,
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libraryId
),
"key"
,
"path3"
,
"md5"
,
false
,
1
))
Await
.
result
(
db
.
getFiles
(),
Duration
.
Inf
)
shouldBe
Seq
(
Schema
.
File
(
0
,
0
,
None
,
None
,
None
,
"key"
,
"path2"
,
"md5"
,
false
,
1
),
Schema
.
File
(
0
,
0
,
Some
(
moduleId
),
Some
(
sampleId
),
Some
(
libraryId
),
"key"
,
"path3"
,
"md5"
,
false
,
1
))
db
.
close
()
}
@Test
def
testExecutable
:
Unit
=
{
val
dbFile
=
File
.
createTempFile
(
"summary."
,
".db"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment