Skip to content

Commit

Permalink
test(chart): test template from chart package tgz
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Mar 29, 2024
1 parent 5b5f17a commit e1c4f17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions tests/charts/bootstrap.sh
Expand Up @@ -13,13 +13,15 @@ python -m pip install pyyaml==6.0.1 \

cd ..

helm package charts/selenium-grid --version 1.0.0-SNAPSHOT -d tests/tests

RELEASE_NAME="selenium"

helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy.yaml \
--set-file 'nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
charts/selenium-grid > ./tests/tests/dummy_template_manifests.yaml
tests/tests/selenium-grid-1.0.0-SNAPSHOT.tgz > ./tests/tests/dummy_template_manifests.yaml

python tests/charts/templates/test.py "./tests/tests/dummy_template_manifests.yaml" ${RELEASE_NAME}
if [ $? -ne 0 ]; then
Expand All @@ -30,14 +32,15 @@ fi
rm -rf tests/charts/umbrella-charts/Chart.lock tests/charts/umbrella-charts/charts
helm dependency update tests/charts/umbrella-charts
helm dependency build tests/charts/umbrella-charts
helm package tests/charts/umbrella-charts --version 1.0.0-SNAPSHOT -d tests/tests

RELEASE_NAME="test"

helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy_solution.yaml \
--set-file 'selenium-grid.nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'selenium-grid.recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'selenium-grid.uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
tests/charts/umbrella-charts > ./tests/tests/dummy_solution_template_manifests.yaml
tests/tests/umbrella-charts-1.0.0-SNAPSHOT.tgz > ./tests/tests/dummy_solution_template_manifests.yaml

python tests/charts/templates/test.py "./tests/tests/dummy_solution_template_manifests.yaml" ${RELEASE_NAME}
if [ $? -ne 0 ]; then
Expand Down
8 changes: 4 additions & 4 deletions tests/charts/templates/test.py
Expand Up @@ -154,10 +154,10 @@ def test_extra_script_import_to_node_configmap(self):
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap':
logger.info(f"Assert default file is imported to Node ConfigMap")
self.assertTrue(doc['data']['nodeProbe.sh'] is not None)
self.assertTrue(doc['data']['nodePreStop.sh'] is not None)
self.assertTrue(doc['data']['nodeCustomTask.sh'] is not None)
self.assertTrue(doc['data']['setFromCommand.sh'] is not None)
self.assertTrue(doc['data']['nodeProbe.sh'] != "")
self.assertTrue(doc['data']['nodePreStop.sh'] != "")
self.assertTrue(doc['data']['nodeCustomTask.sh'] != "")
self.assertTrue(doc['data']['setFromCommand.sh'] != "")
count += 1
self.assertEqual(count, len(resources_name), "No node config resources found")

Expand Down
6 changes: 6 additions & 0 deletions tests/charts/umbrella-charts/values.yaml
@@ -0,0 +1,6 @@
global:
seleniumGrid:
imageRegistry: selenium

selenium-grid:
enabled: true

0 comments on commit e1c4f17

Please sign in to comment.