Exemple #1
0
def _IsMinikubeClusterUp(cluster_name):
    """Checks if a minikube cluster is running."""
    cmd = [_FindMinikube(), 'status', '-p', cluster_name, '-o', 'json']
    try:
        status = run_subprocess.GetOutputJson(cmd, show_stderr=False)
        return 'Host' in status and status['Host'].strip() == 'Running'
    except ValueError:
        return False
Exemple #2
0
 def testCanHideStderr(self):
     # The JSON decode will fail either way. The point of this (flimsy) test is
     # to see if stderr is suppressed. I'll try to eliminate that feature
     # in an upcoming CL.
     with self.assertRaises(ValueError):
         run_subprocess.GetOutputJson(
             ['bash', '-c', 'echo should not see this in test log >&2'],
             timeout_sec=10,
             show_stderr=False)
Exemple #3
0
 def testErrorsOnInvalidJson(self):
     with self.assertRaises(ValueError):
         run_subprocess.GetOutputJson(['echo', '{corruptjson'],
                                      timeout_sec=10)
Exemple #4
0
 def testReturnsParsedCommandJson(self):
     parsed = run_subprocess.GetOutputJson(['echo', '{"hello": "world"}'],
                                           timeout_sec=10)
     self.assertEqual(parsed, {u'hello': u'world'})