test_nodejs.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import os
  2. import pytest
  3. from pathlib import Path
  4. from container_ci_suite.openshift import OpenShiftAPI
  5. test_dir = Path(os.path.abspath(os.path.dirname(__file__)))
  6. VERSION=os.getenv("SINGLE_VERSION")
  7. if not VERSION:
  8. VERSION="22-ubi9"
  9. class TestNodeJSAppExTemplate:
  10. def setup_method(self):
  11. self.oc_api = OpenShiftAPI(pod_name_prefix="nodejs-example")
  12. json_raw_file = self.oc_api.get_raw_url_for_json(
  13. container="s2i-nodejs-container", dir="imagestreams", filename="nodejs-rhel.json"
  14. )
  15. self.oc_api.import_is(path=json_raw_file, name="node", skip_check=True)
  16. def teardown_method(self):
  17. self.oc_api.delete_project()
  18. def test_template_inside_cluster(self):
  19. expected_output = "Node.js Crud Application"
  20. template_json = self.oc_api.get_raw_url_for_json(
  21. container="nodejs-ex", dir="openshift/templates", filename="nodejs.json"
  22. )
  23. assert self.oc_api.deploy_template(
  24. template=template_json, name_in_template="dancer-example", expected_output=expected_output,
  25. openshift_args=["SOURCE_REPOSITORY_REF=master", f"NODEJS_VERSION={VERSION}", "NAME=nodejs-example"]
  26. )
  27. assert self.oc_api.is_template_deployed(name_in_template="nodejs-example")
  28. assert self.oc_api.check_response_inside_cluster(
  29. name_in_template="nodejs-example", expected_output=expected_output
  30. )