Skip to content

Commit

Permalink
Use vagrantfiles from main repo by default, option to take from the a…
Browse files Browse the repository at this point in the history
…lternate branch (#1070)

* Don't use vagrant files from the branch under test

Signed-off-by: Stewart Addison <sxa@uk.ibm.com>

* pbTestScripts: Add option to use Vagrant files from the new branch

Signed-off-by: Stewart Addison <sxa@uk.ibm.com>
  • Loading branch information
sxa555 authored and Willsparker committed Jan 6, 2020
1 parent 7237cb3 commit c4643ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
19 changes: 10 additions & 9 deletions ansible/pbTestScripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ These machines will then have the playbooks ran on them, with additional options

The top level script `vagrantPlayBookCheck.sh` takes a number of options:

| Option | Description | Example |
|----------------------|-------------------------------------------------------|-----------------------------------------------------------------------------------------|
| --vagrantfile / -v OS| Run against the specified operating system | `./vagrantPlaybookCheck.sh -v Ubuntu1804` |
| --all / -a | Runs for all OSs | `./vagrantPlaybookCheck.sh -a` |
| --retainVM / -r | Retains the VM after running the Playbook | `./vagrantPlaybookCheck.sh -a --retainVM` |
| --build / -b | Build JDK8 on the VM after the playbook | `./vagrantPlaybookCheck.sh -a --build` |
| --URL / -u Git URL | Specify the URL of the infrastructure repo to clone * | `./vagrantPlaybookCheck.sh -a --URL https://github.com/sxa555/openjdk-infrastructure/tree/mybranch` |
| --test / -t | Run a small test on the built JDK within the VM ** | `./vagrantPlaybookCheck.sh -a --build --test` |
| --help | Displays usage | `./vagrantPlaybookCheck.sh --help` |
| Option | Description | Example |
|--------------------------|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| --vagrantfile / -v OS | Run against the specified operating system | `./vagrantPlaybookCheck.sh -v Ubuntu1804` |
| --all / -a | Runs for all OSs | `./vagrantPlaybookCheck.sh -a` |
| --retainVM / -r | Retains the VM after running the Playbook | `./vagrantPlaybookCheck.sh -a --retainVM` |
| --build / -b | Build JDK8 on the VM after the playbook | `./vagrantPlaybookCheck.sh -a --build` |
| --URL / -u Git URL | Specify the URL of the infrastructure repo to clone * | `./vagrantPlaybookCheck.sh -a --URL https://github.com/sxa555/openjdk-infrastructure/tree/mybranch` |
| --test / -t | Run a small test on the built JDK within the VM ** | `./vagrantPlaybookCheck.sh -a --build --test` |
| --new-vagrant-file / -nv | Use the vagrant files from the new URL | `./vagrantPlaybookCheck.sh -a -nv --URL https://...` |
| --help | Displays usage | `./vagrantPlaybookCheck.sh --help` |

Notes:
- If not specified, the URL will default to `https://github.com/adoptopenjdk/openjdk-infrastructure`
Expand Down
22 changes: 18 additions & 4 deletions ansible/pbTestScripts/vagrantPlaybookCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ testNativeBuild=false
runTest=false
vmHalt=true
cleanWorkspace=false
newVagrantFiles=false

# Takes all arguments from the script, and determines options
processArgs()
Expand All @@ -34,6 +35,8 @@ processArgs()
vmHalt=false;;
"--clean-workspace" | "-c" )
cleanWorkspace=true;;
"--new-vagrant-files" | "-nv" )
newVagrantFiles=true;;
"--help" | "-h" )
usage; exit 0;;
*) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognised."; usage; exit 1;;
Expand All @@ -50,7 +53,8 @@ usage()
--clean-workspace | -c Will remove the old work folder if detected
--URL | -u <GitURL> The URL of the git repository
--test | -t Runs a quick test on the built JDK
--no-halt | -nh Option to stop the vagrant VMs halting
--no-halt | -n Option to stop the vagrant VMs halting
--new-vagrant-files | -nv Use vagrantfiles from the the specified git repository
--help | -h Displays this help message"
}

Expand Down Expand Up @@ -91,7 +95,9 @@ checkVagrantOS()
{
cd ${WORKSPACE}/adoptopenjdkPBTests/${folderName}-${branchName}/ansible
local vagrantOSlist=$(ls -1 Vagrantfile.* | cut -d. -f 2)
if [[ -f "Vagrantfile.${vagrantOS}" ]]; then
if [[ "$newVagrantFiles" = "true" ]] && [[ -f "Vagrantfile.${vagrantOS}" ]]; then
echo "Vagrantfile detected"
elif [[ "$newVagrantFiles" != "true" ]] && [[ -f "$WORKSPACE/ansible/pbTestScripts/Vagrantfile.${vagrantOS}" ]]; then
echo "Vagrantfile detected"
elif [[ "$vagrantOS" == "all" ]]; then
vagrantOS=$vagrantOSlist
Expand Down Expand Up @@ -160,7 +166,11 @@ startVMPlaybook()
{
local OS=$1
cd $WORKSPACE/adoptopenjdkPBTests/$folderName-$branchName/ansible
ln -sf Vagrantfile.$OS Vagrantfile
if [ "$newVagrantFiles" = "true" ]; then
ln -sf Vagrantfile.$OS Vagrantfile
else
ln -sf $WORKSPACE/ansible/pbTestScripts/Vagrantfile.$OS Vagrantfile
fi
# Copy the machine's ssh key for the VMs to use, after removing prior files
rm -f id_rsa.pub id_rsa
ssh-keygen -q -f $PWD/id_rsa -t rsa -N ''
Expand Down Expand Up @@ -199,7 +209,11 @@ startVMPlaybookWin()
{
local OS=$1
cd $WORKSPACE/adoptopenjdkPBTests/$folderName-$branchName/ansible
ln -sf Vagrantfile.$OS Vagrantfile
if [ "$newVagrantFiles" = "true" ]; then
ln -sf Vagrantfile.$OS Vagrantfile
else
ln -sf $WORKSPACE/ansible/pbTestScripts/Vagrantfile.$OS Vagrantfile
fi
# Remove the Hosts files if they're found
rm -f playbooks/AdoptOpenJDK_Windows_Playbook/hosts.tmp
rm -f playbooks/AdoptOpenJDK_Windows_Playbook/hosts.win
Expand Down

0 comments on commit c4643ee

Please sign in to comment.