Files
kuberay/tests/framework/test_sample_rayservice_yamls.py
Dmitri GekhtmanandGitHub 5d38edac57 Revise sample configs, increase memory requests, update Ray versions (#761)
This PR

- Cleans up and updates sample configs and test files
- Increments Ray versions to the latest Ray release (2.1.0)
- Memory resource requests are increased in some sample configs.
- The Ray head pod has a high risk of running out of memory if it is allocated less than 2Gb memory, so that's fixed.

Signed-off-by: Dmitri Gekhtman <[email protected]>
2022-12-01 14:10:51 -08:00

53 lines
1.6 KiB
Python

''' Test sample RayService YAML files to catch invalid and outdated ones. '''
import unittest
import os
import logging
import yaml
from prototype import (
RuleSet,
GeneralTestCase,
RayServiceAddCREvent,
EasyJobRule,
CurlServiceRule,
CONST
)
logger = logging.getLogger(__name__)
if __name__ == '__main__':
NAMESPACE = 'default'
SAMPLE_PATH = '../../ray-operator/config/samples/'
YAMLs = ['ray_v1alpha1_rayservice.yaml']
sample_yaml_files = []
for filename in YAMLs:
with open(SAMPLE_PATH+filename, encoding="utf-8") as cr_yaml:
for k8s_object in yaml.safe_load_all(cr_yaml):
sample_yaml_files.append(
{'path': SAMPLE_PATH+filename, 'name': filename, 'cr': k8s_object}
)
rs = RuleSet([EasyJobRule(), CurlServiceRule()])
image_dict = {
CONST.RAY_IMAGE_KEY: os.getenv('RAY_IMAGE', default='rayproject/ray:2.1.0'),
CONST.OPERATOR_IMAGE_KEY: os.getenv('OPERATOR_IMAGE', default='kuberay/operator:nightly'),
}
logger.info(image_dict)
# Build a test plan
logger.info("Build a test plan ...")
test_cases = unittest.TestSuite()
for index, new_cr in enumerate(sample_yaml_files):
logger.info('[TEST %d]: %s', index, new_cr['name'])
addEvent = RayServiceAddCREvent(new_cr['cr'], [rs], 90, NAMESPACE, new_cr['path'])
test_cases.addTest(GeneralTestCase('runtest', image_dict, addEvent))
# Execute all tests
runner = unittest.TextTestRunner()
test_result = runner.run(test_cases)
# Without this line, the exit code will always be 0.
assert test_result.wasSuccessful()