From 4220e5ca9f819bcd3931f0e247a6fc20b92671b7 Mon Sep 17 00:00:00 2001 From: Eoin Gallinagh Date: Fri, 9 Feb 2024 16:25:16 +0000 Subject: [PATCH] add: update machinepool tests to identify machines based on label --- .../workflows/project-codeflare-release.yml | 75 +------------------ test/e2e/instascale_machinepool_test.go | 20 ++--- 2 files changed, 13 insertions(+), 82 deletions(-) diff --git a/.github/workflows/project-codeflare-release.yml b/.github/workflows/project-codeflare-release.yml index 6e2d75742..d771f91cc 100644 --- a/.github/workflows/project-codeflare-release.yml +++ b/.github/workflows/project-codeflare-release.yml @@ -10,15 +10,9 @@ on: replaces: description: 'The previous operator semantic version that this release replaces (for example: v0.0.0)' required: true - mcad-version: - description: 'Version of multi-cluster-app-dispatcher to be released (for example: v0.0.0)' - required: true codeflare-sdk-version: description: 'Version of CodeFlare-SDK to be released (for example: v0.0.0)' required: true - instascale-version: - description: 'Version of InstaScale to be released (for example: v0.0.0)' - required: true kuberay-version: description: 'Tested version of KubeRay (for example: v0.0.0)' required: true @@ -48,79 +42,13 @@ jobs: echo "Below are the release parameters set for the workflow:" echo "Operator Version: ${{ github.event.inputs.operator-version }}" echo "Replaces: ${{ github.event.inputs.replaces }}" - echo "MCAD Version: ${{ github.event.inputs.mcad-version }}" echo "CodeFlare SDK Version: ${{ github.event.inputs.codeflare-sdk-version }}" - echo "InstaScale Version: ${{ github.event.inputs.instascale-version }}" echo "Tested KubeRay Version: ${{ github.event.inputs.kuberay-version }}" echo "Is Stable: ${{ github.event.inputs.is-stable }}" echo "CodeFlare Repository Organization: ${{ github.event.inputs.codeflare-repository-organization }}" echo "Quay Organization: ${{ github.event.inputs.quay-organization }}" echo "Community Operators Prod Organization: ${{ github.event.inputs.community-operators-prod-organization }}" - release-mcad: - needs: check-kuberay-version - runs-on: ubuntu-latest - - steps: - - name: Check if MCAD release does exist - run: | - status_code=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases/tag/${{ github.event.inputs.mcad-version }}) - if [[ "$status_code" == "200" ]]; then - echo "MCAD release with version ${{ github.event.inputs.mcad-version }} already exist. Will not create MCAD release." - fi - echo "MCAD_RELEASE_STATUS_CODE=$status_code" >> $GITHUB_ENV - - - name: Release MCAD - run: | - gh workflow run mcad-release.yml --repo ${{ github.event.inputs.codeflare-repository-organization }}/multi-cluster-app-dispatcher --ref go-1.20 --field tag=${{ github.event.inputs.mcad-version }} - env: - GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} - shell: bash - if: ${{ env.MCAD_RELEASE_STATUS_CODE != '200' }} - - - name: Wait for MCAD run to finish - run: | - # wait for a while for Run to be started - sleep 5 - run_id=$(gh run list --workflow mcad-release.yml --repo ${{ github.event.inputs.codeflare-repository-organization }}/multi-cluster-app-dispatcher --limit 1 --json databaseId --jq .[].databaseId) - gh run watch ${run_id} --repo ${{ github.event.inputs.codeflare-repository-organization }}/multi-cluster-app-dispatcher --interval 10 --exit-status - env: - GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} - shell: bash - if: ${{ env.MCAD_RELEASE_STATUS_CODE != '200' }} - - release-instascale: - needs: release-mcad - runs-on: ubuntu-latest - - steps: - - name: Check if Instascale release does exist - run: | - status_code=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/project-codeflare/instascale/releases/tag/${{ github.event.inputs.instascale-version }}) - if [[ "$status_code" == "200" ]]; then - echo "Instascale release with version ${{ github.event.inputs.instascale-version }} already exist. Will not create Instascale release." - fi - echo "INSTASCALE_RELEASE_STATUS_CODE=$status_code" >> $GITHUB_ENV - - - name: Release InstaScale - run: | - gh workflow run instascale-release.yml --repo ${{ github.event.inputs.codeflare-repository-organization }}/instascale --ref ${{ github.ref }} --field tag=${{ github.event.inputs.instascale-version }} --field mcad-version=${{ github.event.inputs.mcad-version }} - env: - GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} - shell: bash - if: ${{ env.INSTASCALE_RELEASE_STATUS_CODE != '200' }} - - - name: Wait for InstaScale run to finish - run: | - # wait for a while for Run to be started - sleep 5 - run_id=$(gh run list --workflow instascale-release.yml --repo ${{ github.event.inputs.codeflare-repository-organization }}/instascale --limit 1 --json databaseId --jq .[].databaseId) - gh run watch ${run_id} --repo ${{ github.event.inputs.codeflare-repository-organization }}/instascale --interval 10 --exit-status - env: - GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} - shell: bash - if: ${{ env.INSTASCALE_RELEASE_STATUS_CODE != '200' }} - release-codeflare-sdk: needs: check-kuberay-version runs-on: ubuntu-latest @@ -169,7 +97,7 @@ jobs: if: ${{ env.SDK_RELEASE_STATUS_CODE != '200' }} release-codeflare-operator: - needs: [release-mcad, release-instascale, release-codeflare-sdk] + needs: [release-codeflare-sdk] runs-on: ubuntu-latest steps: @@ -203,3 +131,4 @@ jobs: echo "KubeRay release with version ${{ github.event.inputs.kuberay-version }} does not exist. Please select an existing version." exit 1 fi + \ No newline at end of file diff --git a/test/e2e/instascale_machinepool_test.go b/test/e2e/instascale_machinepool_test.go index 69fa037d3..64e53f8a8 100644 --- a/test/e2e/instascale_machinepool_test.go +++ b/test/e2e/instascale_machinepool_test.go @@ -17,6 +17,7 @@ limitations under the License. package e2e import ( + "fmt" "testing" . "github.com/onsi/gomega" @@ -49,14 +50,15 @@ func TestInstascaleMachinePool(t *testing.T) { connection := CreateOCMConnection(test) defer connection.Close() - // check existing cluster machine pool resources - // look for machine pool with aw name - expect not to find it - test.Expect(GetMachinePools(test, connection)). - ShouldNot(ContainElement(WithTransform(MachinePoolId, Equal("test-instascale-g4dn-xlarge")))) - // Setup batch job and AppWrapper aw := instaScaleJobAppWrapper(test, namespace, cm) + expectedLabel := fmt.Sprintf("%s-%s", aw.Name, aw.Namespace) + // check existing cluster machine pool resources + // look for a machine pool with a label key equal to aw.name-aw.namespace - expect NOT to find it + test.Expect(GetMachinePools(test, connection)). + ShouldNot(ContainElement(WithTransform(MachinePoolLabels, HaveKey(expectedLabel)))) + // apply AppWrapper to cluster _, err := test.Client().MCAD().WorkloadV1beta1().AppWrappers(namespace.Name).Create(test.Ctx(), aw, metav1.CreateOptions{}) test.Expect(err).NotTo(HaveOccurred()) @@ -66,15 +68,15 @@ func TestInstascaleMachinePool(t *testing.T) { test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutGpuProvisioning). Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))) - // look for machine pool with aw name - expect to find it + // look for a machine pool with a label key equal to aw.name-aw.namespace - expect to find it test.Eventually(MachinePools(test, connection), TestTimeoutLong). - Should(ContainElement(WithTransform(MachinePoolId, Equal("test-instascale-g4dn-xlarge")))) + Should(ContainElement(WithTransform(MachinePoolLabels, HaveKey(expectedLabel)))) test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutShort). Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateCompleted))) - // look for machine pool with aw name - expect not to find it + // look for a machine pool with a label key equal to aw.name-aw.namespace - expect NOT to find it test.Eventually(MachinePools(test, connection), TestTimeoutLong). - ShouldNot(ContainElement(WithTransform(MachinePoolId, Equal("test-instascale-g4dn-xlarge")))) + ShouldNot(ContainElement(WithTransform(MachinePoolLabels, HaveKey(expectedLabel)))) }