def assert_mock_cluster_is( self, mock_cluster, starting=False, bootstrapping=False, done=False, from_end_of_hour=timedelta(hours=1), has_pending_steps=False, idle_for=timedelta(0), pool_hash=None, pool_name=None, running=False, non_streaming=False): self.assertEqual(starting, is_cluster_starting(mock_cluster)) self.assertEqual(bootstrapping, is_cluster_bootstrapping(mock_cluster)) self.assertEqual(done, is_cluster_done(mock_cluster)) self.assertEqual(from_end_of_hour, _est_time_to_hour(mock_cluster, self.now)) self.assertEqual(has_pending_steps, cluster_has_pending_steps(mock_cluster._steps)) self.assertEqual(idle_for, self.time_mock_cluster_idle(mock_cluster)) self.assertEqual((pool_hash, pool_name), _pool_hash_and_name(mock_cluster._bootstrapactions)) self.assertEqual(running, is_cluster_running(mock_cluster._steps)) self.assertEqual(non_streaming, is_cluster_non_streaming(mock_cluster._steps))
def assert_mock_cluster_is(self, mock_cluster, starting=False, bootstrapping=False, done=False, from_end_of_hour=timedelta(hours=1), has_pending_steps=False, idle_for=timedelta(0), pool_hash=None, pool_name=None, running=False, non_streaming=False): self.assertEqual(starting, is_cluster_starting(mock_cluster)) self.assertEqual(bootstrapping, is_cluster_bootstrapping(mock_cluster)) self.assertEqual(done, is_cluster_done(mock_cluster)) self.assertEqual(from_end_of_hour, _est_time_to_hour(mock_cluster, self.now)) self.assertEqual(has_pending_steps, cluster_has_pending_steps(mock_cluster._steps)) self.assertEqual(idle_for, self.time_mock_cluster_idle(mock_cluster)) self.assertEqual((pool_hash, pool_name), _pool_hash_and_name(mock_cluster._bootstrapactions)) self.assertEqual(running, is_cluster_running(mock_cluster._steps)) self.assertEqual(non_streaming, is_cluster_non_streaming(mock_cluster._steps))
def time_mock_cluster_idle(self, mock_cluster): if (is_cluster_starting(mock_cluster) or is_cluster_bootstrapping(mock_cluster) or is_cluster_running(mock_cluster._steps) or is_cluster_done(mock_cluster)): return timedelta(0) else: return self.now - time_last_active( mock_cluster, mock_cluster._steps)
def time_mock_cluster_idle(self, mock_cluster): if (is_cluster_starting(mock_cluster) or is_cluster_bootstrapping(mock_cluster) or is_cluster_running(mock_cluster._steps) or is_cluster_done(mock_cluster)): return timedelta(0) else: return self.now - time_last_active(mock_cluster, mock_cluster._steps)