Beispiel #1
0
def _StartMinikubeCluster(cluster_name, vm_driver, debug=False):
  """Starts a minikube cluster."""
  # pylint: disable=broad-except
  try:
    if not _IsMinikubeClusterUp(cluster_name):
      cmd = [
          _FindMinikube(),
          'start',
          '-p',
          cluster_name,
          '--keep-context',
          '--interactive=false',
          '--delete-on-failure',
          '--install-addons=false',
          '--output=json',
      ]
      if vm_driver:
        cmd.append('--vm-driver=' + vm_driver)
        if vm_driver == 'docker':
          cmd.append('--container-runtime=docker')
      if debug:
        cmd.extend(['--alsologtostderr', '-v8'])

      start_msg = "Starting development environment '%s' ..." % cluster_name

      with console_io.ProgressBar(start_msg) as progress_bar:
        for json_obj in run_subprocess.StreamOutputJson(
            cmd, event_timeout_sec=90, show_stderr=debug):
          if debug:
            print('minikube', json_obj)

          _HandleMinikubeStatusEvent(progress_bar, json_obj)
  except Exception as e:
    six.reraise(MinikubeStartError, e, sys.exc_info()[2])
Beispiel #2
0
 def testNoTimeoutIfProgressEventsComeFastEnough(self):
     tuple(
         run_subprocess.StreamOutputJson(cmd=[
             'bash', '-c',
             'sleep .4; echo {}; sleep .4; echo {}; sleep .4; echo {}'
         ],
                                         event_timeout_sec=0.9))
Beispiel #3
0
    def testJsonObjects(self):
        objs = [{'one': 'two', 'three': 4}, {'five': {'six': 'seven'}}]
        text = ''.join(json.dumps(obj) + '\n' for obj in objs)

        with cross_platform_temp_file.NamedTempFile(text) as multi_line_file:
            cmd = ['cat', multi_line_file.name]
            self.assertSequenceEqual(
                tuple(
                    run_subprocess.StreamOutputJson(cmd,
                                                    event_timeout_sec=10)),
                objs)
Beispiel #4
0
 def testExitNonZero(self):
     with self.assertRaises(subprocess.CalledProcessError):
         tuple(
             run_subprocess.StreamOutputJson(['bash', '-c', 'exit 1'],
                                             event_timeout_sec=1))
Beispiel #5
0
 def testTimeout(self):
     with self.assertRaises(utils.TimeoutError):
         tuple(
             run_subprocess.StreamOutputJson(
                 cmd=['bash', '-c', 'sleep 2; echo {}'],
                 event_timeout_sec=0.1))