Skip to content

Commit 84de282

Browse files
Merge pull request #870 from jstourac/testProxy
RHOAIENG-17251: add a test for the proxy env configuration in RStudio + some other minor changes
2 parents 22f1d9c + 51e022e commit 84de282

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

tests/containers/workbenches/rstudio/rstudio_tests.py renamed to tests/containers/workbenches/rstudio/rstudio_test.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import json
44
import logging
55
import pathlib
6+
import pytest_subtests
67
import subprocess
78
import tempfile
89
import textwrap
9-
from typing import TYPE_CHECKING
10+
from typing import NamedTuple, TYPE_CHECKING
1011

1112
import allure
1213
import pytest
@@ -21,7 +22,7 @@
2122
class TestRStudioImage:
2223
"""Tests for RStudio Workbench images in this repository."""
2324

24-
APP_ROOT_HOME = "/opt/app-root/src/"
25+
APP_ROOT_HOME = "/opt/app-root/src"
2526

2627
@allure.issue("RHOAIENG-17256")
2728
def test_rmd_to_pdf_rendering(self, image: str) -> None:
@@ -99,6 +100,43 @@ def test_rmd_to_pdf_rendering(self, image: str) -> None:
99100
finally:
100101
docker_utils.NotebookContainer(container).stop(timeout=0)
101102

103+
@allure.issue("RHOAIENG-16604")
104+
def test_http_proxy_env_propagates(self, image: str, subtests: pytest_subtests.plugin.SubTests) -> None:
105+
"""
106+
This checks that the lowercased proxy configuration is propagated into the RStudio
107+
environment so that the appropriate values are then accepted and followed.
108+
"""
109+
skip_if_not_rstudio_image(image)
110+
111+
class TestCase(NamedTuple):
112+
name: str
113+
name_lc: str
114+
value: str
115+
116+
test_cases: list[TestCase] = [
117+
TestCase("HTTP_PROXY", "http_proxy", "http://localhost:8080"),
118+
TestCase("HTTPS_PROXY", "https_proxy", "https://localhost:8443"),
119+
TestCase("NO_PROXY", "no_proxy", "google.com"),
120+
]
121+
122+
container = WorkbenchContainer(image=image, user=1000, group_add=[0])
123+
for tc in test_cases:
124+
container.with_env(tc.name, tc.value)
125+
126+
try:
127+
# We need to wait for the IDE to be completely loaded so that the envs are processed properly.
128+
container.start(wait_for_readiness=True)
129+
130+
# Once the RStudio IDE is fully up and running, the processed envs should includ also lowercased proxy configs.
131+
for tc in test_cases:
132+
with subtests.test(tc.name):
133+
output = check_output(
134+
container,
135+
f"/usr/bin/R --quiet --no-echo -e 'Sys.getenv(\"{tc.name_lc}\")'")
136+
assert '"' + tc.value + '"' in output
137+
finally:
138+
docker_utils.NotebookContainer(container).stop(timeout=0)
139+
102140

103141
def check_call(container: WorkbenchContainer, cmd: str) -> int:
104142
"""Like subprocess.check_output, but in a container."""

0 commit comments

Comments
 (0)