示例#1
0
    def test_create_cluster_snapshot_returns_snapshot_data(self):
        self._create_clusters()
        hook = RedshiftHook(aws_conn_id='aws_default')

        snapshot = hook.create_cluster_snapshot('test_snapshot_2',
                                                'test_cluster')
        self.assertNotEqual(snapshot, None)
示例#2
0
    def get_hook(self) -> RedshiftHook:
        """Create and return a RedshiftHook"""
        if self.hook:
            return self.hook

        self.hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
        return self.hook
 def test_restore_from_cluster_snapshot_returns_dict_with_cluster_data(self):
     self._create_clusters()
     hook = RedshiftHook(aws_conn_id='aws_default')
     hook.create_cluster_snapshot('test_snapshot', 'test_cluster')
     self.assertEqual(
         hook.restore_from_cluster_snapshot('test_cluster_3', 'test_snapshot')['ClusterIdentifier'],
         'test_cluster_3',
     )
示例#4
0
 def execute(self, context):
     redshift_hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
     cluster_state = redshift_hook.cluster_status(
         cluster_identifier=self.cluster_identifier)
     if cluster_state == 'available':
         self.log.info("Pausing Redshift cluster %s",
                       self.cluster_identifier)
         redshift_hook.get_conn().pause_cluster(
             ClusterIdentifier=self.cluster_identifier)
     else:
         self.log.warning(
             "Unable to pause cluster since cluster is currently in status: %s",
             cluster_state)
 def poke(self, context):
     self.log.info('Poking for status : %s\nfor cluster %s',
                   self.target_status, self.cluster_identifier)
     hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
     return hook.cluster_status(
         self.cluster_identifier) == self.target_status
示例#6
0
 def test_cluster_status_returns_cluster_not_found(self):
     self._create_clusters()
     hook = RedshiftHook(aws_conn_id='aws_default')
     status = hook.cluster_status('test_cluster_not_here')
     self.assertEqual(status, 'cluster_not_found')
示例#7
0
    def test_delete_cluster_returns_a_dict_with_cluster_data(self):
        self._create_clusters()
        hook = RedshiftHook(aws_conn_id='aws_default')

        cluster = hook.delete_cluster('test_cluster_2')
        self.assertNotEqual(cluster, None)
示例#8
0
 def test_cluster_status_returns_available_cluster(self):
     self._create_clusters()
     hook = RedshiftHook(aws_conn_id='aws_default')
     status = hook.cluster_status('test_cluster')
     self.assertEqual(status, 'available')
示例#9
0
 def get_hook(self):
     """Create and return a RedshiftHook"""
     if not self.hook:
         self.hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
     return self.hook