test_nodejs_postgresql.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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="20-ubi8"
  9. class TestNodeJSAppPostgreSQLExTemplate:
  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. json_raw_file = self.oc_api.get_raw_url_for_json(
  17. container="postgresql-container", dir="imagestreams", filename="postgresql-rhel.json"
  18. )
  19. self.oc_api.import_is(path=json_raw_file, name="postgresql", skip_check=True)
  20. def teardown_method(self):
  21. self.oc_api.delete_project()
  22. def test_local_template_inside_cluster(self):
  23. expected_output = "Node.js Crud Application"
  24. template_json = "../openshift/templates/nodejs-postgresql-persistent.json"
  25. assert self.oc_api.deploy_template(
  26. template=template_json, name_in_template="nodejs-example", expected_output=expected_output,
  27. openshift_args=[
  28. "SOURCE_REPOSITORY_REF=master",
  29. f"NODEJS_VERSION={VERSION}",
  30. "NAME=nodejs-example",
  31. "POSTGRESQL_VERSION=12-el8"
  32. ]
  33. )
  34. assert self.oc_api.is_template_deployed(name_in_template="nodejs-example")
  35. assert self.oc_api.check_response_inside_cluster(
  36. name_in_template="nodejs-example", expected_output=expected_output
  37. )
  38. def test_remote_template_inside_cluster(self):
  39. expected_output = "Node.js Crud Application"
  40. template_json = self.oc_api.get_raw_url_for_json(
  41. container="nodejs-ex", dir="openshift/templates", filename="nodejs-postgresql-persistent.json"
  42. )
  43. assert self.oc_api.deploy_template(
  44. template=template_json, name_in_template="dancer-example", expected_output=expected_output,
  45. openshift_args=[
  46. "SOURCE_REPOSITORY_REF=master",
  47. f"NODEJS_VERSION={VERSION}",
  48. "NAME=nodejs-example",
  49. "POSTGRESQL_VERSION=12-el8"
  50. ]
  51. )
  52. assert self.oc_api.is_template_deployed(name_in_template="nodejs-example")
  53. assert self.oc_api.check_response_inside_cluster(
  54. name_in_template="nodejs-example", expected_output=expected_output
  55. )