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

Improve new CLI testing ensuring complete coverage of arguments cases #652

Merged
merged 11 commits into from
Nov 17, 2023
26 changes: 23 additions & 3 deletions user_tools/src/spark_rapids_tools/cmdli/argprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ def validate_onprem_with_cluster_name(self):
'invalid_argument',
f'Cannot run cluster by name with platform [{CspEnv.ONPREM}]\n Error:')

def validate_onprem_with_cluster_props(self):
if self.platform == CspEnv.ONPREM:
raise PydanticCustomError(
'invalid_argument',
f'Cannot run cluster by properties with platform [{CspEnv.ONPREM}]\n Error:')

def init_extra_arg_cases(self) -> list:
return []

Expand Down Expand Up @@ -229,12 +235,19 @@ def get_or_set_platform(self) -> CspEnv:

def post_platform_assignment_validation(self, assigned_platform):
# do some validation after we decide the cluster type
if self.argv_cases[1] == ArgValueCase.VALUE_A:
if assigned_platform == CspEnv.ONPREM:
# it is not allowed to run cluster_by_name on an OnPrem platform
if assigned_platform == CspEnv.ONPREM:
cluster_case = self.argv_cases[1]
eventlogs_case = self.argv_cases[2]
if cluster_case == ArgValueCase.VALUE_A:
# it is not allowed to run cluster by name on an OnPrem platform
raise PydanticCustomError(
'invalid_argument',
f'Cannot run cluster by name with platform [{CspEnv.ONPREM}]\n Error:')
if cluster_case == ArgValueCase.VALUE_B and eventlogs_case == ArgValueCase.UNDEFINED:
# it is not allowed to run cluster by props on an OnPrem platform without eventlogs
raise PydanticCustomError(
'invalid_argument',
f'Cannot run cluster by properties with platform [{CspEnv.ONPREM}] without eventlogs\n Error:')


@dataclass
Expand Down Expand Up @@ -278,6 +291,13 @@ def define_invalid_arg_cases(self):
[ArgValueCase.VALUE_A, ArgValueCase.VALUE_A, ArgValueCase.IGNORE]
]
}
self.rejected['Cluster By Properties Cannot go with OnPrem'] = {
'valid': False,
'callable': partial(self.validate_onprem_with_cluster_props),
'cases': [
[ArgValueCase.VALUE_A, ArgValueCase.VALUE_C, ArgValueCase.UNDEFINED]
parthosa marked this conversation as resolved.
Show resolved Hide resolved
]
}

def define_detection_cases(self):
self.detected['Define Platform from Cluster Properties file'] = {
Expand Down
5 changes: 3 additions & 2 deletions user_tools/tests/spark_rapids_tools_ut/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import sys

import pytest # pylint: disable=import-error
import pytest # pylint: disable=import-error


def get_test_resources_path():
Expand Down Expand Up @@ -46,9 +46,10 @@ def gen_cpu_cluster_props():
# all csps except onprem
csps = ['dataproc', 'dataproc_gke', 'emr', 'databricks_aws', 'databricks_azure']
all_csps = csps + ['onprem']
autotuner_prop_path = 'worker_info.yaml'


class SparkRapidsToolsUT: # pylint: disable=too-few-public-methods
class SparkRapidsToolsUT: # pylint: disable=too-few-public-methods

@pytest.fixture(autouse=True)
def get_ut_data_dir(self):
Expand Down
19 changes: 19 additions & 0 deletions user_tools/tests/spark_rapids_tools_ut/resources/worker_info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
system:
numCores: 32
memory: 212992MiB
numWorkers: 5
gpu:
memory: 15109MiB
count: 4
name: T4
softwareProperties:
spark.driver.maxResultSize: 7680m
spark.driver.memory: 15360m
spark.executor.cores: '8'
spark.executor.instances: '2'
spark.executor.memory: 47222m
spark.executorEnv.OPENBLAS_NUM_THREADS: '1'
spark.scheduler.mode: FAIR
spark.sql.cbo.enabled: 'true'
spark.ui.port: '0'
spark.yarn.am.memory: 640m
Loading
Loading