Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant: Update Vagrant Host Playbook & Introduce 2 new Azure vagrant hosts for VPC / QEMU #3704

Merged
merged 19 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ hosts:
ubuntu2204-x64-1: {ip: 172.187.163.163, user: adoptopenjdk, description: infra-wazuh-server}
ubuntu2204-x64-2: {ip: 20.90.182.165, description: trss.adoptium.net}
ubuntu2204-x64-3: {ip: 172.187.93.97, description: awx.adoptium.net}
ubuntu2204-vagrant-x64-1: {ip: 172.203.178.157, description: VPC-Qemu-1}
ubuntu2204-vagrant-x64-2: {ip: 48.217.96.46, description: VPC-Qemu-2}

- digitalocean:
ubuntu2004-x64-1: {ip: 178.62.115.224, description: bastillion.adoptopenjdk.net}
Expand Down
56 changes: 56 additions & 0 deletions ansible/pbTestScripts/startScriptWin_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import sys
import getopt
import winrm

def usage():
print("Usage: %s -i <VM_IPAddress> -a <buildJDKWin_arguments>" % sys.argv[0])
print(" Use '-b' to run a build or '-t' to run a test")
sys.exit(1)

def run_winrm(vmIP, buildArgs, mode):
cmd_str = "Start-Process powershell.exe -Verb runAs; cd C:/tmp; sh C:/vagrant/pbTestScripts/"
print(f"Mode: {mode}")
if mode == 1:
cmd_str += "buildJDKWin.sh "
else:
cmd_str += "testJDKWin.sh "
cmd_str += buildArgs
print(f"Running: {cmd_str}")

session = winrm.Session(vmIP, auth=('vagrant', 'vagrant'))
result = session.run_ps(cmd_str)

# Print the output and error from the command execution
print(f"STDOUT: {result.std_out.decode('utf-8')}")
print(f"STDERR: {result.std_err.decode('utf-8')}")

def main(argv):
# mode refers to whether it's running a build or a test
mode = 1
print("Running python script")
inputArgs = ""
ipAddress = ""
try:
opts, args = getopt.getopt(argv, "ha:i:bt")
except getopt.GetoptError as error:
print(str(error))
usage()

for current_option, current_value in opts:
if current_option == '-a':
inputArgs = current_value
elif current_option == '-i':
ipAddress = current_value
elif current_option == '-h':
usage()
elif current_option == '-b':
mode = 1
elif current_option == '-t':
mode = 2

print(f"This is what is in the 'inputArgs' var: {inputArgs}")
print(f"This is what is in the 'ipAddress' var: {ipAddress}")
run_winrm(ipAddress, inputArgs, mode)

if __name__ == "__main__":
main(sys.argv[1:])
60 changes: 55 additions & 5 deletions ansible/pbTestScripts/vagrantPlaybookCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ startVMPlaybook()
sed -i -e "s/.*hosts:.*/ hosts: all/g" playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
awk '{print}/^\[defaults\]$/{print "private_key_file = id_rsa"; print "remote_tmp = $HOME/.ansible/tmp"; print "timeout = 60"}' < ansible.cfg > ansible.cfg.tmp && mv ansible.cfg.tmp ansible.cfg

ansible-playbook $verbosity -i playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx -u vagrant -b --skip-tags adoptopenjdk,jenkins${skipFullSetup} playbooks/AdoptOpenJDK_Unix_Playbook/main.yml 2>&1 | tee $WORKSPACE/adoptopenjdkPBTests/logFiles/$gitFork.$newGitBranch.$OS.log
if [ "$OS" == "Solaris10" ]; then
steelhead31 marked this conversation as resolved.
Show resolved Hide resolved
## Run The Playbook With ssh-rsa algorithms for Solaris 10 Only
ansible-playbook $verbosity -i playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx -u vagrant -b --ssh-extra-args='-o PubkeyAcceptedKeyTypes=ssh-rsa -o HostKeyAlgorithms=ssh-rsa' --skip-tags adoptopenjdk,jenkins${skipFullSetup} playbooks/AdoptOpenJDK_Unix_Playbook/main.yml 2>&1 | tee $WORKSPACE/adoptopenjdkPBTests/logFiles/$gitFork.$newGitBranch.$OS.log
else
ansible-playbook $verbosity -i playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx -u vagrant -b --skip-tags adoptopenjdk,jenkins${skipFullSetup} playbooks/AdoptOpenJDK_Unix_Playbook/main.yml 2>&1 | tee $WORKSPACE/adoptopenjdkPBTests/logFiles/$gitFork.$newGitBranch.$OS.log
steelhead31 marked this conversation as resolved.
Show resolved Hide resolved
fi

