Skip to content

Commit e3612d3

Browse files
committed
refactor and more tests for nf-test
Signed-off-by: Jorge Aguilera <[email protected]>
1 parent fbb0789 commit e3612d3

25 files changed

+180
-46
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ To run and test the plugin in a development environment, configure a local Nextf
8484
./launch.sh run main.nf -plugins nf-nomad
8585
```
8686

87+
## End 2 End test (nf-test)
88+
89+
Project uses `nf-test` to run end to end integration tests running "real" pipelines against a local nomad
90+
91+
- compile and install a 99.99.99 version (`./gradlew clean installPlugin -Pversion=99.99.99)
92+
- open a terminal at `src/e2e/nomad` and execute `sudo ./start-nomad.sh` (this command will create a nomad server+client in the /tmp/nomad folder)
93+
- follow terminal instructions to get the NOMAD_TOKEN (`source /mtp/nomad/nomad_temp/.env`)
94+
- run all tests (`nf-test test`)
95+
96+
97+
8798
## Package, upload and publish
8899
89100
The project should be hosted in a GitHub repository whose name should match the name of the plugin, that is the name of the directory in the `plugins` folder (e.g. `nf-nomad`).

src/e2e/nomad/global-acl.hcl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
job "*/" {
2+
policy = "write"
3+
}
4+
5+
namespace "*" {
6+
policy = "write"
7+
8+
# this policy can write, read, or destroy any variable in any namespace
9+
variables {
10+
path "*" {
11+
capabilities = ["write", "read", "list", "destroy"]
12+
}
13+
}
14+
}
15+
16+
17+
host_volume "scratchdir" {
18+
policy = "write"
19+
}
20+

src/e2e/nomad/nf-nomad-acl.hcl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
job "*/" {
2+
policy = "write"
3+
}
4+
5+
namespace "*" {
6+
policy = "write"
7+
8+
# this policy can write, read, or destroy any variable in any namespace
9+
variables {
10+
path "*" {
11+
capabilities = ["write", "read", "list", "destroy"]
12+
}
13+
}
14+
}
15+
16+
17+
host_volume "scratchdir" {
18+
policy = "write"
19+
}
20+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ server {
66
bootstrap_expect = 1
77
}
88

9+
acl {
10+
enabled = true
11+
}
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cp stop-nomad.sh $TMP_NOMAD
88
cp server.conf $TMP_NOMAD
99
cp client.conf $TMP_NOMAD
1010
cp wait-nomad.sh $TMP_NOMAD
11+
cp *.hcl $TMP_NOMAD
1112
cd $TMP_NOMAD
1213
./install-nomad.sh
1314

@@ -24,12 +25,6 @@ cat >server-custom.conf <<EOL
2425
data_dir = "${CURRENT_DIR}/server"
2526
EOL
2627

27-
cat >>server-custom.conf <<EOL
28-
acl {
29-
enabled = true
30-
}
31-
EOL
32-
3328
rm -f client-custom.conf
3429
cat >client-custom.conf <<EOL
3530
data_dir = "${CURRENT_DIR}/client"
@@ -46,15 +41,23 @@ cp ../server.conf .
4641
cp ../client.conf .
4742

4843
# secured nomad cluster
49-
../nomad agent -config server.conf -config client.conf -config server-custom.conf -config client-custom.conf &
44+
../nomad agent -config server.conf -config client.conf -config server-custom.conf -config client-custom.conf&
5045
cd ..
5146
./wait-nomad.sh
5247

5348
NOMAD_TOKEN=$(./nomad acl bootstrap | awk '/^Secret ID/ {print $4}')
54-
export NOMAD_TOKEN
55-
echo New super token generated.
56-
echo export NOMAD_TOKEN=$NOMAD_TOKEN
49+
export NOMAD_TOKEN=$NOMAD_TOKEN
50+
echo New super token generated: $NOMAD_TOKEN
5751

5852
./nomad namespace apply -description "local-nomadlab" nf-nomad
59-
./nomad var put -namespace=nf-nomad secrets/nf-nomad/MY_ACCESS_KEY MY_ACCESS_KEY=TheAccessKey
60-
./nomad var put -namespace=nf-nomad secrets/nf-nomad/MY_SECRET_KEY MY_SECRET_KEY=TheSecretKey
53+
./nomad var put -namespace nf-nomad secrets/nf-nomad/MY_ACCESS_KEY MY_ACCESS_KEY=TheAccessKey
54+
./nomad var put -namespace nf-nomad secrets/nf-nomad/MY_SECRET_KEY MY_SECRET_KEY=TheSecretKey
55+
./nomad acl policy apply -description "nf-nomad policy" nf-nomad-ops global-acl.hcl
56+
./nomad acl policy apply -description "nf-nomad policy" -namespace nf-nomad -job 'MAIN:sayHello (3)' var-ops nf-nomad-acl.hcl
57+
58+
CLI_NOMAD_TOKEN=$(./nomad acl token create -name="nf-nomad" -policy="nf-nomad-ops" -policy="var-ops" -type=client | awk '/^Secret ID/ {print $4}')
59+
echo export NOMAD_TOKEN=$CLI_NOMAD_TOKEN >> ${CURRENT_DIR}/.env
60+
61+
echo run the following in the terminal:
62+
echo " source ${CURRENT_DIR}/.env"
63+
echo " ./nf-test test"
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ cd $TMP_NOMAD
88

99
./nomad node drain -enable $(./nomad node status -quiet)
1010
./nomad system gc
11+
kill $(ps aux | grep '../nomad agent' | awk '{print $2}')
1112
sleep 1
1213
df -h --output=target | grep nf-task | xargs sudo umount
13-
kill $(ps aux | grep '../nomad agent' | awk '{print $2}')
1414
sleep 1
15-
rm -rf nomad_temp
15+
cd $TMP_NOMAD
16+
rm -rf *
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
nextflow_workflow {
22

33
name "Test Basic"
4-
script "tests/basic/main.nf"
4+
script "workflows/hello.nf"
55
workflow "MAIN"
66

77
test("Should run without failures") {

0 commit comments

Comments
 (0)