@@ -82,6 +82,12 @@ def test_sklearn_smoke(self, jupyterlab_datascience_image: conftest.Image) -> No
8282
8383 @allure .description ("Check that mysql client functionality is working with SASL plain auth." )
8484 def test_mysql_connection (self , tf : TestFrame , datascience_image : Image , subtests ):
85+ name_label = datascience_image .labels .get ("name" , "" )
86+ if "-rstudio-" in name_label :
87+ pytest .skip (
88+ f"Image { datascience_image .name } does have -rstudio- in { datascience_image .labels ['name' ]= } '"
89+ )
90+
8591 MYSQL_CONNECTOR_PYTHON_VERSION = "9.5.0"
8692
8793 network = testcontainers .core .network .Network ()
@@ -159,22 +165,26 @@ def test_mysql_connection(self, tf: TestFrame, datascience_image: Image, subtest
159165 try :
160166 container .start (wait_for_readiness = False )
161167
168+ # Use same interpreter for pip and -c so runtime-installed package is visible (PYTHONPATH).
169+ # Code-server image uses /opt/app-root/bin/python3; others use default python.
170+ python_exe = (
171+ "/opt/app-root/bin/python3"
172+ if "-code-server-" in name_label
173+ else "python"
174+ )
175+ print (f"Using python executable: { python_exe } " )
176+
162177 # RHOAIENG-140: code-server image users are expected to install their own db clients
163- if "-code-server-" in datascience_image . labels [ "name" ] :
178+ if "-code-server-" in name_label :
164179 exit_code , output = container .exec (
165- ["python" , "-m" , "pip" , "install" , f"mysql-connector-python=={ MYSQL_CONNECTOR_PYTHON_VERSION } " ]
180+ [python_exe , "-m" , "pip" , "install" , f"mysql-connector-python=={ MYSQL_CONNECTOR_PYTHON_VERSION } " ]
166181 )
167182 output_str = output .decode ()
168183 print (output_str )
169-
170184 assert exit_code == 0 , f"Failed to install mysql-connector-python: { output_str } "
171- elif "-rstudio-" in datascience_image .labels ["name" ]:
172- pytest .skip (
173- f"Image { datascience_image .name } does have -rstudio- in { datascience_image .labels ['name' ]= } '"
174- )
175185
176186 with subtests .test ("Setting the user..." ):
177- exit_code , output = container .exec (["python" , "-c" , setup_mysql_user ])
187+ exit_code , output = container .exec ([python_exe , "-c" , setup_mysql_user ])
178188 output_str = output .decode ()
179189
180190 print (output_str )
@@ -183,7 +193,7 @@ def test_mysql_connection(self, tf: TestFrame, datascience_image: Image, subtest
183193 assert exit_code == 0
184194
185195 with subtests .test ("Checking the output of the clearpassuser script..." ):
186- exit_code , output = container .exec (["python" , "-c" , clearpassuser ])
196+ exit_code , output = container .exec ([python_exe , "-c" , clearpassuser ])
187197 output_str = output .decode ()
188198
189199 print (output_str )
0 commit comments