From 7b9938e27e133974a7e54cd67feaa9c63014f4da Mon Sep 17 00:00:00 2001
From: Wilson Wang <wilson.wang@bytedance.com>
Date: Wed, 29 Jun 2022 11:55:29 -0700
Subject: [PATCH] fix wrong kuberay image used by compatibility test

---
 tests/compatibility-test.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tests/compatibility-test.py b/tests/compatibility-test.py
index 980995a61cf..f93a2e17bf6 100755
--- a/tests/compatibility-test.py
+++ b/tests/compatibility-test.py
@@ -18,12 +18,13 @@
 raycluster_service_file = 'tests/config/raycluster-service.yaml'
 
 logger = logging.getLogger(__name__)
+logging.basicConfig(level=logging.INFO)
 
 kuberay_sha = 'nightly'
 
 
 def shell_run(cmd):
-    logger.info(cmd)
+    logger.info('executing cmd: {}'.format(cmd))
     return os.system(cmd)
 
 
@@ -45,8 +46,10 @@ def apply_kuberay_resources():
     shell_assert_success('kind load docker-image kuberay/apiserver:{}'.format(kuberay_sha))
     shell_assert_success(
         'kubectl create -k manifests/cluster-scope-resources')
+    # use kustomize to build the yaml, then change the image to the one we want to testing.
     shell_assert_success(
-        'kubectl create -k manifests/base')
+        'kustomize build manifests/base | sed "s/image: kuberay\\/\\(.*\\):nightly/image: kuberay\\/\\1:{}/g" | kubectl apply -f -'.format(
+            kuberay_sha))
 
 
 def create_kuberay_cluster():
@@ -128,11 +131,11 @@ def f(x):
         container.stop()
 
         if stdout_str != b'[0, 1, 4, 9]\n':
-            print(output, file=sys.stderr)
+            logger.info(output)
             raise Exception('invalid result.')
         if rtn_code != 0:
             msg = 'invalid return code {}'.format(rtn_code)
-            print(msg, file=sys.stderr)
+            logger.info(msg)
             raise Exception(msg)
 
         client.close()
@@ -160,11 +163,11 @@ def test_cluster_info(self):
         container.stop()
 
         if stdout_str != b'2\n':
-            print(output, file=sys.stderr)
+            logger.info(output)
             raise Exception('invalid result.')
         if rtn_code != 0:
             msg = 'invalid return code {}'.format(rtn_code)
-            print(msg, file=sys.stderr)
+            logger.info(msg)
             raise Exception(msg)
 
         client.close()
@@ -178,11 +181,11 @@ def parse_environment():
     global ray_version, ray_image, kuberay_sha
     for k, v in os.environ.items():
         if k == 'RAY_VERSION':
-            print('Setting Ray image to: {}'.format(v), file=sys.stderr)
+            logger.info('Setting Ray image to: {}'.format(v))
             ray_version = v
             ray_image = 'rayproject/ray:{}'.format(ray_version)
         if k == 'KUBERAY_IMG_SHA':
-            print('Using KubeRay docker build SHA: {}'.format(v))
+            logger.info('Using KubeRay docker build SHA: {}'.format(v))
             kuberay_sha = v