Skip to content

Commit 6e26971

Browse files
committed
Fix volumes in test spec
1 parent 372cbda commit 6e26971

5 files changed

Lines changed: 31 additions & 16 deletions

File tree

applications/workflows/api/openapi.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ info:
88
license:
99
name: UNLICENSED
1010
servers:
11-
-
12-
url: /api
13-
description: Metacell host
11+
- url: /api
12+
description: Metacell host
1413
paths:
1514
/operations:
1615
get:

deployment/codefresh-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ steps:
385385
- pytest -v test/api
386386
common_api_test:
387387
volumes:
388-
- '${{CF_REPO_NAME}}/applications/common/server:/home/test'
388+
- '${{CF_REPO_NAME}}/applications/common:/home/test'
389389
- '${{CF_REPO_NAME}}/deployment/helm/values.yaml:/opt/cloudharness/resources/allvalues.yaml'
390390
environment:
391391
- APP_URL=https://common.${{CF_SHORT_REVISION}}.${{DOMAIN}}/api
@@ -394,7 +394,7 @@ steps:
394394
https://common.${{CF_SHORT_REVISION}}.${{DOMAIN}}/api -c all
395395
workflows_api_test:
396396
volumes:
397-
- '${{CF_REPO_NAME}}/applications/workflows/server:/home/test'
397+
- '${{CF_REPO_NAME}}/applications/workflows:/home/test'
398398
- '${{CF_REPO_NAME}}/deployment/helm/values.yaml:/opt/cloudharness/resources/allvalues.yaml'
399399
environment:
400400
- APP_URL=https://workflows.${{CF_SHORT_REVISION}}.${{DOMAIN}}/api

tools/cloudharness-test/cloudharness_test/apitest_init.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
raise Exception(f"Cannot setup api tests: {openapi_uri} not reachable. Check your deployment is up and configuration") from e
1818

1919
if "USERNAME" in os.environ and "PASSWORD" in os.environ:
20+
logging.info("Setting token from username and password")
2021
@st.auth.register()
2122
class TokenAuth:
2223
def get(self, context):
@@ -26,6 +27,17 @@ def get(self, context):
2627

2728
return get_token(username, password)
2829

30+
def set(self, case, data, context):
31+
case.headers = case.headers or {}
32+
case.headers["Authorization"] = f"Bearer {data}"
33+
case.headers["Cookie"] = f"kc-access={data}"
34+
else:
35+
@st.auth.register()
36+
class TokenAuth:
37+
def get(self, context):
38+
39+
return ""
40+
2941
def set(self, case, data, context):
3042
case.headers = case.headers or {}
3143
case.headers["Authorization"] = f"Bearer {data}"

tools/deployment-cli-tools/ch_cli_tools/codefresh.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from cloudharness_utils.constants import *
1212
from .helm import KEY_APPS, KEY_TASK_IMAGES
1313
from .utils import find_dockerfiles_paths, get_app_relative_to_base_path, guess_build_dependencies_from_dockerfile, \
14-
get_image_name, get_template, dict_merge, app_name_from_path
14+
get_image_name, get_template, dict_merge, app_name_from_path, clean_path
1515
from cloudharness_utils.testing.api import get_api_filename, get_schemathesis_command, get_urls_from_api_file
1616

1717
logging.getLogger().setLevel(logging.INFO)
@@ -92,9 +92,9 @@ def e2e_test_environment(app_config: ApplicationHarnessConfig, app_domain: str =
9292
def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, include=build_included, publish=True):
9393

9494
for dockerfile_path in find_dockerfiles_paths(base_path):
95-
app_relative_to_root = relpath(dockerfile_path, '.')
96-
app_relative_to_base = get_app_relative_to_base_path(base_path, dockerfile_path)
97-
app_name = app_name_from_path(app_relative_to_base)
95+
dockerfile_relative_to_root = relpath(dockerfile_path, '.')
96+
dockerfile_relative_to_base = get_app_relative_to_base_path(base_path, dockerfile_path)
97+
app_name = app_name_from_path(dockerfile_relative_to_base)
9898
app_key = app_name.replace("-", "_")
9999
app_config: ApplicationHarnessConfig = app_key in helm_values.apps and helm_values.apps[
100100
app_key].harness
@@ -115,7 +115,7 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in
115115
build = codefresh_app_build_spec(
116116
app_name=app_name,
117117
app_context_path=relpath(
118-
fixed_context, '.') if fixed_context else app_relative_to_root,
118+
fixed_context, '.') if fixed_context else dockerfile_relative_to_root,
119119
dockerfile_path=join(
120120
relpath(
121121
dockerfile_path, root_path) if fixed_context else '',
@@ -146,8 +146,8 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in
146146

147147
if CD_API_TEST_STEP in steps and app_config and app_config.test.api.enabled:
148148
tests_path = join(
149-
base_path, app_relative_to_base, "test", API_TESTS_DIRNAME)
150-
api_filename = get_api_filename(app_relative_to_base)
149+
base_path, dockerfile_relative_to_base, "test", API_TESTS_DIRNAME)
150+
api_filename = get_api_filename(dockerfile_relative_to_base)
151151
if app_config.subdomain:
152152
server_urls = get_urls_from_api_file(
153153
os.path.join(root_path, APPS_PATH, api_filename))
@@ -156,8 +156,8 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in
156156
app_domain = get_app_domain(
157157
app_config) + app_domain
158158
steps[CD_API_TEST_STEP]['scale'][f"{app_name}_api_test"] = dict(
159-
volumes=api_test_volumes(
160-
app_relative_to_root),
159+
volumes=api_test_volumes(clean_path(
160+
dockerfile_relative_to_root)),
161161
environment=e2e_test_environment(
162162
app_config, app_domain),
163163
commands=api_tests_commands(
@@ -166,13 +166,13 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in
166166

167167
if CD_E2E_TEST_STEP in steps and app_config and app_config.test.e2e.enabled:
168168
tests_path = join(
169-
base_path, app_relative_to_base, "test", E2E_TESTS_DIRNAME)
169+
base_path, dockerfile_relative_to_base, "test", E2E_TESTS_DIRNAME)
170170

171171
if app_config.subdomain:
172172

173173
steps[CD_E2E_TEST_STEP]['scale'][f"{app_name}_e2e_test"] = dict(
174174
volumes=e2e_test_volumes(
175-
app_relative_to_root, app_name),
175+
clean_path(dockerfile_relative_to_root), app_name),
176176
environment=e2e_test_environment(app_config)
177177
)
178178

tools/deployment-cli-tools/tests/test_codefresh.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ def test_create_codefresh_configuration_tests():
236236
assert "-c all" in st_cmd, "Default check loaded is `all` on schemathesis command"
237237
assert "--hypothesis-deadline=" in st_cmd, "Custom parameters are loaded from values.yaml"
238238

239+
test_step = api_steps["common_api_test"]
240+
for volume in test_step["volumes"]:
241+
assert "server" not in volume
242+
239243

240244
assert any("CLOUDHARNESS_BASE" in arg for arg in st_build_test_steps["test-api"]
241245
["build_arguments"]), "Missing build dependency on api test image"

0 commit comments

Comments
 (0)