Converting Test Setup Scripts to Bash: CreateCertificates.sh
- Added CreateCertificates.sh, a bash variation of CreateCertificates.java
- Modified SetupTestVO to call CreateCertificates.sh
Merge request reports
Activity
62 62 63 63 // step 2 64 64 System.out.println("----- STEP2 [INIT]: Certificates -----"); 65 if (!CreateCertificates.doit(verbose)) 65 final TestCommand genCerts = new TestCommand(new String[] {"bash","/jalien/src/main/java/alien/test/setup/CreateCertificates.sh"}); Unfortunately had to hardcode file path. One direction we could explore is not only converting the
alien/test/setup/*.java
files but also convertingSetupTestVO.java
,StartTestVO.java
andShutdownTestVO.java
.This also lets us have one
source_env.sh
file which can be added to the start of every bash script to initialise the path variables. Do let me know if this is a direction worth pursuing.
1 #!/bin/bash 2 #can have a testconfig.sh, for all commands and source it within script 3 #set -e 16 HOST_REQ="${TVO_CERTS}/hostreq.pem" 17 HOSTTEMP_KEY="${TVO_CERTS}/hostkeytemp.pem" 18 CERTSUBJECT_HOST="/C=CH/O=JAliEn/CN=localhost.localdomain" 19 HOST_CERT="${TVO_CERTS}/hostcert.pem" 20 HOST_KEY="${TVO_CERTS}/hostkey.pem" 21 22 JAUTHTEMP_KEY="${TVO_CERTS}/authenkeytemp.pem" 23 JAUTH_PUB="${TVO_CERTS}/AuthZ_pub.pem" 24 CERTSUBJECT_JAUTH="/C=CH/O=JAliEn/CN=jAuth" 25 JAUTH_PRIV="${TVO_CERTS}/AuthZ_priv.pem" 26 27 SETEMP_KEY="${TVO_CERTS}/SEkeytemp.pem" 28 SE_PUB="${TVO_CERTS}/SE_pub.pem" 29 CERTSUBJECT_SE="/C=CH/O=JAliEn/CN=TESTSE" 30 SE_PRIV="${TVO_CERTS}/SE_priv.pem" 31 Kept the file paths hardcoded for now. Injecting a file path (via
CreateCertificates.sh /file/path/here
) requires every other script to also be updated to look to the same place.Another argument for the above comment on using a
source_env.sh
file at the top of each bash script and convertingSetupTestVO.java
,StartTestVO.java
andShutdownTestVO.java
to bash as well.Yes, are right, we should definitely go in the direction of converting other scripts to bash. However, we can't do it all at once. What do you say about this:
- You already have started converting
SetupTestVO.java
, it will becomesetuplocalVO.sh
- A trivial implementation of
setuplocalVO.sh
would just calltestj test
and delegate the whole setup toSetupTestVO.java
- You could call
CreateCertificates.sh
fromsetuplocalVO.sh
before callingtestj
andSetupTestVO.java
- The problem is that you don't have good control over
testj
and where it creates files, so parametrize it - Make the bash setup script in charge of creating this "config" directory (
TestConfig.tvo_home
) - First create the config dir, then create certificates in it, and finally call
testj
and let it take over from there - If the "config rotation" logic in
SetupTestVO.java
is in your way, then pull it up into the bash script, something like[ -d $TVO_HOME ] && mv $TVO_HOME $TVO_HOME_$(date)
So the whole point behind this is to pull up the config target dir to the bash script, and then push it down to any component it needs it. You could go through:
- test, regular shell args
- Tester.java, pass args to main
- SetupTestVO.setupVO(target), add param
- In setupVO() you set
TestConfig.tvo_home = target
(drop final in TestConfig)
- You already have started converting
added 2 commits