mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
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]>
53 lines
1.6 KiB
Python
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()
|