-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(chart): Chart template render and assert output (#2043)
Signed-off-by: Viet Nguyen Duc <[email protected]>
- Loading branch information
Showing
19 changed files
with
156 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
mkdir -p tests/tests | ||
cd tests || true | ||
|
||
if [ "${CI:-false}" = "false" ]; then | ||
pip3 install virtualenv | grep -v 'Requirement already satisfied' | ||
virtualenv docker-selenium-tests | ||
source docker-selenium-tests/bin/activate | ||
fi | ||
|
||
python -m pip install pyyaml==6.0.1 \ | ||
| grep -v 'Requirement already satisfied' | ||
|
||
cd .. | ||
helm template dummy --values tests/charts/templates/render/dummy.yaml \ | ||
charts/selenium-grid > ./tests/tests/output_deployment.yaml | ||
|
||
python tests/charts/templates/test.py "./tests/tests/output_deployment.yaml" | ||
ret_code=$? | ||
|
||
if [ "${CI:-false}" = "false" ]; then | ||
deactivate | ||
fi | ||
|
||
exit $ret_code |
2 changes: 1 addition & 1 deletion
2
...s/selenium-grid/ci/NodeChrome-values.yaml → tests/charts/ci/NodeChrome-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
charts/selenium-grid/ci/NodeEdge-values.yaml → tests/charts/ci/NodeEdge-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../selenium-grid/ci/NodeFirefox-values.yaml → tests/charts/ci/NodeFirefox-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This is dummy values file for chart template testing | ||
global: | ||
seleniumGrid: | ||
affinity: &affinity | ||
podAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- selenium | ||
topologyKey: "kubernetes.io/hostname" | ||
|
||
isolateComponents: true | ||
|
||
chromeNode: | ||
affinity: *affinity | ||
|
||
firefoxNode: | ||
affinity: *affinity | ||
|
||
edgeNode: | ||
affinity: *affinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import yaml | ||
import unittest | ||
import sys | ||
import logging | ||
|
||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") | ||
logger = logging.getLogger(__name__) | ||
|
||
def load_template(yaml_file): | ||
try: | ||
with open(yaml_file, 'r') as file: | ||
documents = yaml.safe_load_all(file) | ||
list_of_documents = [doc for doc in documents] | ||
return list_of_documents | ||
except yaml.YAMLError as error: | ||
print("Error in configuration file: ", error) | ||
|
||
class ChartTemplateTests(unittest.TestCase): | ||
def test_set_affinity(self): | ||
resources_name = ['selenium-chrome-node', 'selenium-distributor', 'selenium-edge-node', 'selenium-firefox-node', | ||
'selenium-event-bus', 'selenium-router', 'selenium-session-map', 'selenium-session-queue'] | ||
count = 0 | ||
for doc in LIST_OF_DOCUMENTS: | ||
if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment': | ||
self.assertTrue(doc['spec']['template']['spec']['affinity']['podAffinity']['requiredDuringSchedulingIgnoredDuringExecution'][0]['labelSelector']['matchExpressions'] is not None) | ||
count += 1 | ||
self.assertEqual(count, len(resources_name), "Not all resources have affinity set") | ||
|
||
if __name__ == '__main__': | ||
failed = False | ||
try: | ||
FILE_NAME = sys.argv[1] | ||
LIST_OF_DOCUMENTS = load_template(FILE_NAME) | ||
suite = unittest.TestLoader().loadTestsFromTestCase(ChartTemplateTests) | ||
test_runner = unittest.TextTestRunner(verbosity=3) | ||
failed = not test_runner.run(suite).wasSuccessful() | ||
except Exception as e: | ||
logger.fatal(e) | ||
failed = True | ||
|
||
if failed: | ||
exit(1) |