def testStartCluster_InstanceStatusError(self):
        """Unit test of StartCluster() instance status error.

    This unit test simulates the situation where status of one of the instances
    doesn't turn into RUNNING.
    """
        parent_mock = self._SetUpMocksForClusterStart()

        # Set hw-000's status to forever STAGING.
        parent_mock.GceApi.return_value.GetInstance.return_value = {
            'status': 'STAGING',
        }

        self.assertRaises(
            gce_cluster.ClusterSetUpError,
            gce_cluster.GceCluster(
                argparse.Namespace(project='project-hoge',
                                   bucket='bucket-fuga',
                                   machinetype='',
                                   image='',
                                   zone='',
                                   num_workers=2,
                                   command='',
                                   external_ip='all')).StartCluster)

        # Ensure ListInstances() and sleep() are called more than 120 times.
        self.assertLessEqual(40, parent_mock.GetInstance.call_count)
        self.assertLessEqual(40, parent_mock.sleep.call_count)
Пример #2
0
    def testStartCluster_PostprocessDidNotFinish(self):
        """Unit test of StartCluster() with postprocess error.

    This unit test simulates the situation where postprocess script doesn't
    finish.  (poll() keeps returning None.)
    """
        parent_mock = self._SetUpMocksForClusterStart()

        # Set return value of poll() to None (not yet finished).
        parent_mock.poll.return_value = None

        self.assertRaises(
            gce_cluster.ClusterSetUpError,
            gce_cluster.GceCluster(
                argparse.Namespace(project='project-hoge',
                                   bucket='bucket-fuga',
                                   machinetype='',
                                   image='',
                                   zone='',
                                   num_workers=2,
                                   command='')).StartCluster)

        self.assertEqual(2, parent_mock.ListInstances.call_count)
        self.assertLess(360, parent_mock.poll.call_count)
        self.assertLess(120, parent_mock.sleep.call_count)
Пример #3
0
    def testStartCluster_SubprocessCallError(self):
        """Unit test of StartCluster() with subprocess.call() error."""
        parent_mock = self._SetUpMocksForClusterStart()

        # Set subprocess.call() mock to return 1 (error return code).
        parent_mock.subprocess_call.return_value = 1

        self.assertRaises(
            gce_cluster.ClusterSetUpError,
            gce_cluster.GceCluster(
                argparse.Namespace(project='project-hoge',
                                   bucket='bucket-fuga',
                                   machinetype='',
                                   image='',
                                   zone='',
                                   num_workers=2,
                                   command='')).StartCluster)
 def MapReduce(flags):
     """Starts MapReduce job."""
     gce_cluster.GceCluster(flags).StartMapReduce()
 def ShutDown(flags):
     """Deletes all instances included in the Hadoop cluster."""
     gce_cluster.GceCluster(flags).TeardownCluster()
 def Start(flags):
     """Starts Google Compute Engine cluster with Hadoop set up."""
     gce_cluster.GceCluster(flags).StartCluster()
 def SetUp(flags):
     """Set up environment for Hadoop on Compute."""
     gce_cluster.GceCluster(flags).EnvironmentSetUp()