def test_release(self, release, timeout=const.DEFAULT_TILLER_TIMEOUT, cleanup=False): ''' :param release: name of release to test :param timeout: runtime before exiting :param cleanup: removes testing pod created :returns: test suite run object ''' LOG.info("Running Helm test: release=%s, timeout=%s", release, timeout) try: stub = ReleaseServiceStub(self.channel) # TODO: This timeout is redundant since we already have the grpc # timeout below, and it's actually used by tiller for individual # k8s operations not the overall request, should we: # 1. Remove this timeout # 2. Add `k8s_timeout=const.DEFAULT_K8S_TIMEOUT` arg and use release_request = TestReleaseRequest(name=release, timeout=timeout, cleanup=cleanup) test_message_stream = stub.RunReleaseTest(release_request, timeout, metadata=self.metadata) failed = 0 for test_message in test_message_stream: if test_message.status == test.TESTRUN_STATUS_FAILURE: failed += 1 LOG.info(test_message.msg) if failed: LOG.info('{} test(s) failed'.format(failed)) status = self.get_release_status(release) return status.info.status.last_test_suite_run except Exception: LOG.exception('Error while testing release %s', release) status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Test')
def testing_release(self, release, timeout=300, cleanup=True): ''' :param release - name of release to test :param timeout - runtime before exiting :param cleanup - removes testing pod created :returns - results of test pod ''' LOG.debug("Helm test release %s, timeout=%s", release, timeout) try: stub = ReleaseServiceStub(self.channel) release_request = TestReleaseRequest(name=release, timeout=timeout, cleanup=cleanup) content = self.get_release_content(release) if not len(content.release.hooks): LOG.info('No test found') return False if content.release.hooks[0].events[0] == RUNTEST_SUCCESS: test = stub.RunReleaseTest(release_request, self.timeout, metadata=self.metadata) if test.running(): self.k8s.wait_get_completed_podphase(release) test.cancel() return self.get_release_status(release) except Exception: LOG.exception('Error while testing release %s', release) status = self.get_release_status(release) raise ex.ReleaseException(release, status, 'Test')