예제 #1
0
 def test_create_cluster_other_exception(self, mock_cluster_client):
   """
   Tests that an exception is thrown when the exception is not handled by
   any other case under _create_cluster.
   """
   cluster_metadata = dataproc_cluster_manager.MasterURLIdentifier(
       project_id='test-project', region='test-region')
   cluster_manager = dataproc_cluster_manager.DataprocClusterManager(
       cluster_metadata)
   from apache_beam.runners.interactive.dataproc.dataproc_cluster_manager import _LOGGER
   with self.assertLogs(_LOGGER, level='ERROR') as context_manager:
     self.assertRaises(MockException, cluster_manager.create_cluster, {})
     self.assertTrue('Unable to create cluster' in context_manager.output[0])
예제 #2
0
 def test_create_cluster_region_does_not_exist(self, mock_cluster_client):
   """
   Tests that an exception is thrown when a user specifies a region
   that does not exist.
   """
   cluster_metadata = dataproc_cluster_manager.MasterURLIdentifier(
       project_id='test-project', region='test-region')
   cluster_manager = dataproc_cluster_manager.DataprocClusterManager(
       cluster_metadata)
   from apache_beam.runners.interactive.dataproc.dataproc_cluster_manager import _LOGGER
   with self.assertLogs(_LOGGER, level='ERROR') as context_manager:
     self.assertRaises(ValueError, cluster_manager.create_cluster, {})
     self.assertTrue('Invalid region provided' in context_manager.output[0])
예제 #3
0
 def test_create_cluster_default_already_exists(self, mock_cluster_client):
   """
   Tests that no exception is thrown when a cluster already exists,
   but is using ie.current_env().clusters.default_cluster_name.
   """
   cluster_metadata = dataproc_cluster_manager.MasterURLIdentifier(
       project_id='test-project', region='test-region')
   cluster_manager = dataproc_cluster_manager.DataprocClusterManager(
       cluster_metadata)
   from apache_beam.runners.interactive.dataproc.dataproc_cluster_manager import _LOGGER
   with self.assertLogs(_LOGGER, level='INFO') as context_manager:
     cluster_manager.create_cluster({})
     self.assertTrue('already exists' in context_manager.output[0])
예제 #4
0
 def test_cleanup_does_not_exist(self, mock_cluster_client):
   """
   Tests that an exception is thrown when cleanup attempts to delete
   a cluster that does not exist.
   """
   cluster_metadata = dataproc_cluster_manager.MasterURLIdentifier(
       project_id='test-project', region='test-region')
   cluster_manager = dataproc_cluster_manager.DataprocClusterManager(
       cluster_metadata)
   from apache_beam.runners.interactive.dataproc.dataproc_cluster_manager import _LOGGER
   with self.assertLogs(_LOGGER, level='ERROR') as context_manager:
     self.assertRaises(ValueError, cluster_manager.cleanup)
     self.assertTrue('Cluster does not exist' in context_manager.output[0])
예제 #5
0
 def test_create_cluster_permission_denied(self, mock_cluster_client):
   """
   Tests that an exception is thrown when a user is trying to write to
   a project while having insufficient permissions.
   """
   cluster_metadata = dataproc_cluster_manager.MasterURLIdentifier(
       project_id='test-project', region='test-region')
   cluster_manager = dataproc_cluster_manager.DataprocClusterManager(
       cluster_metadata)
   from apache_beam.runners.interactive.dataproc.dataproc_cluster_manager import _LOGGER
   with self.assertLogs(_LOGGER, level='ERROR') as context_manager:
     self.assertRaises(ValueError, cluster_manager.create_cluster, {})
     self.assertTrue(
         'Due to insufficient project permissions' in
         context_manager.output[0])