diff --git a/gradle.properties b/gradle.properties index 8766f31..c623543 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.0.2-rc1 \ No newline at end of file +version=0.0.2 \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle index 6b08277..644098c 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -1,8 +1,7 @@ /* + * Copyright 2023-, Stellenbosch University, South Africa * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain - * Copyright 2023, Stellenbosch University, South Africa - * Copyright 2022, Center for Medical Genetics, Ghent - * + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/plugins/nf-nomad/src/main/nextflow/nomad/NomadConfig.groovy b/plugins/nf-nomad/src/main/nextflow/nomad/NomadConfig.groovy index 624efc2..bf6bacf 100644 --- a/plugins/nf-nomad/src/main/nextflow/nomad/NomadConfig.groovy +++ b/plugins/nf-nomad/src/main/nextflow/nomad/NomadConfig.groovy @@ -1,6 +1,6 @@ /* - * Copyright 2023, Stellenbosch University, South Africa - * Copyright 2022, Center for Medical Genetics, Ghent + * Copyright 2023-, Stellenbosch University, South Africa + * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadExecutor.groovy b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadExecutor.groovy index a7115f4..d4e59bb 100644 --- a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadExecutor.groovy +++ b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadExecutor.groovy @@ -1,4 +1,19 @@ - +/* + * Copyright 2023-, Stellenbosch University, South Africa + * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package nextflow.nomad.executor import groovy.transform.CompileStatic diff --git a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadScriptLauncher.groovy b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadScriptLauncher.groovy index 2a8b693..1f37061 100644 --- a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadScriptLauncher.groovy +++ b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadScriptLauncher.groovy @@ -1,3 +1,20 @@ +/* + * Copyright 2023-, Stellenbosch University, South Africa + * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package nextflow.nomad.executor diff --git a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy index 7c1cdd5..ba73970 100644 --- a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy +++ b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy @@ -1,7 +1,6 @@ /* + * Copyright 2023-, Stellenbosch University, South Africa * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain - * Copyright 2023, Stellenbosch University, South Africa - * Copyright 2022, Center for Medical Genetics, Ghent * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +50,10 @@ class NomadService implements Closeable{ this.config = config ApiClient apiClient = new ApiClient() apiClient.basePath = config.clientOpts.address + if( config.clientOpts.token ){ + log.debug "[NOMAD BATCH] Creating Nomad connection using token: ${config.clientOpts.token?.substring(0,5)}.." + apiClient.apiKey = config.clientOpts.token + } this.jobsApi = new JobsApi(apiClient); } diff --git a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadTaskHandler.groovy b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadTaskHandler.groovy index 0ed6259..3390b4d 100644 --- a/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadTaskHandler.groovy +++ b/plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadTaskHandler.groovy @@ -1,4 +1,19 @@ - +/* + * Copyright 2023-, Stellenbosch University, South Africa + * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package nextflow.nomad.executor diff --git a/plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy b/plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy index 02410ca..72a83bc 100644 --- a/plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy +++ b/plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy @@ -1,4 +1,6 @@ /* + * Copyright 2023-, Stellenbosch University, South Africa + * Copyright 2024, Evaluacion y Desarrollo de Negocios, Spain* * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy b/plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy index 3e7e69d..241b4c3 100644 --- a/plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy +++ b/plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy @@ -245,4 +245,42 @@ class NomadServiceSpec extends Specification{ body.Job.TaskGroups[0].Tasks[0].VolumeMounts[0] == [Destination:"a", Volume:"test"] } + + void "should send the token"(){ + given: + def config = new NomadConfig( + client:[ + address : "http://${mockWebServer.hostName}:${mockWebServer.port}", + token: "1234" + ], + jobs:[ + dockerVolume:'test' + ] + ) + def service = new NomadService(config) + + String id = "theId" + String name = "theName" + String image = "theImage" + List args = ["theCommand", "theArgs"] + String workingDir = "a/b/c" + Mapenv = [test:"test"] + + mockWebServer.enqueue(new MockResponse() + .setBody(JsonOutput.toJson(["EvalID":"test"]).toString()) + .addHeader("Content-Type", "application/json")); + when: + + def idJob = service.submitTask(id, name, image, args, workingDir,env) + def recordedRequest = mockWebServer.takeRequest(); + def body = new JsonSlurper().parseText(recordedRequest.body.readUtf8()) + + then: + idJob + + and: + recordedRequest.method == "POST" + recordedRequest.path == "/v1/jobs" + recordedRequest.headers.values('X-Nomad-Token').first()=='1234' + } }