echo The playbook finished at : `date +%T`
if ! grep -q 'unreachable=0.*failed=0' $pbLogPath; then
echo PLAYBOOK FAILED
Expand All @@ -286,7 +292,8 @@ startVMPlaybook()
# Remove IP from known_hosts as the playbook installs an
# alternate sshd which regenerates the host key infra#2244
ssh-keygen -R $(cat playbooks/AdoptOpenJDK_Unix_Playbook/hosts.unx)
ssh_args="$ssh_args -o StrictHostKeyChecking=no"
ssh-keyscan -t rsa -p ${vagrantPORT} -H 127.0.0.1 > ~/.ssh/known_hosts
ssh_args="$ssh_args -o PubkeyAcceptedKeyTypes=ssh-rsa -o HostKeyAlgorithms=ssh-rsa"
fi

if [[ "$testNativeBuild" = true ]]; then
Expand Down Expand Up @@ -400,18 +407,61 @@ startVMPlaybookWin()

# Run a python script to start the build on the Windows VM to give live stdout/stderr
# See: https://github.com/adoptium/infrastructure/issues/1296
python pbTestScripts/startScriptWin.py -i "127.0.0.1:$vagrantPort" -a "$buildFork $buildBranch $jdkToBuild $buildHotspot" -b 2>&1 | tee $buildLogPath
## This Needs Amendments To Work With Python 3, so check the current version of python, and run the appropriate script

# Check the Python version
PYTHON_VERSION=$(python -V 2>&1)

echo "Starting Build"
if [[ $PYTHON_VERSION == *"Python 2."* ]]; then
echo "Python 2 detected"
python pbTestScripts/startScriptWin.py -i "127.0.0.1:$vagrantPort" -a "$buildFork $buildBranch $jdkToBuild $buildHotspot" -b 2>&1 | tee $buildLogPath
elif [[ $PYTHON_VERSION == *"Python 3."* ]]; then
echo "Python 3 detected"
##echo "Due To Changes In Python 3 - No Output Will Be Displayed Until The Build Is Completed"
##python pbTestScripts/startScriptWin_v2.py -i "127.0.0.1:$vagrantPort" -a "$buildFork $buildBranch $jdkToBuild $buildHotspot" -b 2>&1 | tee $buildLogPath
# Create Powershell Script To Launch Build
echo "Set-Location -Path \"C:/tmp\"" > BuildJDK_Tmp.ps1
if [ "$buildHotspot" != "" ]; then
echo "& sh \"C:/vagrant/pbTestScripts/buildJDKWin.sh\" $buildFork $buildBranch $jdkToBuild --hotspot" >> BuildJDK_Tmp.ps1
else
echo "& sh \"C:/vagrant/pbTestScripts/buildJDKWin.sh\" $buildFork $buildBranch $jdkToBuild" >> BuildJDK_Tmp.ps1
fi
# Copy PowerShell Script From Vagrant Share For Performance Reasons & Launch
vagrant winrm -s powershell -e -c 'copy c:/vagrant/BuildJDK_Tmp.ps1 c:/tmp; cd c:/tmp; pwd; ls'
vagrant winrm -e -c 'powershell -ExecutionPolicy Bypass -File c:/tmp/BuildJDK_Tmp.ps1' | tee $buildLogPath
else
echo "Python is not installed or is of an unsupported version."
exit 99
fi

echo The build finished at : `date +%T`
if grep -q '] Error' $buildLogPath || grep -q 'configure: error' $buildLogPath; then
echo BUILD FAILED
exit 127
fi

echo "Starting Tests.."
if [[ "$runTest" = true ]]; then
local testLogPath="$WORKSPACE/adoptopenjdkPBTests/logFiles/${gitFork}.${newGitBranch}.$OS.test_log"

# Run a python script to start a test for the built JDK on the Windows VM
python pbTestScripts/startScriptWin.py -i "127.0.0.1:$vagrantPort" -t 2>&1 | tee $testLogPath
if [[ $PYTHON_VERSION == *"Python 2."* ]]; then
echo "Python 2 detected"
python pbTestScripts/startScriptWin.py -i "127.0.0.1:$vagrantPort" -t 2>&1 | tee $testLogPath
elif [[ $PYTHON_VERSION == *"Python 3."* ]]; then
echo "Python 3 detected"
#echo "Due To Changes In Python 3 - No Output Will Be Displayed Until The Build Is Completed"
#python pbTestScripts/startScriptWin_v2.py -i "127.0.0.1:$vagrantPort" -t 2>&1 | tee $testLogPath
# Create Powershell Script To Launch Tests
echo "& sh \"C:/vagrant/pbTestScripts/testJDKWin.sh\"" > testJDK_Tmp.ps1
# Copy PowerShell Script From Vagrant Share For Performance Reasons & Launch
vagrant winrm -s powershell -e -c 'copy c:/vagrant/testJDK_Tmp.ps1 c:/tmp; cd c:/tmp; pwd; ls'
vagrant winrm -e -c 'powershell -ExecutionPolicy Bypass -File c:/tmp/testJDK_Tmp.ps1' | tee $testLogPath
else
echo "Python is not installed or is of an unsupported version."
exit 99
fi

echo The test finished at : `date +%T`
if ! grep -q 'FAILED: 0' $testLogPath; then
echo TEST FAILED
Expand Down
Loading