()
| 22 | |
| 23 | |
| 24 | def get_e2e_configuration(): |
| 25 | config = Configuration() |
| 26 | config.host = None |
| 27 | if os.path.exists( |
| 28 | os.path.expanduser(kube_config.KUBE_CONFIG_DEFAULT_LOCATION)): |
| 29 | loop = asyncio.new_event_loop() |
| 30 | asyncio.set_event_loop(loop) |
| 31 | loop.run_until_complete(kube_config.load_kube_config(client_configuration=config)) |
| 32 | else: |
| 33 | print('Unable to load config from %s' % |
| 34 | kube_config.KUBE_CONFIG_DEFAULT_LOCATION) |
| 35 | for proto, host, port in [('https', DEFAULT_E2E_HOST, '8443'), |
| 36 | ('http', DEFAULT_E2E_HOST, '8080')]: |
| 37 | try: |
| 38 | print('Testing:', proto, host, port) |
| 39 | http.client.HTTPConnection(host, port).request('GET', '/') |
| 40 | config.host = "{}://{}:{}".format(proto, host, port) |
| 41 | config.verify_ssl = False |
| 42 | break |
| 43 | except ConnectionRefusedError: |
| 44 | pass |
| 45 | |
| 46 | if config.host is None: |
| 47 | raise unittest.SkipTest('Unable to find a running Kubernetes instance') |
| 48 | print('Running test against : %s' % config.host) |
| 49 | config.assert_hostname = False |
| 50 | return config |
nothing calls this directly
no test coverage detected