diff --git a/.github/workflows/openstack.yml b/.github/workflows/openstack-centos-7.yml similarity index 86% rename from .github/workflows/openstack.yml rename to .github/workflows/openstack-centos-7.yml index 54a9e6bd..5d4a861f 100644 --- a/.github/workflows/openstack.yml +++ b/.github/workflows/openstack-centos-7.yml @@ -1,4 +1,4 @@ -name: Openstack Test Run +name: "Test Run: centos-7" on: push: @@ -11,7 +11,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-openstack + group: ${{ github.workflow }}-${{ github.ref }}-openstack-centos-7 cancel-in-progress: true env: @@ -29,7 +29,7 @@ env: TF_VAR_os_project_name: ${{ secrets.OS_PROJECT_NAME }} TF_VAR_os_region_name: ${{ secrets.OS_REGION_NAME }} TF_VAR_os_username: ${{ secrets.OS_USERNAME }} - tf_working_directory: "./.github/workflows/openstack/terraform" + tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7" jobs: testsuite: @@ -39,7 +39,7 @@ jobs: runs-on: self-hosted defaults: run: - working-directory: "./.github/workflows/openstack/terraform" + working-directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7" steps: - uses: actions/checkout@v4 - name: Terraform fmt @@ -48,11 +48,6 @@ jobs: terraform fmt -check continue-on-error: true - - name: DEBUGVAR - id: debugvar - run: | - env | awk 'tolower($0)~/auth|project_name/' - - name: Terraform Init id: init run: | @@ -66,7 +61,16 @@ jobs: - name: Terraform Apply id: apply run: | + pwd terraform apply -no-color -auto-approve + mv -v .terraform.lock.hcl terraform.lock.hcl + find $PWD + + - name: Upload Terraform State File as Artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: ${{ github.run_id }}-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/centos-7" - name: Terraform Output File Create run: | @@ -77,18 +81,11 @@ jobs: run: | echo "$(jq -r '.address.value' ${{ github.run_id }}-tf.out.json)" > ${{ github.workspace }}/${{ github.run_id }}-vm_ip - - name: Upload JSON Output - uses: actions/upload-artifact@v4 - with: - name: ${{ github.run_id }}-tf.out.json - path: ${{ github.workspace }}/ - overwrite: true - - name: Upload VM Output - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.4.3 with: name: ${{ github.run_id }}-vm_ip - path: ${{ github.workspace }}/ + path: ${{ github.workspace }}/${{ github.run_id }}-vm_ip overwrite: true clone_elevate_repo: @@ -98,7 +95,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -151,7 +148,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -186,7 +183,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -217,8 +214,9 @@ jobs: cp -pv /opt/${REPODIR}/.github/workflows/openstack/status_marker /scripts/status_marker cp -pv /opt/${REPODIR}/.github/workflows/openstack/reboot_watch /scripts/reboot_watch chmod -v +x /scripts/elevate-cpanel - /usr/local/cpanel/cpkeyclt + until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done /scripts/elevate-cpanel --non-interactive --skip-cpanel-version-check --start & + exit 0 wait_for_stage_1_reboot: runs-on: self-hosted @@ -227,7 +225,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -254,7 +252,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -281,8 +279,8 @@ jobs: debug: true script: | /scripts/status_marker 1 - /scripts/elevate-cpanel --log & - sleep 1.5 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep .5 REBOOT_STRING="Rebooting into stage 2 of 5" RETVAL=1 /scripts/reboot_watch wait_for_stage_2_reboot: @@ -292,7 +290,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -319,7 +317,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -346,8 +344,8 @@ jobs: debug: true script: | /scripts/status_marker 2 - /scripts/elevate-cpanel --log & - sleep 1.5 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep .5 REBOOT_STRING="Rebooting into stage 3 of 5" RETVAL=1 /scripts/reboot_watch wait_for_stage_3_reboot: @@ -357,7 +355,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -384,7 +382,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -410,8 +408,8 @@ jobs: command_timeout: 30m script: | /scripts/status_marker 3 - /scripts/elevate-cpanel --log & - sleep 1.5 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep .5 REBOOT_STRING="Rebooting into stage 4 of 5" RETVAL=1 /scripts/reboot_watch wait_for_stage_4_reboot: @@ -421,7 +419,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -448,7 +446,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -474,8 +472,8 @@ jobs: command_timeout: 35m script: | /scripts/status_marker 4 - /scripts/elevate-cpanel --log & - sleep 1.5 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep .5 REBOOT_STRING="Rebooting into stage 5 of 5" RETVAL=1 /scripts/reboot_watch wait_for_stage_5_reboot: @@ -485,7 +483,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -512,7 +510,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -538,8 +536,8 @@ jobs: command_timeout: 35m script: | /scripts/status_marker 5 - /scripts/elevate-cpanel --log & - sleep 1.5 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep 2.5 SKIP_PID_CHECK=1 REBOOT_STRING="Doing final reboot" RETVAL=1 /scripts/reboot_watch wait_for_final_reboot: @@ -549,7 +547,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -576,7 +574,7 @@ jobs: VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} steps: - name: Download VM IP - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v4.1.8 with: name: ${{ github.run_id }}-vm_ip path: ${{ github.workspace }}/ @@ -603,18 +601,31 @@ jobs: script: | REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/*.t + /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/centos7-to-almalinux8/*.t terraform_openstack_destroy: runs-on: self-hosted needs: verify_upgraded_os defaults: run: - working-directory: "./.github/workflows/openstack/terraform" + working-directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7" steps: - - name: Download Terraform Output JSON - uses: actions/download-artifact@v4 + - name: Download Terraform State + uses: actions/download-artifact@v4.1.8 with: - name: ${{ github.run_id }}-tf.out.json - path: ${{ github.workspace }}/tf.out.json - - name: Destroy OpenStack VM - run: terraform destroy -no-color -auto-approve + name: ${{ github.run_id }}-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform" + + + - name: Stage Files & Show Artifact Paths + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform/ + mv -v terraform.lock.hcl .terraform.lock.hcl + find ${{ github.workspace }}/.github/workflows/openstack/centos-7/ + + - name: Initialize Terraform & Destroy + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/centos-7/terraform/ + rm -Rfv .terraform || true + terraform init + terraform destroy -no-color -auto-approve diff --git a/.github/workflows/openstack-cloudlinux-7.yml b/.github/workflows/openstack-cloudlinux-7.yml new file mode 100644 index 00000000..a2d99c05 --- /dev/null +++ b/.github/workflows/openstack-cloudlinux-7.yml @@ -0,0 +1,652 @@ +name: "Test Run: cloudlinux-7" + +on: + push: + branches: + - "main" + - '!docs' + tags-ignore: + - "*" + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-openstack-cloudlinux-7 + cancel-in-progress: true + +env: + TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} + TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} + TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} + TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }} + TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }} + TF_VAR_os_auth_url: ${{ secrets.OS_AUTH_URL }} + TF_VAR_os_interface: ${{ secrets.OS_INTERFACE }} + TF_VAR_os_project_domain_name: ${{ secrets.OS_PROJECT_DOMAIN_NAME }} + TF_VAR_os_password: ${{ secrets.OS_PASSWORD }} + TF_VAR_os_project_id: ${{ secrets.OS_PROJECT_ID }} + TF_VAR_os_project_domain_id: ${{ secrets.OS_PROJECT_DOMAIN_ID }} + TF_VAR_os_project_name: ${{ secrets.OS_PROJECT_NAME }} + TF_VAR_os_region_name: ${{ secrets.OS_REGION_NAME }} + TF_VAR_os_username: ${{ secrets.OS_USERNAME }} + tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7" + +jobs: + testsuite: + uses: ./.github/workflows/testsuite.yml + terraform_openstack_create: + needs: [testsuite] + runs-on: self-hosted + defaults: + run: + working-directory: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7" + steps: + - uses: actions/checkout@v4 + - name: Terraform fmt + id: fmt + run: | + terraform fmt -check + continue-on-error: true + + - name: Terraform Init + id: init + run: | + terraform init + + - name: Terraform Plan + id: plan + run: | + terraform plan -no-color + + - name: Terraform Apply + id: apply + run: | + pwd + terraform apply -no-color -auto-approve + mv -v .terraform.lock.hcl terraform.lock.hcl + find $PWD + + - name: Upload Terraform State File as Artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: ${{ github.run_id }}-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7" + + - name: Terraform Output File Create + run: | + terraform output -json > ${{ github.run_id }}-tf.out.json + + - name: Make vm_ip file from Terraform Output File + id: get_vm_ip + run: | + echo "$(jq -r '.address.value' ${{ github.run_id }}-tf.out.json)" > ${{ github.workspace }}/${{ github.run_id }}-vm_ip + + - name: Upload VM Output + uses: actions/upload-artifact@v4.4.3 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/${{ github.run_id }}-vm_ip + overwrite: true + + clone_elevate_repo: + runs-on: self-hosted + needs: terraform_openstack_create + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Checkout Repo and Commit + if: github.event_name != 'pull_request' + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + cd /opt + echo "## [INFO]: ${{ github.ref }}" + echo "## [INFO]: ${{ github.ref_name }}" + echo "## [INFO}: ${{ github.repository }}" + git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/${{ github.repository }}.git + hostname && pwd && ls -la + cd /opt/$(echo ${{ github.repository }} | cut -d / -f2) + git status + + - name: Checking out Repo and Pull Request + if: github.event_name == 'pull_request' + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + cd /opt + echo "[DEBUG]: ${{ github.ref }}" + echo "[DEBUG]: ${{ github.head_ref }}" + echo "## [INFO}: ${{ github.repository }}" + git clone --depth 1 --branch ${{ github.head_ref }} https://github.com/${{ github.repository }}.git + cd /opt/$(echo ${{ github.repository }} | cut -d / -f2) + git status + + setup_integration_checks: + runs-on: self-hosted + needs: clone_elevate_repo + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + + - name: Setup for Integration Checks Prior to Running Elevate + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + chmod -v +x /opt/${REPODIR}/t/integration/setup + /opt/${REPODIR}/t/integration/setup + + start_elevate: + runs-on: self-hosted + needs: setup_integration_checks + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + + - name: Update CloudLinux License + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 30m + command_timeout: 30m + script: | + /usr/sbin/rhnreg_ks --activationkey=${{ secrets.CLOUDLINUX_LICENSE_KEY }} --force + /usr/bin/cldetect --update-license + /usr/bin/cldetect --check-license + until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done + + - name: Starting Elevate + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 30m + command_timeout: 30m + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + cp -pv /opt/${REPODIR}/elevate-cpanel /scripts/elevate-cpanel + chmod -v +x /scripts/elevate-cpanel + cp -pv /opt/${REPODIR}/.github/workflows/openstack/status_marker /scripts/status_marker + cp -pv /opt/${REPODIR}/.github/workflows/openstack/reboot_watch /scripts/reboot_watch + /usr/bin/yum erase -y awscli + echo "yum reinstall -y `yum list installed | awk '$3~/cloudlinux-x86_64-server/{printf "%s ", $1}'` --disablerepo=cloudlinux-x86_64-server --enablerepo=cloudlinux-base --enablerepo=cloudlinux-updates" | sh + mv -v /etc/yum.repos.d/clmirror.repo /root/ + /usr/bin/yum clean all + echo "## [INFO]: Removing /etc/yum/pluginconf.d/rhnplugin.conf" && rm -fv /etc/yum/pluginconf.d/rhnplugin.conf + until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done + /usr/bin/yum makecache + /scripts/elevate-cpanel --non-interactive --skip-cpanel-version-check --start & + + wait_for_stage_1_reboot: + runs-on: self-hosted + needs: start_elevate + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Initial Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_2_reboot: + runs-on: self-hosted + needs: wait_for_stage_1_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Reboot from Stage 1 into Stage 2 + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 60m + command_timeout: 30m + debug: true + script: | + /scripts/status_marker 1 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep 1.5 + REBOOT_STRING="Rebooting into stage 2 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_2_reboot: + runs-on: self-hosted + needs: watch_for_stage_2_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 2 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_3_reboot: + runs-on: self-hosted + needs: wait_for_stage_2_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 3 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 60m + command_timeout: 30m + debug: true + script: | + /scripts/status_marker 2 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep 1.5 + REBOOT_STRING="Rebooting into stage 3 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_3_reboot: + runs-on: self-hosted + needs: watch_for_stage_3_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 3 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_4_reboot: + runs-on: self-hosted + needs: wait_for_stage_3_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 4 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 60m + command_timeout: 50m + script: | + /scripts/status_marker 3 + yum makecache + tail -n40 -F /var/log/elevate-cpanel.log& + sleep 1.5 + REBOOT_STRING="Rebooting into stage 4 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_4_reboot: + runs-on: self-hosted + needs: watch_for_stage_4_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 4 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_5_reboot: + runs-on: self-hosted + needs: wait_for_stage_4_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 5 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 45m + command_timeout: 35m + script: | + /scripts/status_marker 4 + tail -n40 -F /var/log/elevate-cpanel.log& + sleep 300 + REBOOT_STRING="cPanel & WHM updates are disabled via cron because they are set to" /scripts/reboot_watch + + wait_for_stage_5_reboot: + runs-on: self-hosted + needs: watch_for_stage_5_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 5 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + echo "## [INFO]: Sleeping 37 seconds to try and slam the timing on this tricky reboot sequence." + sleep 37 + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_final_reboot: + runs-on: self-hosted + needs: wait_for_stage_5_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Final Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 45m + command_timeout: 35m + script: | + /scripts/status_marker 5 + tail -n40 -F /var/log/elevate-cpanel.log& + SKIP_PID_CHECK=1 REBOOT_STRING="Doing final reboot" RETVAL=1 /scripts/reboot_watch + + wait_for_final_reboot: + runs-on: self-hosted + needs: watch_for_final_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Final Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + verify_upgraded_os: + runs-on: self-hosted + needs: wait_for_final_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Verify End Result Integration Tests + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 5m + command_timeout: 1m + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/*.t + /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/cloudlinux7-to-cloudlinux8/*.t + + terraform_openstack_destroy: + runs-on: self-hosted + needs: verify_upgraded_os + defaults: + run: + working-directory: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7" + steps: + - name: Download Terraform State + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7/terraform" + + - name: Stage Files & Show Artifact Paths + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7/terraform/ + mv -v terraform.lock.hcl .terraform.lock.hcl + find ${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7/ + + - name: Initialize Terraform & Destroy + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/cloudlinux-7/terraform/ + rm -Rfv .terraform || true + terraform init + terraform destroy -no-color -auto-approve diff --git a/.github/workflows/openstack/terraform/cloud-config.yaml b/.github/workflows/openstack/centos-7/cloud-config.yaml similarity index 100% rename from .github/workflows/openstack/terraform/cloud-config.yaml rename to .github/workflows/openstack/centos-7/cloud-config.yaml diff --git a/.github/workflows/openstack/terraform/cloud-init.yml b/.github/workflows/openstack/centos-7/cloud-init.yml similarity index 100% rename from .github/workflows/openstack/terraform/cloud-init.yml rename to .github/workflows/openstack/centos-7/cloud-init.yml diff --git a/.github/workflows/openstack/terraform/main.tf b/.github/workflows/openstack/centos-7/main.tf similarity index 100% rename from .github/workflows/openstack/terraform/main.tf rename to .github/workflows/openstack/centos-7/main.tf diff --git a/.github/workflows/openstack/terraform/outputs.tf b/.github/workflows/openstack/centos-7/outputs.tf similarity index 100% rename from .github/workflows/openstack/terraform/outputs.tf rename to .github/workflows/openstack/centos-7/outputs.tf diff --git a/.github/workflows/openstack/terraform/variables.tf b/.github/workflows/openstack/centos-7/variables.tf similarity index 99% rename from .github/workflows/openstack/terraform/variables.tf rename to .github/workflows/openstack/centos-7/variables.tf index e55b66a3..7806ea96 100644 --- a/.github/workflows/openstack/terraform/variables.tf +++ b/.github/workflows/openstack/centos-7/variables.tf @@ -52,4 +52,4 @@ variable "cpanel_release_version" { variable "flavor_name" { type = string default = "c2.d20.r2048" -} \ No newline at end of file +} diff --git a/.github/workflows/openstack/cloudlinux-7/cloud-config.yaml b/.github/workflows/openstack/cloudlinux-7/cloud-config.yaml new file mode 100644 index 00000000..0445e91b --- /dev/null +++ b/.github/workflows/openstack/cloudlinux-7/cloud-config.yaml @@ -0,0 +1,5 @@ +--- + users: + - name: root + lock_passwd: false + disable_root: false \ No newline at end of file diff --git a/.github/workflows/openstack/cloudlinux-7/cloud-init.yml b/.github/workflows/openstack/cloudlinux-7/cloud-init.yml new file mode 100644 index 00000000..1602682e --- /dev/null +++ b/.github/workflows/openstack/cloudlinux-7/cloud-init.yml @@ -0,0 +1,6 @@ +#cloud-config +disable_root: false +ssh_pwauth: true +hostname: host +fqdn: host.domain.tbd +prefer_fqdn_over_hostname: true diff --git a/.github/workflows/openstack/cloudlinux-7/main.tf b/.github/workflows/openstack/cloudlinux-7/main.tf new file mode 100644 index 00000000..22f1cedd --- /dev/null +++ b/.github/workflows/openstack/cloudlinux-7/main.tf @@ -0,0 +1,82 @@ +# Define required providers +terraform { + required_version = ">= 0.14.0" + required_providers { + openstack = { + source = "terraform-provider-openstack/openstack" + version = "~> 1.54.1" + } + } +} + +# Configure the OpenStack Provider +provider "openstack" { + user_name = var.user + application_credential_id = var.application_credential_id + application_credential_secret = var.application_credential_secret + auth_url = "https://keystone.hou-01.cloud.prod.cpanel.net:5000/v3" + region = var.os_auth_region +} + +data "openstack_images_image_ids_v2" "images" { + name_regex = var.image_name + sort = "updated_at" +} + +data "template_cloudinit_config" "config" { + gzip = true + base64_encode = true + + part { + content_type = "text/cloud-config" + content = "cloud-config.yaml" + } +} + +resource "tls_private_key" "ssh" { + algorithm = "ECDSA" + ecdsa_curve = "P384" +} + +resource "random_string" "keyname" { + length = 22 + special = false +} + +resource "openstack_compute_keypair_v2" "tf_remote_key" { + name = "${random_string.keyname.result}-deletethis" + public_key = tls_private_key.ssh.public_key_openssh +} + +resource "openstack_compute_instance_v2" "elevatevm" { + name = "elevate.github.cpanel.net" + image_id = data.openstack_images_image_ids_v2.images.ids[0] + flavor_name = var.flavor_name + key_pair = openstack_compute_keypair_v2.tf_remote_key.name + user_data = data.template_cloudinit_config.config.rendered + network { + name = "hou-prod-external" + } + + provisioner "remote-exec" { + inline = [<> /root/.ssh/id_ed25519 + echo "${var.ssh_public_key}" >> /root/.ssh/authorized_keys + echo 'waiting on cloud-init...' + cloud-init status --wait > /dev/null || true + EOF + ] + connection { + type = "ssh" + agent = "false" + host = self.access_ip_v4 + user = "root" + script_path = "/root/elevate_bootstrap" + private_key = tls_private_key.ssh.private_key_pem + } + } +} + diff --git a/.github/workflows/openstack/cloudlinux-7/outputs.tf b/.github/workflows/openstack/cloudlinux-7/outputs.tf new file mode 100644 index 00000000..396221f0 --- /dev/null +++ b/.github/workflows/openstack/cloudlinux-7/outputs.tf @@ -0,0 +1,7 @@ +output "address" { + value = openstack_compute_instance_v2.elevatevm.access_ip_v4 +} + +output "id" { + value = openstack_compute_instance_v2.elevatevm.id +} \ No newline at end of file diff --git a/.github/workflows/openstack/cloudlinux-7/variables.tf b/.github/workflows/openstack/cloudlinux-7/variables.tf new file mode 100644 index 00000000..c9df47af --- /dev/null +++ b/.github/workflows/openstack/cloudlinux-7/variables.tf @@ -0,0 +1,55 @@ +variable "user" { + type = string + default = "resu" +} + +variable "application_credential_id" { + type = string +} + +variable "application_credential_secret" { + type = string +} + +variable "os_password" { + type = string +} + +variable "os_auth_region" { + type = string +} + +variable "os_auth_url" { + type = string +} + +variable "os_project_domain_name" { + type = string +} + +variable "ssh_private_key" { + type = string + description = "SSH private key matching the public key added to the VMs /root/.ssh/authorized_keys file to allow user access." + sensitive = true +} + +variable "ssh_public_key" { + type = string + description = "SSH public key matching the public key added to the VMs /root/.ssh/authorized_keys file to allow user access." + sensitive = true +} + +variable "image_name" { + type = string + default = "11.110.0.* on CloudLinux 7" +} + +variable "cpanel_release_version" { + type = string + default = "110" +} + +variable "flavor_name" { + type = string + default = "c2.d20.r2048" +} \ No newline at end of file diff --git a/.github/workflows/openstack/reboot_watch b/.github/workflows/openstack/reboot_watch index 75bbc185..cfcc0abf 100755 --- a/.github/workflows/openstack/reboot_watch +++ b/.github/workflows/openstack/reboot_watch @@ -39,6 +39,7 @@ sub _check_elevate_log_for_REBOOT_STRING { my $has_continued = 0; $file = File::Tail->new( name => $filepath, maxinterval => 1, adjustafter => 5, interval => 1 ); + while ( defined( $line = $file->read ) ) { # Lines that match ERROR or FATAL are an indication that the script diff --git a/.github/workflows/openstack/ssh_retry b/.github/workflows/openstack/ssh_retry index a32ecb38..08065c7a 100755 --- a/.github/workflows/openstack/ssh_retry +++ b/.github/workflows/openstack/ssh_retry @@ -6,12 +6,12 @@ my $HOST = $ARGV[0]; my $PORT = $ARGV[1] // 22; my $RETVAL = 1; my $RETRIES = 0; -my $RETRY = $ARGV[2] // 900; +my $RETRY = $ARGV[2] // 1200; # Bumping this to 20 minutes per cloudlinux Stage 4 averaging right at 15 mins return unless defined $HOST; while ( $RETVAL != 0 ) { - my $cmd = qq{ /usr/bin/nc -z -w 3 $HOST $PORT }; + my $cmd = qq{ /usr/bin/nc -z -w 1 $HOST $PORT }; my $output = `$cmd`; my $time = POSIX::strftime( "%Y-%m-%d %H:%M:%S", localtime ); diff --git a/.github/workflows/openstack/status_marker b/.github/workflows/openstack/status_marker index f26776ab..0da481e2 100755 --- a/.github/workflows/openstack/status_marker +++ b/.github/workflows/openstack/status_marker @@ -6,7 +6,7 @@ my $CPANEL_VERSION = `cat /usr/local/cpanel/version`; use strict; -print "######################################\n"; +print "###################################\n"; sub main { my @arr = ( @@ -16,7 +16,7 @@ sub main { for my $row (@arr) { format STDOUT = -@<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<< +@<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @$row . write; @@ -26,4 +26,4 @@ sub main { main(); -print "######################################\n"; +print "###################################\n"; diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index e50fe92c..59e2b96f 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -21,43 +21,37 @@ jobs: PERL_USE_UNSAFE_INC: 1 CPANEL_BIN_PATH: /usr/local/cpanel/3rdparty/bin CPANEL_PERL: /usr/local/cpanel/3rdparty/perl/536/bin/perl + ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node20 + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true runs-on: ubuntu-latest - # Note: the container is not a CentOS 7 distro - # this is ok if we use it for unit test purpose - # we are also relying on e2e test using C7 VM on self-hosted runner. + strategy: + fail-fast: false + container: - image: cpanelos/perl-compiler:alma8-perl-v5.36.0 + image: cpanelos/perl-compiler:perl-v5.36.0 steps: - + - name: Checkout + uses: actions/checkout@v3 - name: Setup PATH run: | - echo $CPANEL_BIN_PATH >> $GITHUB_PATH; - $CPANEL_PERL -MConfig -E 'say $Config{sitebin}' >> $GITHUB_PATH - $CPANEL_PERL -MConfig -E 'say $Config{vendorbin}' >> $GITHUB_PATH - - - name: Checkout - uses: actions/checkout@v4 - + echo $CPANEL_BIN_PATH >> $GITHUB_PATH; + $CPANEL_PERL -MConfig -E 'say $Config{sitebin}' >> $GITHUB_PATH + $CPANEL_PERL -MConfig -E 'say $Config{vendorbin}' >> $GITHUB_PATH - run: perl -V - - - name: cpanel-setup - run: /bin/bash t/cpanel-setup - - - name: Install Extra Perl dependencies - uses: perl-actions/install-with-cpm@v1 + - name: install Perl dependencies + uses: perl-actions/install-with-cpm@v1.7 with: sudo: false cpanfile: "t/cpanfile" args: "--with-all" - + - name: cpanel-setup + run: /bin/bash t/cpanel-setup - name: which prove run: ls -l $(which prove) - - run: perl -cw elevate-cpanel - - name: Run tests run: prove -lv -It/lib t/*.t diff --git a/t/integration/centos7-to-almalinux8/complete.t b/t/integration/centos7-to-almalinux8/complete.t new file mode 100644 index 00000000..ea02d222 --- /dev/null +++ b/t/integration/centos7-to-almalinux8/complete.t @@ -0,0 +1,19 @@ +#!/usr/local/cpanel/3rdparty/bin/perl + +# Copyright 2024 WebPros International, LLC +# All rights reserved. +# copyright@cpanel.net http://cpanel.net +# This code is subject to the cPanel license. Unauthorized copying is prohibited. + +use lib '/usr/local/cpanel/'; + +use Cpanel::OS (); +use Cpanel::SafeRun::Simple (); + +use Test::More tests => 2; + +use Data::Dumper; + +is( Cpanel::OS->distro(), 'almalinux', 'System is Almalinux after upgrade.' ); +is( Cpanel::OS->major(), '8', 'Verson 8 of OS.' ); + diff --git a/t/integration/cloudlinux7-to-cloudlinux8/complete.t b/t/integration/cloudlinux7-to-cloudlinux8/complete.t new file mode 100644 index 00000000..747dac1d --- /dev/null +++ b/t/integration/cloudlinux7-to-cloudlinux8/complete.t @@ -0,0 +1,19 @@ +#!/usr/local/cpanel/3rdparty/bin/perl + +# Copyright 2024 WebPros International, LLC +# All rights reserved. +# copyright@cpanel.net http://cpanel.net +# This code is subject to the cPanel license. Unauthorized copying is prohibited. + +use lib '/usr/local/cpanel/'; + +use Cpanel::OS (); +use Cpanel::SafeRun::Simple (); + +use Test::More tests => 2; + +use Data::Dumper; + +is( Cpanel::OS->distro(), 'cloudlinux', 'System is Almalinux after upgrade.' ); +is( Cpanel::OS->major(), '8', 'Verson 8 of OS.' ); + diff --git a/t/integration/complete.t b/t/integration/complete.t index 94c9b941..0a6f96fb 100644 --- a/t/integration/complete.t +++ b/t/integration/complete.t @@ -8,73 +8,16 @@ use lib '/usr/local/cpanel/'; use Cpanel::OS (); -use Cpanel::JSON (); use Cpanel::SafeRun::Simple (); -use Test::More; +use Test::More tests => 7; -# "Poor man's" FailWarnings -$SIG{'__WARN__'} = sub { fail("Warning detected: $_[0]"); }; +use Data::Dumper; is( Cpanel::OS->distro(), 'almalinux', 'System is Almalinux after upgrade.' ); is( Cpanel::OS->major(), '8', 'Verson 8 of OS.' ); is( -e '/var/log/elevate-cpanel.log', 1, 'Elevate log exists.' ); - -note "Gather service status..."; -my $svcstatus = run_api(qw{whmapi1 servicestatus}); -if ( ref $svcstatus->{'data'}{'service'} eq 'ARRAY' ) { - foreach my $svc_info ( $svcstatus->{'data'}{'service'}->@* ) { - next if !$svc_info->{'enabled'} || $svc_info->{'name'} eq 'mailman' || $svc_info->{'name'} eq 'tailwatchd' || $svc_info->{'name'} eq 'imunify360'; - ok( $svc_info->{'running'}, "$svc_info->{'name'} is running" ); - } -} -ok( run(qw{pgrep elevate}) eq '', 'No instance of elevate-cpanel currently running.' ); - -# Do some basic checks for other things -# Sadly, we don't ship anything useful for login checks, so just use curl -my $login_url = run('/usr/sbin/whmlogin'); -my $content = curl($login_url); -like( $content, qr/WHM/, "WHM is able to be logged into" ); - -like( run( qw{/usr/bin/bash -c}, 'echo "SHOW DATABASES" | mysql' ), qr/information_schema/, "MySQL seems OK" ); - -# XXX TODO randomize this, I really wish I had t/qa tools here. Also need to set allowunreg, etc. ;_; -note "Creating an account for testing..."; -run_api( qw{whmapi1 set_tweaksetting value=1}, "key=$_" ) for qw{allowunregistereddomains allowremotedomains}; -my $user = run_api(qw{whmapi1 createacct domain=azurediamond.test user=azurediamond pass=H4nt3r2_Als0_B1FF_R00LZ}); -note "Waiting on taskqueue..."; -run(qw{/usr/local/cpanel/3rdparty/bin/servers_queue run}); -$login_url = run_api(qw{whmapi1 create_user_session user=azurediamond service=cpaneld})->{'data'}{'url'}; -$content = curl($login_url); -like( $content, qr/<title>cPanel/, "cPanel is able to be logged into with newly created user" ); - -# Delete the account. Possibly should be done in an END block but meh. -# VM will get whacked after pipeline runs, so *for now* this should be fine. -note "Deleting created account..."; -run_api(qw{whmapi1 removeacct user=azurediamond}); - -done_testing(); - -# Less typing, it all needs the chomp -sub run { - my $out = Cpanel::SafeRun::Simple::saferun(@_); - chomp $out; - return $out; -} - -sub curl { - return run( qw{curl -s -k -L}, @_ ); -} - -# Returns HASHREF. For "script only opts" like --user, etc., use `--` to separate after API args. -sub run_api { - my ( $api, @call_args ) = @_; - my $out = {}; - { - local $@; - $out = eval { Cpanel::JSON::Load( run( "/usr/local/cpanel/bin/$api", '--output=json', @call_args ) ) }; - warn $@ if $@; - } - warn "$api @call_args failed: $out->{'metadata'}{'reason'}" if !$out->{'metadata'}{'result'}; - return $out; -} +like( Cpanel::SafeRun::Simple::saferun( '/bin/sh', '-c', '/scripts/restartsrv_httpd --status' ), qr/is running as root/, 'Apache is up and accepting connections.' ); +like( Cpanel::SafeRun::Simple::saferun( '/bin/sh', '-c', '/scripts/restartsrv_cpsrvd --status' ), qr/is running as root/, 'Chksrvd is up and accepting connections.' ); +like( Cpanel::SafeRun::Simple::saferun( '/bin/sh', '-c', '/scripts/restartsrv_named --status' ), qr/is running as named/, 'Nameserver is up and accepting connections.' ); +ok( Cpanel::SafeRun::Simple::saferun( '/bin/sh', '-c', 'pgrep elevate' ) eq '', 'No instance of elevate-cpanel currently running.' );