Skip to content

Commit 8f5e2c1

Browse files
committed
iteration with env var for test env[ci skip]
1 parent 989a344 commit 8f5e2c1

File tree

8 files changed

+27
-35
lines changed

8 files changed

+27
-35
lines changed

plugins/nf-nomad/src/main/nextflow/nomad/builders/JobBuilder.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ class JobBuilder {
107107

108108
static protected Resources getResources(TaskRun task) {
109109
final DEFAULT_CPUS = 1
110-
final DEFAULT_MEMORY = "500.MB"
110+
final DEFAULT_MEMORY = "1.GB"
111111

112112
final taskCfg = task.getConfig()
113113
final taskCores = !taskCfg.get("cpus") ? DEFAULT_CPUS : taskCfg.get("cpus") as Integer
114-
final taskMemory = taskCfg.get("memory") ? new MemoryUnit( taskCfg.get("memory") as String ) : new MemoryUnit(DEFAULT_MEMORY)
114+
final taskMemory = !taskCfg.get("memory") ? new MemoryUnit(DEFAULT_MEMORY) : new MemoryUnit( taskCfg.get("memory") as String )
115115

116116
final res = new Resources()
117117
.cores(taskCores)
@@ -313,4 +313,4 @@ class JobBuilder {
313313
}
314314

315315

316-
}
316+
}

plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,6 @@ class NomadService implements Closeable{
136136

137137

138138

139-
String getJobStatus(String jobId){
140-
try {
141-
Job job = safeExecutor.apply {
142-
jobsApi.getJob(jobId, config.jobOpts().region, config.jobOpts().namespace,
143-
null, null, null, null, null, null, null)
144-
}
145-
log.debug "[NOMAD] getJobStatus jobID=$job.ID; status=$job.status"
146-
job.status
147-
}catch (Exception e){
148-
log.debug("[NOMAD] getJobStatus Failed to get jobState ${jobId} -- Cause: ${e.message ?: e}", e)
149-
"unknown"
150-
}
151-
}
152-
153139
void kill(String jobId) {
154140
purgeJob(jobId, false)
155141
}

plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/MockNomadDSLSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import okhttp3.mockwebserver.MockWebServer
2828
import okhttp3.mockwebserver.RecordedRequest
2929
import org.jetbrains.annotations.NotNull
3030
import org.pf4j.PluginDescriptorFinder
31+
import spock.lang.Requires
3132
import spock.lang.Shared
3233
import spock.lang.Timeout
3334
import test.Dsl2Spec
@@ -43,7 +44,8 @@ import java.util.jar.Manifest
4344
* @author : Jorge Aguilera <[email protected]>
4445
*/
4546
@Timeout(60)
46-
class NomadDSLSpec extends Dsl2Spec{
47+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
48+
class MockNomadDSLSpec extends Dsl2Spec{
4749
@Shared String pluginsMode
4850

4951
MockWebServer mockWebServer

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadSecretServiceSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/executor/MockNomadSecretServiceSpec.groovy

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,23 @@
1616
*/
1717
package nextflow.nomad.executor
1818

19-
import groovy.json.JsonOutput
20-
import groovy.json.JsonSlurper
21-
import nextflow.executor.Executor
19+
2220
import nextflow.nomad.config.NomadConfig
23-
import nextflow.processor.TaskBean
24-
import nextflow.processor.TaskConfig
25-
import nextflow.processor.TaskProcessor
26-
import nextflow.processor.TaskRun
27-
import nextflow.script.ProcessConfig
2821
import okhttp3.mockwebserver.MockResponse
2922
import okhttp3.mockwebserver.MockWebServer
23+
import spock.lang.Requires
3024
import spock.lang.Specification
3125

32-
import java.nio.file.Files
33-
import java.nio.file.Path
34-
3526
/**
3627
* Unit test for Nomad Service for Secrets requests
3728
*
3829
* Validate requests using a Mock WebServer
3930
*
4031
* @author : Jorge Aguilera <[email protected]>
4132
*/
42-
class NomadSecretServiceSpec extends Specification{
33+
34+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
35+
class MockNomadSecretServiceSpec extends Specification{
4336

4437
MockWebServer mockWebServer
4538

@@ -90,6 +83,7 @@ class NomadSecretServiceSpec extends Specification{
9083
recordedRequest2.path == "/v1/var/another%2FMySecret"
9184
}
9285

86+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
9387
void "should set a variable"(){
9488
given:
9589
def config = new NomadConfig(

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/executor/MockNomadServiceSpec.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import nextflow.processor.TaskRun
2727
import nextflow.script.ProcessConfig
2828
import okhttp3.mockwebserver.MockResponse
2929
import okhttp3.mockwebserver.MockWebServer
30+
import spock.lang.Requires
3031
import spock.lang.Specification
3132

3233
import java.nio.file.Files
@@ -39,7 +40,9 @@ import java.nio.file.Path
3940
*
4041
* @author : Jorge Aguilera <[email protected]>
4142
*/
42-
class NomadServiceSpec extends Specification{
43+
44+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
45+
class MockNomadServiceSpec extends Specification{
4346

4447
MockWebServer mockWebServer
4548

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadTaskHandlerSpec.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import java.nio.file.Path
3232
*
3333
* @author : Jorge Aguilera <[email protected]>
3434
*/
35+
3536
class NomadTaskHandlerSpec extends Specification{
3637

3738
void "a task should have a container"(){

plugins/nf-nomad/src/test/nextflow/nomad/models/JobConstraintsSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/models/MockJobConstraintsSpec.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import nextflow.processor.TaskRun
2929
import nextflow.script.ProcessConfig
3030
import okhttp3.mockwebserver.MockResponse
3131
import okhttp3.mockwebserver.MockWebServer
32+
import spock.lang.Requires
3233
import spock.lang.Specification
3334

34-
import java.nio.file.Files
3535
import java.nio.file.Path
3636

3737
/**
@@ -41,7 +41,9 @@ import java.nio.file.Path
4141
*
4242
* @author : Jorge Aguilera <[email protected]>
4343
*/
44-
class JobConstraintsSpec extends Specification{
44+
45+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
46+
class MockJobConstraintsSpec extends Specification{
4547

4648
MockWebServer mockWebServer
4749

validation/sun-nomadlab/nextflow.config

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ plugins {
44

55
process {
66
executor = "nomad"
7+
8+
resourceLimits = [ cpus: 4, memory: 4.GB, time: 1.h ]
9+
710
}
811

912
aws {
@@ -30,6 +33,7 @@ fusion {
3033
logLevel = 'verbose' // 'info' | 'debug'
3134
}
3235

36+
3337
nomad {
3438

3539
client {
@@ -47,14 +51,14 @@ nomad {
4751
volume = { type "host" name "scratch" }
4852

4953
// constraints = {
50-
// // attr {
54+
// attr {
5155
// // unique = [hostname:'nomad03']
5256
// // //raw 'platform.aws.instance-type', '=', 'm4.xlarge'
5357

5458
// node {
5559
// unique = [name: "nomad03"]
60+
// }
5661
// }
57-
5862
// }
5963
}
6064
}

0 commit comments

Comments
 (0)