Source code for tests.system.providers.amazon.aws.example_redshift_cluster
## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.fromdatetimeimportdatetimefromosimportgetenvfromairflowimportDAGfromairflow.models.baseoperatorimportchainfromairflow.providers.amazon.aws.operators.redshift_clusterimport(RedshiftCreateClusterOperator,RedshiftDeleteClusterOperator,RedshiftPauseClusterOperator,RedshiftResumeClusterOperator,)fromairflow.providers.amazon.aws.sensors.redshift_clusterimportRedshiftClusterSensorfromairflow.utils.trigger_ruleimportTriggerRulefromtests.system.providers.amazon.aws.utilsimportset_env_id
)# [END howto_operator_redshift_cluster]# [START howto_sensor_redshift_cluster]task_wait_cluster_available=RedshiftClusterSensor(task_id='sensor_redshift_cluster_available',cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,target_status='available',poke_interval=5,timeout=60*15,)# [END howto_sensor_redshift_cluster]# [START howto_operator_redshift_pause_cluster]task_pause_cluster=RedshiftPauseClusterOperator(task_id='redshift_pause_cluster',cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,)# [END howto_operator_redshift_pause_cluster]task_wait_cluster_paused=RedshiftClusterSensor(task_id='sensor_redshift_cluster_paused',cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,target_status='paused',poke_interval=5,timeout=60*15,)# [START howto_operator_redshift_resume_cluster]task_resume_cluster=RedshiftResumeClusterOperator(task_id='redshift_resume_cluster',cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,)# [END howto_operator_redshift_resume_cluster]# [START howto_operator_redshift_delete_cluster]task_delete_cluster=RedshiftDeleteClusterOperator(task_id="delete_cluster",cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,trigger_rule=TriggerRule.ALL_DONE,)# [END howto_operator_redshift_delete_cluster]chain(task_create_cluster,task_wait_cluster_available,task_pause_cluster,task_wait_cluster_paused,task_resume_cluster,task_delete_cluster,)fromtests.system.utils.watcherimportwatcher# This test needs watcher in order to properly mark success/failure# when "tearDown" task with trigger rule is part of the DAGlist(dag.tasks)>>watcher()fromtests.system.utilsimportget_test_run# noqa: E402# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)