From 21314778dbd72565df1230357b5f27e64b14ab92 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 21 Feb 2024 13:53:02 +0530 Subject: [PATCH] feat: add memory check for runners for VTOrc Signed-off-by: Manan Gupta --- .github/workflows/cluster_endtoend_vtorc.yml | 9 +++++++++ .../workflows/cluster_endtoend_vtorc_mysql57.yml | 9 +++++++++ test/ci_workflow_gen.go | 11 +++++++++++ test/templates/cluster_endtoend_test.tpl | 13 +++++++++++++ test/templates/cluster_endtoend_test_mysql57.tpl | 13 +++++++++++++ 5 files changed, 55 insertions(+) diff --git a/.github/workflows/cluster_endtoend_vtorc.yml b/.github/workflows/cluster_endtoend_vtorc.yml index 39413d28cde..3dec9b0262d 100644 --- a/.github/workflows/cluster_endtoend_vtorc.yml +++ b/.github/workflows/cluster_endtoend_vtorc.yml @@ -43,6 +43,15 @@ jobs: draft=$(echo "$PR_DATA" | jq .draft -r) echo "is_draft=${draft}" >> $GITHUB_OUTPUT + - name: Check Memory + run: | + totalMem=$(free -g | awk 'NR==2 {print $2}') + echo "total memory $totalMem GB" + if [[ "$totalMem" -lt 15 ]]; then + echo "Less memory than required" + exit 1 + fi + - name: Check out code if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3 diff --git a/.github/workflows/cluster_endtoend_vtorc_mysql57.yml b/.github/workflows/cluster_endtoend_vtorc_mysql57.yml index c33b13a1323..dc9f3581a62 100644 --- a/.github/workflows/cluster_endtoend_vtorc_mysql57.yml +++ b/.github/workflows/cluster_endtoend_vtorc_mysql57.yml @@ -43,6 +43,15 @@ jobs: draft=$(echo "$PR_DATA" | jq .draft -r) echo "is_draft=${draft}" >> $GITHUB_OUTPUT + - name: Check Memory + run: | + totalMem=$(free -g | awk 'NR==2 {print $2}') + echo "total memory $totalMem GB" + if [[ "$totalMem" -lt 15 ]]; then + echo "Less memory than required" + exit 1 + fi + - name: Check out code if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3 diff --git a/test/ci_workflow_gen.go b/test/ci_workflow_gen.go index c60076e9766..d047d588f2a 100644 --- a/test/ci_workflow_gen.go +++ b/test/ci_workflow_gen.go @@ -137,6 +137,9 @@ var ( "vtgate_topo_consul", "tabletmanager_consul", } + clustersRequiringMemoryCheck = []string{ + "vtorc", + } clusterRequiring16CoresMachines = []string{ "onlineddl_vrepl", "onlineddl_vrepl_stress", @@ -154,6 +157,7 @@ type unitTest struct { type clusterTest struct { Name, Shard, Platform string FileName string + MemoryCheck bool MakeTools, InstallXtraBackup bool Docker bool LimitResourceUsage bool @@ -351,6 +355,13 @@ func generateClusterWorkflows(list []string, tpl string) { break } } + memoryCheckClusters := canonnizeList(clustersRequiringMemoryCheck) + for _, memCheckCluster := range memoryCheckClusters { + if memCheckCluster == cluster { + test.MemoryCheck = true + break + } + } xtraBackupClusters := canonnizeList(clustersRequiringXtraBackup) for _, xtraBackupCluster := range xtraBackupClusters { if xtraBackupCluster == cluster { diff --git a/test/templates/cluster_endtoend_test.tpl b/test/templates/cluster_endtoend_test.tpl index ef1a991c169..d75cdbe817d 100644 --- a/test/templates/cluster_endtoend_test.tpl +++ b/test/templates/cluster_endtoend_test.tpl @@ -41,6 +41,19 @@ jobs: draft=$(echo "$PR_DATA" | jq .draft -r) echo "is_draft=${draft}" >> $GITHUB_OUTPUT + {{if .MemoryCheck}} + + - name: Check Memory + run: | + totalMem=$(free -g | awk 'NR==2 {print $2}') + echo "total memory $totalMem GB" + if [[ "$totalMem" -lt 15 ]]; then + echo "Less memory than required" + exit 1 + fi + + {{end}} + - name: Check out code if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3 diff --git a/test/templates/cluster_endtoend_test_mysql57.tpl b/test/templates/cluster_endtoend_test_mysql57.tpl index 9f9e51fbc69..b4f528eeb2f 100644 --- a/test/templates/cluster_endtoend_test_mysql57.tpl +++ b/test/templates/cluster_endtoend_test_mysql57.tpl @@ -46,6 +46,19 @@ jobs: draft=$(echo "$PR_DATA" | jq .draft -r) echo "is_draft=${draft}" >> $GITHUB_OUTPUT + {{if .MemoryCheck}} + + - name: Check Memory + run: | + totalMem=$(free -g | awk 'NR==2 {print $2}') + echo "total memory $totalMem GB" + if [[ "$totalMem" -lt 15 ]]; then + echo "Less memory than required" + exit 1 + fi + + {{end}} + - name: Check out code if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3