Manage a pool of nodes for a distributed test infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_openshift.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2018 Red Hat
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. # implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import logging
  16. import os
  17. import yaml
  18. from nodepool import tests
  19. class TestOpenShift(tests.DBTestCase):
  20. log = logging.getLogger("nodepool.TestOpenShift")
  21. def setup_config(self, filename):
  22. adjusted_filename = "functional/openshift/" + filename
  23. # Openshift context name are not hardcoded,
  24. # discover the name setup by oc login
  25. kubecfg = yaml.safe_load(open(os.path.expanduser("~/.kube/config")))
  26. try:
  27. ctx_name = kubecfg['contexts'][0]['name']
  28. except IndexError:
  29. raise RuntimeError("Run oc login first")
  30. self.log.debug("Using %s context name", ctx_name)
  31. return super().setup_config(adjusted_filename, context_name=ctx_name)
  32. def test_basic(self):
  33. configfile = self.setup_config('basic.yaml')
  34. pool = self.useNodepool(configfile, watermark_sleep=1)
  35. pool.start()
  36. nodes = self.waitForNodes("openshift-project", 1)
  37. self.assertEqual(1, len(nodes))
  38. self.assertEqual(nodes[0].connection_type, "project")
  39. nodes = self.waitForNodes("openshift-pod", 1)
  40. self.assertEqual(1, len(nodes))
  41. self.assertEqual(nodes[0].connection_type, "kubectl")