Skip to content
Snippets Groups Projects

Converting Test Setup Scripts to Bash: CreateCertificates.sh

Open Animesh Narayan Dangwal requested to merge adangwal/jalien:bash-conversion into master
3 unresolved threads
  • Added CreateCertificates.sh, a bash variation of CreateCertificates.java
  • Modified SetupTestVO to call CreateCertificates.sh

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 converting SetupTestVO.java, StartTestVO.java and ShutdownTestVO.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.

  • Please register or sign in to reply
  • 1 #!/bin/bash
    2 #can have a testconfig.sh, for all commands and source it within script
    3 #set -e
    • So openssl is pretty weird. Using set -e can break the script because of this error making it pretty fickle to keep. Not too sure on how to improve error handling now, since many commands fall to the same error. (Funnily enough it does work even with the error.)

    • Please register or sign in to reply
  • 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 converting SetupTestVO.java, StartTestVO.java and ShutdownTestVO.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 become setuplocalVO.sh
      • A trivial implementation of setuplocalVO.sh would just call testj test and delegate the whole setup to SetupTestVO.java
      • You could call CreateCertificates.sh from setuplocalVO.sh before calling testj and SetupTestVO.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)
    • Please register or sign in to reply
  • added 2 commits

    Compare with previous version

  • added 3 commits

    • 732f1618 - Converting CreateDB.java to CreateDB.sh
    • c936b678 - Converting CreateDB.java to CreateDB.sh
    • 422300b6 - Converting CreateDB.java to CreateDB.sh

    Compare with previous version

  • added 3 commits

    • 36aba2f1 - Convert CreateLDAP.java to CreateLDAP.sh:
    • aa3ce6d0 - Bug Fixes:
    • ca6641b8 - Convert CreateLDAP.java to CreateLDAP.sh:

    Compare with previous version

  • Please register or sign in to reply
    Loading