From 74d2c33cbb899130f88b43af24d0e9870435b695 Mon Sep 17 00:00:00 2001 From: Sivakanth Rebba Date: Thu, 6 Jul 2017 23:11:44 +0530 Subject: [PATCH] Added ARM support for Wordpress test and fixed minor issues (#35) * Updated the detect_linux_distribution_version lib function to get proper distro version * Minor fix to support package installation for CentOS * Minor fix to support package installation for CentOS and RHEL distros in FIO perf test * Minor fix for FIO test * Minor fix for detect distro version * Updated the perf_iperf3.sh script to install the required packages for CentOS & RHEL * Added new test scripts for LIS build scenario tests 1. Added new test scripts for LIS build 8 scenario tests 2. Updated ARM test execution mode * Minor Fix to display upgrade & uninstall LIS console messages * Minor fix to support ARM mode * Added ARM support for Wordpress test and fixed minor issues * Minor fix for ARM instance size support --- Azure_ICA_all.xml | 75 +------- remote-scripts/E2E-WORDPRESS-SETUP.ps1 | 165 +++++++++++++----- remote-scripts/E2E-WORDPRESS-SETUP.py | 151 ++++++++++++---- .../ICA-BUILD-LINUX-NEXT-DEB-PACKAGE.ps1 | 24 --- 4 files changed, 246 insertions(+), 169 deletions(-) diff --git a/Azure_ICA_all.xml b/Azure_ICA_all.xml index 5a93f00..d63230d 100644 --- a/Azure_ICA_all.xml +++ b/Azure_ICA_all.xml @@ -505,26 +505,13 @@ Small + Standard_A1 SSH tcp 22 22 - - https-1 - tcp - 8443 - 8443 - False - - - https-2 - udp - 443 - 443 - False - http-1 tcp @@ -666,6 +653,7 @@ Medium + Standard_A2 Backend SSH @@ -678,6 +666,7 @@ Small + Standard_A1 Frontend1 SSH @@ -685,22 +674,6 @@ 22 222 - - https-1 - tcp - 8443 - 8443 - 8443 - True - - - https-2 - udp - 443 - 443 - 443 - True - http-1 tcp @@ -722,6 +695,7 @@ Small + Standard_A1 Frontend2 SSH @@ -729,22 +703,6 @@ 22 322 - - https-1 - tcp - 8443 - 8443 - 8443 - True - - - https-2 - udp - 443 - 443 - 443 - True - http-1 tcp @@ -766,6 +724,7 @@ Small + Standard_A1 Frontend3 SSH @@ -773,22 +732,6 @@ 22 422 - - https-1 - tcp - 8443 - 8443 - 8443 - True - - - https-2 - udp - 443 - 443 - 443 - True - http-1 tcp @@ -5968,12 +5911,12 @@ E2E-WORDPRESS-SINGLE-VM-SETUP E2E-WORDPRESS-SETUP.py E2E-WORDPRESS-SETUP.ps1 - .\remote-scripts\Packages\wordpress.zip,.\remote-scripts\Packages\Wordpress.DDL,.\remote-scripts\E2E-WORDPRESS-SETUP.py,.\remote-scripts\azuremodules.py + .\remote-scripts\E2E-WORDPRESS-SETUP.py,.\remote-scripts\azuremodules.py,.\tools\packages\python-pexpect-3.1-1.1.noarch.rpm E2ESingleVM singleVM_setup - AzureServiceManagement + AzureServiceManagement,AzureResourceManager P0 @@ -5999,12 +5942,12 @@ E2E-WORDPRESS-FOUR-VM-SETUP E2E-WORDPRESS-SETUP.py E2E-WORDPRESS-SETUP.ps1 - .\remote-scripts\Packages\wordpress.zip,.\remote-scripts\Packages\Wordpress.DDL,.\remote-scripts\E2E-WORDPRESS-SETUP.py,.\remote-scripts\azuremodules.py + .\remote-scripts\E2E-WORDPRESS-SETUP.py,.\remote-scripts\azuremodules.py,.\tools\packages\python-pexpect-3.1-1.1.noarch.rpm E2EFourVM loadbalancer_setup - AzureServiceManagement + AzureServiceManagement,AzureResourceManager P0 diff --git a/remote-scripts/E2E-WORDPRESS-SETUP.ps1 b/remote-scripts/E2E-WORDPRESS-SETUP.ps1 index 64f4ff3..004813e 100644 --- a/remote-scripts/E2E-WORDPRESS-SETUP.ps1 +++ b/remote-scripts/E2E-WORDPRESS-SETUP.ps1 @@ -11,35 +11,37 @@ if ($isDeployed) { try { - $testServiceData = Get-AzureService -ServiceName $isDeployed - - #Get VMs deployed in the service.. - $testVMsinService = $testServiceData | Get-AzureVM + LogMsg "TEST VM : $($allVMData.ServiceName)" try{ if($currentTestData.E2ESetupCmdLineArgument -imatch "singleVM_setup") { + #region FOR WORDPRESS 1 VM TEST write-host "Preparing WordPress SingleVM Setup" - $hs1vm1 = $testVMsinService - $hs1vm1Endpoints = $hs1vm1 | Get-AzureEndpoint - $hs1vm1sshport = GetPort -Endpoints $hs1vm1Endpoints -usage ssh - $hs1VIP = $hs1vm1Endpoints[0].Vip - $wordpressUrl = $hs1vm1.DNSName+"wordpress/wp-admin/install.php" - $hs1ServiceUrl = $hs1vm1.DNSName - $hs1ServiceUrl = $hs1ServiceUrl.Replace("http://","") - $hs1ServiceUrl = $hs1ServiceUrl.Replace("/","") - $hs1vm1Hostname = $hs1vm1.Name - - "#all the IPs should be Internal ips `n$user`n$passwd" > 'wordpress_install.XML' - # Uploading files into VM - $out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files "wordpress_install.XML" -username $user -password $password -upload 2>&1 | Out-Null + [string] $ServiceName = $allVMData.ServiceName + $hs1vm1sshport = $allVMData.SSHPort + $hs1bkvmurl = $allVMData.URL + $wordpressUrl = "http://"+$hs1bkvmurl+"/wordpress/wp-admin/install.php" + $hs1vm1Hostname = $allVMData.RoleName + $hs1VIP = $allVMData.PublicIP + $hs1IP = $allVMData.InternalIP + + LogMsg "TEST VM details :" + LogMsg " RoleName : $hs1vm1Hostname" + LogMsg " Public IP : $hs1VIP" + LogMsg " SSH Port : $hs1vm1sshport" + LogMsg " WORDPRESS URL : $wordpressUrl" + + Set-Content -Value "#all the IPs should be Internal ips `n$user`n$passwd" -Path "$LogDir\wordpress_install.XML" # Uploading files into VM + $out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files ".\$LogDir\wordpress_install.XML" -username $user -password $password -upload 2>&1 | Out-Null $out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null # Assiging Permissions to uploaded files into VM $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null - # Converting the file from UTF-16 to ASCII - $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "iconv -f UTF-16 -t ASCII wordpress_install.XML > wordpress_install.XML.tmp ; mv -f wordpress_install.XML.tmp wordpress_install.XML" -runAsSudo 2>&1 | Out-Null LogMsg "Executing : $($currentTestData.testScript)" + #region EXECUTE TEST + Set-Content -Value "python $($currentTestData.testScript) singleVM_setup 2>&1> /home/$user/wordpressConsole.txt" -Path "$LogDir\StartWordpressTest.sh" + $out = RemoteCopy -uploadTo $hs1VIP -port $hs1vm1sshport -files ".\$LogDir\StartWordpressTest.sh" -username $user -password $password -upload # Wordpress installation on E2ESingleVM" Write-host "#################################################################################################" Write-host "" @@ -48,45 +50,106 @@ if ($isDeployed) Write-host "" Write-host "#################################################################################################" # Wordpress Setup file is executing on E2ESingleVM" - $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command " python $($currentTestData.testScript) singleVM_setup 2>&1 > print.log" -runAssudo -ignoreLinuxExitCode -runmaxallowedtime 3600 2>&1 | Out-Null + $testJob = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "bash /home/$user/StartWordpressTest.sh" -runAsSudo -RunInBackground + #region MONITOR TEST + while ( (Get-Job -Id $testJob).State -eq "Running" ) + { + $wordpressTestInfo = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "cat /home/$user/Runtime.log | grep 'INFO :' | tail -2 " -runAsSudo + LogMsg "** Current TEST Staus : $wordpressTestInfo" + WaitFor -seconds 2 + } # Downloading the files VM RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/wdp_test.txt , /home/$user/logs.tar.gz" -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password 2>&1 | Out-Null } elseif($currentTestData.E2ESetupCmdLineArgument -imatch "loadbalancer_setup") { + #region FOR WORDPRESS 4 VM TEST write-host "Preparing WordPress FourVM Setup" - $hs1bkvm = $testVMsinService[0] - $hs1fe1vm1 = $testVMsinService[1] - $hs1fe2vm2 = $testVMsinService[2] - $hs1fe3vm3 = $testVMsinService[3] + $noFrontend = $true + $noBackend = $true + foreach ( $vmData in $allVMData ) + { + if ( $vmData.RoleName -imatch "Frontend1" ) + { + $fronend1VMData = $vmData + $noFrontend = $false + } + elseif ( $vmData.RoleName -imatch "Frontend2" ) + { + $fronend2VMData = $vmData + $noFrontend = $false + } + elseif ( $vmData.RoleName -imatch "Frontend3" ) + { + $fronend3VMData = $vmData + $noFrontend = $false + } + elseif ( $vmData.RoleName -imatch "Backend" ) + { + $noBackend = $fase + $backendVMData = $vmData + } + } + if ( $noFrontend ) + { + Throw "No any slave VM defined. Be sure that, Server machine role names matches with pattern `"*slave*`" Aborting Test." + } + if ( $noBackend ) + { + Throw "No any master VM defined. Be sure that, Client VM role name matches with the pattern `"*master*`". Aborting Test." + } - $hs1bkvmEndpoints = $hs1bkvm | Get-AzureEndpoint - $hs1bkvmsshport = GetPort -Endpoints $hs1bkvmEndpoints -usage ssh + $hs1bkvmurl = $allVMData.url[0] + $wordpressUrl = "http://"+$hs1bkvmurl+"/wordpress/wp-admin/install.php" - $hs1VIP = $hs1bkvmEndpoints.Vip + LogMsg "FRONTEND VM details :" + LogMsg " RoleName : $($fronend1VMData.RoleName)" + LogMsg " Public IP : $($fronend1VMData.PublicIP)" + LogMsg " SSH Port : $($fronend1VMData.SSHPort)" - $wordpressUrl = $hs1bkvm.DNSName+"wordpress/wp-admin/install.php" - $hs1ServiceUrl = $hs1bkvm.DNSName - $hs1ServiceUrl = $hs1ServiceUrl.Replace("http://","") - $hs1ServiceUrl = $hs1ServiceUrl.Replace("/","") + LogMsg " RoleName : $($fronend2VMData.RoleName)" + LogMsg " Public IP : $($fronend2VMData.PublicIP)" + LogMsg " SSH Port : $($fronend2VMData.SSHPort)" - $bkendip = $hs1bkvm.Ipaddress.ToString() - $fe1ip = $hs1fe1vm1.Ipaddress.ToString() - $fe2ip = $hs1fe2vm2.Ipaddress.ToString() - $fe3ip = $hs1fe3vm3.Ipaddress.ToString() + LogMsg " RoleName : $($fronend3VMData.RoleName)" + LogMsg " Public IP : $($fronend3VMData.PublicIP)" + LogMsg " SSH Port : $($fronend3VMData.SSHPort)" + + LogMsg "BACKEND VM details :" + LogMsg " RoleName : $($backendVMData.RoleName)" + LogMsg " Public IP : $($backendVMData.PublicIP)" + LogMsg " SSH Port : $($backendVMData.SSHPort)" + LogMsg " WORDPRESS URL : $wordpressUrl" + + $hs1VIP = $backendVMData.PublicIP + [string] $ServiceName = $allVMData.ServiceName + + $bkendip = $backendVMData.InternalIP.ToString() + $fe1ip = $fronend1VMData.InternalIP.ToString() + $fe2ip = $fronend2VMData.InternalIP.ToString() + $fe3ip = $fronend3VMData.InternalIP.ToString() + + $hs1bkvmsshport = $backendVMData.SSHPort + $fe1sshport = $fronend1VMData.SSHPort + $fe2sshport = $fronend2VMData.SSHPort + $fe3sshport = $fronend3VMData.SSHPort #Preparation of wordpress install xml file - "#all the IPs should be Internal ips `n$bkendip`n$fe1ip $fe2ip $fe3ip`n$user`n$passwd" > 'wordpress_install.XML' - # Uploading xml file into VM - $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bkvmsshport -files "wordpress_install.XML" -username $user -password $password -upload 2>&1 | Out-Null + Set-Content -Value "#all the IPs should be Internal ips `n$bkendip`n$fe1ip $fe2ip $fe3ip`n$user`n$passwd" -Path "$LogDir\wordpress_install.XML" # Uploading files into VM + $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bkvmsshport -files ".\$LogDir\wordpress_install.XML" -username $user -password $password -upload 2>&1 | Out-Null $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bkvmsshport -files $currentTestData.files -username $user -password $password -upload 2>&1 | Out-Null # Assiging Permissions to uploaded files into VM - $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "chmod 777 *.XML" -runAsSudo 2>&1 | Out-Null - # Converting the file from UTF-16 to ASCII - $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "iconv -f UTF-16 -t ASCII wordpress_install.XML > wordpress_install.XML.tmp ; mv -f wordpress_install.XML.tmp wordpress_install.XML" -runAsSudo 2>&1 | Out-Null + $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "chmod +x *" -runAsSudo 2>&1 | Out-Null + #region EXECUTE TEST + Set-Content -Value "python $($currentTestData.testScript) loadbalancer_setup 2>&1 > /home/$user/wordpressConsole.txt" -Path "$LogDir\StartWordpressTest.sh" + $out = RemoteCopy -uploadTo $hs1VIP -port $hs1bkvmsshport -files ".\$LogDir\StartWordpressTest.sh" -username $user -password $password -upload LogMsg "Executing : $($currentTestData.testScript)" + $cmdStr = '`date` INFO : Setup Not Started..' + $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe1sshport -command "echo $cmdStr > /home/$user/Runtime.log" #-runAsSudo + $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe2sshport -command "echo $cmdStr > /home/$user/Runtime.log" #-runAsSudo + $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe3sshport -command "echo $cmdStr > /home/$user/Runtime.log" #-runAsSudo # Wordpress installation on E2EFOURVM Write-host "#################################################################################################" Write-host "" @@ -94,9 +157,21 @@ if ($isDeployed) Write-host "It will take more than 30 minutes and may take more time depending on internet speed." -foregroundcolor "magenta" Write-host "" Write-host "#################################################################################################" - # Wordpress Setup file is executing on E2EFOURVM - $out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "python $($currentTestData.testScript) loadbalancer_setup 2>&1 > print.log" -runAsSudo -ignoreLinuxExitCode -runmaxallowedtime 3600 2>&1 | Out-Null - # Downloading the files VM + # Read-host "Verify 4VM detais...." + $testJob = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "bash /home/$user/StartWordpressTest.sh" -runAsSudo -RunInBackground + #region MONITOR TEST + while ( (Get-Job -Id $testJob).State -eq "Running" ) + { + $wordpressTestInfo = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1bkvmsshport -command "cat /home/$user/Runtime.log | grep 'INFO :' | tail -2 " -runAsSudo + LogMsg "** Current TEST Staus BACKEND : $wordpressTestInfo" + $fe1TestInfo = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe1sshport -command "cat /home/$user/Runtime.log | grep 'INFO :' | tail -2 " -runAsSudo -ignoreLinuxExitCode + LogMsg "** Current TEST Staus of FRONTEND1 : $fe1TestInfo" + $fe2TestInfo = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe2sshport -command "cat /home/$user/Runtime.log | grep 'INFO :' | tail -2 " -runAsSudo -ignoreLinuxExitCode + LogMsg "** Current TEST Staus of FRONTEND2 : $fe2TestInfo" + $fe3TestInfo = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $fe3sshport -command "cat /home/$user/Runtime.log | grep 'INFO :' | tail -2 " -runAsSudo -ignoreLinuxExitCode + LogMsg "** Current TEST Staus of FRONTEND3 : $fe3TestInfo" + WaitFor -seconds 10 + } RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/wdp_test.txt,/home/$user/logs.tar.gz " -downloadTo $LogDir -port $hs1bkvmsshport -username $user -password $password 2>&1 | Out-Null }else{ $testResult="FAIL" @@ -170,7 +245,7 @@ $result = GetFinalResultHeader -resultarr $resultArr $result = $testResult #Clean up the setup -#DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed +#DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed -ResourceGroups $isDeployed #Return the result and summery to the test suite script.. if ($testResult -eq "PASS") diff --git a/remote-scripts/E2E-WORDPRESS-SETUP.py b/remote-scripts/E2E-WORDPRESS-SETUP.py index abae967..56f788b 100644 --- a/remote-scripts/E2E-WORDPRESS-SETUP.py +++ b/remote-scripts/E2E-WORDPRESS-SETUP.py @@ -7,8 +7,9 @@ import os.path from azuremodules import * #OS independent variables -wdp_downlink = "http://wordpress.org/latest.tar.gz" -##wdp_db_root_password = "wordpress_root_password" +# wdp_downlink = "http://wordpress.org/latest.tar.gz" +# wdp_configlink = "https://konkasoftpackages.blob.core.windows.net/testpackages/wordpress/wp-config-sample.php" +wdp_downlink = "https://github.com/WordPress/WordPress.git" wdp_db_root_password = "wordpress_password" wdp_db_name = "wordpressdb" wdp_db_hostname = "localhost" @@ -55,50 +56,50 @@ def set_variables_OS_dependent(): service_httpd_name = "httpd" service_mysqld_name = "mysqld" mysql_pkg_name = "mysql-server" - frontend_packages_list = ["mysql.x86_64","php", "php-mysql","httpd","wget","sendmail"] + frontend_packages_list = ["mysql.x86_64","php", "php-mysql","httpd","wget","sendmail", "git"] if(distro_version >= 7): service_mysqld_name = "mariadb" mysql_pkg_name = "mariadb-server" - frontend_packages_list = ["mariadb","php", "php-mysql","httpd","wget","sendmail"] + frontend_packages_list = ["mariadb","php", "php-mysql","httpd","wget","sendmail", "git"] elif (current_distro == "ubuntu"): pexpect_pkg_name = "python-pexpect" service_httpd_name = "apache2" service_mysqld_name = "mysql" mysql_pkg_name = "mysql-server" - frontend_packages_list = ["mysql-client","php5", "php5-mysql","libapache2-mod-php5","apache2","wget","sendmail"] + frontend_packages_list = ["mysql-client","php", "php-mysql","libapache2-mod-php","apache2","wget","sendmail", "git"] elif (current_distro == "opensuse"): pexpect_pkg_name = "python-pexpect" service_httpd_name = "apache2" service_mysqld_name = "mysql" mysql_pkg_name = "mysql-community-server" - frontend_packages_list = ["mysql-community-server-client","php5", "php5-mysql","apache2-mod_php5","apache2","wget", "sendmail"] + frontend_packages_list = ["mysql-community-server-client","php5", "php5-mysql","apache2-mod_php5","apache2","wget", "sendmail", "git"] elif (current_distro == "SUSE Linux"): pexpect_pkg_name = "python-pexpect" service_httpd_name = "apache2" service_mysqld_name = "mysql" mysql_pkg_name = "mysql" #service_command = "/etc/init.d/" - frontend_packages_list = ["mysql-client","php53", "php53-mysql","apache2-mod_php53","apache2","wget","sendmail"] + frontend_packages_list = ["mysql-client","php53", "php53-mysql","apache2-mod_php53","apache2","wget","sendmail", "git"] elif (current_distro == "sles"): pexpect_pkg_name = "python-pexpect" service_httpd_name = "apache2" service_mysqld_name = "mysql" mysql_pkg_name = "mariadb" - frontend_packages_list = ["mariadb-client","apache2-mod_php5","apache2","php5", "php5-mysql","wget","sendmail"] + frontend_packages_list = ["mariadb-client","apache2-mod_php5","apache2","php5", "php5-mysql","wget","sendmail", "git"] if(distro_version >= 12): service_mysqld_name = "mysql" mysql_pkg_name = "mariadb" - frontend_packages_list = ["mariadb-client","apache2-mod_php5","apache2","php5", "php5-mysql","wget","sendmail"] + frontend_packages_list = ["mariadb-client","apache2-mod_php5","apache2","php5", "php5-mysql","wget","sendmail", "git"] elif ((current_distro == "Red Hat") or (current_distro == "rhel")): pexpect_pkg_name = "pexpect" service_httpd_name = "httpd" service_mysqld_name = "mysqld" mysql_pkg_name = "mysql-server" - frontend_packages_list = ["mysql.x86_64","php", "php-mysql", "httpd" , "wget","sendmail"] + frontend_packages_list = ["mysql.x86_64","php", "php-mysql", "httpd" , "wget","sendmail", "git"] if(distro_version >= 7): service_mysqld_name = "mariadb" mysql_pkg_name = "mariadb-server" - frontend_packages_list = ["mariadb","mysql.x86_64","php", "php-mysql", "httpd" , "wget","sendmail"] + frontend_packages_list = ["mariadb","mysql.x86_64","php", "php-mysql", "httpd" , "wget","sendmail", "git"] singlevm_packages_list = frontend_packages_list + [mysql_pkg_name] RunLog.info( "set_variables_OS_dependent .. [done]") @@ -120,6 +121,18 @@ def DetectDistro(): matchObj = re.match( r'^VERSION_ID=(.*)', line, re.M|re.I) version = float(matchObj.group(1)) + if(version == "unknown"): + RunLog.info("Detecting Distro Version") + oslist = Run("echo '"+vm_password+"' | sudo -S ls /etc/*-release") + if("/etc/centos-release" in oslist): + version = float(Run("echo '"+vm_password+"' | sudo -S cat /etc/centos-release | sed s/.*release\ // | sed s/\ .*// ")) + elif("/etc/oracle-release" in oslist): + version = float(Run("echo '"+vm_password+"' | sudo -S cat /etc/oracle-release | sed s/.*release\ // | sed s/\ .*// ") ) + elif("/etc/redhat-release" in oslist): + version = float(Run("echo '"+vm_password+"' | sudo -S cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// ")) + else: + RunLog.info("Detected Distro Version : " +str(version)) + if(distribution == 'unknown'): for line in outputlist: if (re.match(r'.*ubuntu.*',line,re.M|re.I) ): @@ -320,9 +333,28 @@ def download_url(url, destination_folder): else: print rtrn return False + +def download_git_url(url, destination_folder): + RunLog.info("Downloading the WordPress from git URL...") + rtrn = Run("echo '"+vm_password+"' | sudo -S git clone "+url+" "+destination_folder+"wordpress 2>&1") + # Faild to find git package + if(rtrn.rfind("git command not found") != -1): + install_package("git") + rtrn = Run("echo '"+vm_password+"' | sudo -S git clone "+url+" "+destination_folder+"wordpress 2>&1") + RunLog.info("Downloading the WordPress from git URL... status...." + rtrn) + + rtrn = Run("echo '"+vm_password+"' | sudo -S ls "+destination_folder+"wordpress 2>&1") + if( rtrn.rfind("No such file or directory") == -1) : + RunLog.info("Downloading the WordPress from git URL... status...." + rtrn) + print rtrn + return True + else: + print rtrn + return False def install_packages_singleVM(): global wdp_install_folder + global wdp_configlink RunLog.info("Installing Packages in SingleVM") for package in singlevm_packages_list: @@ -338,9 +370,30 @@ def install_packages_singleVM(): RunLog.error("Aborting the installation.") end_the_script() - if(download_url(wdp_downlink, wdp_install_folder)): - RunLog.info("Wordpress package downloaded successfully") - Run("echo '"+vm_password+"' | sudo -S tar -xvf "+wdp_install_folder+"/latest.tar.gz -C "+wdp_install_folder) + if(".git" in wdp_downlink): + RunLog.info("Wordpress package is downloading from git" +wdp_downlink) + if(download_git_url(wdp_downlink, wdp_install_folder)): + RunLog.info("Wordpress package downloaded successfully") + else: + RunLog.info("Wordpress package downloaded failed.") + return False + elif(".tar" in wdp_downlink): + if(download_url(wdp_downlink, wdp_install_folder)): + RunLog.info("Wordpress package extraction is Started..") + Run("echo '"+vm_password+"' | sudo -S tar -xvzf "+wdp_install_folder+"/latest.tar.gz -C "+wdp_install_folder+" 2>&1") + RunLog.info("Wordpress package extract verification is Started..") + wdp_configfileStatus = Run("echo '"+vm_password+"' | sudo -S ls "+wdp_install_folder+"wordpress/wp-config-sample.php") + if("wp-config-sample.php" in wdp_configfileStatus): + RunLog.info(""+wdp_install_folder+"wordpress/wp-config-sample.php is there.. Wordpress extacred Successfully.. & update user, Db details for wordpress setup in config") + else: + RunLog.error(""+wdp_install_folder+"wordpress/wp-config-sample.php is NOT there.. So copy Sample-Config file") + if(download_url(wdp_configlink, wdp_install_folder)): + RunLog.info("wp-config-sample.php downloaded successfully") + Run("echo '"+vm_password+"' | sudo -S cp "+wdp_install_folder+"wp-config-sample.php -C "+wdp_install_folder+"/wordpress/ 2>&1") + return True + else: + RunLog.info("wp-config-sample.php downloaded failed.") + return False else: RunLog.info("Wordpress package downloaded failed.") return False @@ -388,14 +441,34 @@ def install_packages_frontend(): end_the_script() #Downloading "WordPress" from Web URL - #wdp_install_folder = get_apache_document_root() - if(download_url(wdp_downlink, wdp_install_folder)): - RunLog.info("Wordpress package downloaded successfully") - Run("echo '"+vm_password+"' | sudo -S tar -xvf "+wdp_install_folder+"/latest.tar.gz -C "+wdp_install_folder) + if(".git" in wdp_downlink): + RunLog.info("Wordpress package is downloading from git" +wdp_downlink) + if(download_git_url(wdp_downlink, wdp_install_folder)): + RunLog.info("Wordpress package downloaded successfully") + else: + RunLog.info("Wordpress package downloaded failed.") + return False + elif(".tar" in wdp_downlink): + if(download_url(wdp_downlink, wdp_install_folder)): + RunLog.info("Wordpress package extraction is Started..") + Run("echo '"+vm_password+"' | sudo -S tar -xvzf "+wdp_install_folder+"/latest.tar.gz -C "+wdp_install_folder+" 2>&1") + RunLog.info("Wordpress package extract verification is Started..") + wdp_configfileStatus = Run("echo '"+vm_password+"' | sudo -S ls "+wdp_install_folder+"wordpress/wp-config-sample.php") + if("wp-config-sample.php" in wdp_configfileStatus): + RunLog.info(""+wdp_install_folder+"wordpress/wp-config-sample.php is there.. Wordpress extacred Successfully.. & update user, Db details for wordpress setup in config") + else: + RunLog.error(""+wdp_install_folder+"wordpress/wp-config-sample.php is NOT there.. So copy Sample-Config file") + if(download_url(wdp_configlink, wdp_install_folder)): + RunLog.info("wp-config-sample.php downloaded successfully") + Run("echo '"+vm_password+"' | sudo -S cp "+wdp_install_folder+"wp-config-sample.php -C "+wdp_install_folder+"/wordpress/ 2>&1") + return True + else: + RunLog.info("wp-config-sample.php downloaded failed.") + return False else: RunLog.info("Wordpress package downloaded failed.") return False - + return True def mysql_secure_install(wdp_db_root_password): @@ -591,17 +664,28 @@ def disable_selinux(): def disable_iptables(): RunLog.info("Disabling IPPTABLES...") + iptablesInfo = Run ("echo '"+vm_password+"' | sudo -S iptables -nL") + RunLog.info("iptables status " +iptablesInfo) #Identify the Distro and disable the Firewall if (current_distro == 'ubuntu'): ufw = Run ("echo '"+vm_password+"' | sudo -S ufw disable") RunLog.info(ufw) - if ((current_distro == 'Red Hat') or (current_distro == 'rhel')): - Run ("echo '"+vm_password+"' | sudo -S service iptables save") - Run ("echo '"+vm_password+"' | sudo -S service iptables stop") - Run ("echo '"+vm_password+"' | sudo -S chkconfig iptables off") + elif ((current_distro == 'Red Hat') or (current_distro == 'rhel') or (current_distro == 'centos') or (current_distro == 'oracle')): + cmds = ("iptables -F","service iptables save","service iptables stop","chkconfig iptables off","service firewalld stop","chkconfig firewalld off") + output = exec_multi_cmds_local_sudo(cmds) + elif((current_distro == 'SUSE Linux')or(current_distro == 'sles') or (current_distro == "opensuse")): + cmds = ("/sbin/yast2 firewall startup manual","/sbin/rcSuSEfirewall2 stop","chkconfig SuSEfirewall2_setup off") + output = exec_multi_cmds_local_sudo(cmds) + output = Run("echo '"+vm_password+"' | sudo -S /sbin/rcSuSEfirewall2 status") + if((output.find('unused') != -1) or (output.find('dead') != -1)): + RunLog.info( "Diasabling iptables..[done]") + else: + RunLog.info( "Diasabling iptables..[failed]") else: - Run ("echo '"+vm_password+"' | sudo -S chkconfig iptables off") - Run ("echo '"+vm_password+"' | sudo -S chkconfig ip6tables off") + Run ("echo '"+vm_password+"' | sudo -S iptables -F") + + iptablesInfo = Run ("echo '"+vm_password+"' | sudo -S iptables -nL") + RunLog.info("iptables status " +iptablesInfo) RunLog.info("Disabling IPPTABLES...[done]") def setup_wordpress(): @@ -614,6 +698,7 @@ def setup_wordpress(): RunLog.error("Aborting the installation.") end_the_script() else: + RunLog.info("wp-config.php updating with user & DB credentails Started..") Run("echo '"+vm_password+"' | sudo -S cp "+wdp_install_folder+"wordpress/wp-config-sample.php "+wdp_install_folder+"wordpress/wp-config.php") Run("echo '"+vm_password+"' | sudo -S sed -i 's/database_name_here/" +wdp_db_name+ "/' "+wdp_install_folder+"wordpress/wp-config.php") Run("echo '"+vm_password+"' | sudo -S sed -i 's/username_here/"+wdp_db_username+"/' "+wdp_install_folder+"wordpress/wp-config.php") @@ -632,7 +717,7 @@ def UpdateRepos(): #Repo update for current_distro if ((current_distro == "ubuntu") or (current_distro == "Debian")): Run("echo '"+vm_password+"' | sudo -S apt-get update") - elif ((current_distro == "RedHat") or (current_distro == "rhel") or (current_distro == "Oracle") or (current_distro == "ol") or (current_distro == 'centos') or (current_distro == "fedora")): + elif ((current_distro == "Red Hat") or (current_distro == "rhel") or (current_distro == "Oracle") or (current_distro == "ol") or (current_distro == 'centos') or (current_distro == "fedora")): Run("echo '"+vm_password+"' | sudo -S yum -y update") elif (current_distro == "opensuse") or (current_distro == "SUSE Linux") or (current_distro == "sles"): Run("echo '"+vm_password+"' | sudo -S zypper --non-interactive --gpg-auto-import-keys update") @@ -693,8 +778,6 @@ def setup_wordpress_singleVM(): def setup_wordpress_E2ELoadBalance_backend(front_end_users): RunLog.info("Setup WordPress for E2ELoadbalancer Backend VM") - disable_selinux() - disable_iptables() # Installing packages in Backend VM Role if (not install_packages_backend()): @@ -708,7 +791,6 @@ def setup_wordpress_E2ELoadBalance_backend(front_end_users): end_the_script() # To make to connection from backend to other IP's ranging from 0.0.0.0 - #bind = Run("echo '"+vm_password+"' | sudo -S sed -i 's/\(bind-address.*= \)\(.*\)/\\1 0.0.0.0/' /etc/mysql/my.cnf | grep bind") bind = Run("echo '"+vm_password+"' | sudo -S sed -i 's/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/' /etc/mysql/my.cnf| grep bind") bind = Run("echo '"+vm_password+"' | sudo -S sed -i 's/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind") bind = Run("echo '"+vm_password+"' | sudo -S sed -i 's/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/' /etc/mysql/mariadb.conf.d/mysqld.cnf | grep bind") @@ -737,8 +819,6 @@ def setup_wordpress_E2ELoadBalance_backend(front_end_users): def setup_wordpress_E2ELoadBalance_frontend(): global wdp_install_folder RunLog.info("Setup WordPress for E2ELoadbalancer Frontend VM") - disable_selinux() - disable_iptables() # Installing packages in Front-end VM Role's if (not install_packages_frontend()): @@ -998,7 +1078,7 @@ def main(): frontend_count = 1 for ip in front_endVM_ips: RunLog.info("**********************************************************") - RunLog.info("\nConfiguring frontend"+str(frontend_count)+" at "+ip+":\n") + RunLog.info("Configuring frontend"+str(frontend_count)+" at "+ip+":\n") # TODO FIX TCP alive on Servers and restart the RunLog.info("Copying "+__file__+" to "+ ip) RunLog.info(put_file_sftp(front_endVM_username, front_endVM_password, ip, __file__)) @@ -1021,7 +1101,7 @@ def main(): wdp_db_hostname = sys.argv[2] setup_wordpress_E2ELoadBalance_frontend() #Reboot the Frontend1,2,3 - RunLog.info( "Rebooting the frontend....\n") + RunLog.info( "Wordpress setup done and Rebooting the frontend....\n") if (current_distro != "opensuse"): RunLog.info( exec_multi_cmds_local_sudo(["reboot"])) else: @@ -1047,6 +1127,9 @@ get_username_password_from_xml() set_variables_OS_dependent() UpdateRepos() +disable_selinux() +disable_iptables() + #check for availability of pexpect module try: imp.find_module('pexpect') @@ -1060,7 +1143,7 @@ except ImportError: RunLog.info( "pexpect module could not be installed") pythonversion = Run ("echo '"+vm_password+"' | sudo -S python --version 2>&1") if(pythonversion.find('Python 2.7.') or pythonversion.find('Python 3.')): - if((current_distro == 'sles') and (distro_version == "12")): + if((current_distro == 'sles') and (distro_version >= 12)): RunLog.info( "Trying to install pexpect module using rpm package") out = Run("echo '"+vm_password+"' | sudo -S rpm -ivh python-pexpect-3.1-1.1.noarch.rpm 2>&1") RunLog.info("out = "+out) diff --git a/remote-scripts/ICA-BUILD-LINUX-NEXT-DEB-PACKAGE.ps1 b/remote-scripts/ICA-BUILD-LINUX-NEXT-DEB-PACKAGE.ps1 index 33feb67..553fe4a 100644 --- a/remote-scripts/ICA-BUILD-LINUX-NEXT-DEB-PACKAGE.ps1 +++ b/remote-scripts/ICA-BUILD-LINUX-NEXT-DEB-PACKAGE.ps1 @@ -16,37 +16,13 @@ $SAName = $currentTestData.remoteSA $SAPrimaryKey = (Get-AzureStorageKey -StorageAccountName $SAName).Primary $SAContainer = $currentTestData.remoteSAContainer $remoteDebPath = $currentTestData.remoteDEBPath -$imageType = $currentTestData.imageType -$BaseOsImageName = GetOSImageFromDistro -Distro $Distro -xmlConfig $xmlConfig LogMsg "Remote Storage Account to copy deb package : $SAName" -Logmsg "Image type : $imageType" -if($imageType -imatch "Standard") -{ - LogMsg "BaseOsImageName : $BaseOsImageName" - LogMsg "Collecting latest $imageType ubuntu image from Azure gallery.." - $latestLinuxImage = (Get-AzureVMImage | where {$_.ImageName -imatch "Ubuntu-16_04-LTS-amd64-server" } | sort PublishedDate -Descending)[0].ImageName - LogMsg "Latest $imageType Image from Azure gallery : $latestLinuxImage" - $latestOsImage = SetOSImageToDistro -Distro $Distro -xmlConfig $xmlConfig -ImageName $latestLinuxImage - LogMsg "Is $imageType latestOsImage SET : $latestOsImage" -} -elseif($imageType -imatch "Daily") -{ - LogMsg "BaseOsImageName : $BaseOsImageName" - LogMsg "Collecting latest ubuntu $imageType image from Azure gallery" - $latestLinuxImage = (Get-AzureVMImage | where {$_.ImageName -imatch "Ubuntu_DAILY_BUILD-xenial-16_04-" } | sort PublishedDate -Descending)[0].ImageName - LogMsg "Latest $imageType Image from Azure gallery : $latestLinuxImage" - $latestOsImage = SetOSImageToDistro -Distro $Distro -xmlConfig $xmlConfig -ImageName $latestLinuxImage - LogMsg "Is $imageType latestOsImage SET : $latestOsImage" - -} $isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig if ($isDeployed) { try { - $allVMData = GetAllDeployementData -DeployedServices $isDeployed - Set-Variable -Name AllVMData -Value $allVMData [string] $ServiceName = $allVMData.ServiceName $hs1VIP = $allVMData.PublicIP $hs1ServiceUrl = $allVMData.URL