Ejemplo n.º 1
0
 def test_delete_execute_error_project_id(self, mock_hook):
     with self.assertRaises(AirflowException):
         operator = GKEClusterDeleteOperator(location=PROJECT_LOCATION,
                                             name=CLUSTER_NAME,
                                             task_id=PROJECT_TASK_ID)
         operator.execute(None)
         mock_hook.return_value.delete_cluster.assert_not_called()
Ejemplo n.º 2
0
    def test_delete_execute(self, mock_hook):
        operator = GKEClusterDeleteOperator(project_id=TEST_GCP_PROJECT_ID,
                                            name=CLUSTER_NAME,
                                            location=PROJECT_LOCATION,
                                            task_id=PROJECT_TASK_ID)

        operator.execute(None)
        mock_hook.return_value.delete_cluster.assert_called_once_with(
            name=CLUSTER_NAME, project_id=TEST_GCP_PROJECT_ID)
Ejemplo n.º 3
0
 def test_delete_execute_error_location(self, mock_hook):
     with self.assertRaises(AirflowException):
         GKEClusterDeleteOperator(project_id=TEST_GCP_PROJECT_ID,
                                  name=CLUSTER_NAME,
                                  task_id=PROJECT_TASK_ID)
Ejemplo n.º 4
0
 def test_delete_execute_error_cluster_name(self, mock_hook):
     with self.assertRaises(AirflowException):
         GKEClusterDeleteOperator(project_id=TEST_GCP_PROJECT_ID,
                                  location=PROJECT_LOCATION,
                                  task_id=PROJECT_TASK_ID)
Ejemplo n.º 5
0
        task_id="pod_task_xcom",
        project_id=GCP_PROJECT_ID,
        location=GCP_LOCATION,
        cluster_name=CLUSTER_NAME,
        do_xcom_push=True,
        namespace="default",
        image="alpine",
        cmds=[
            "sh", "-c",
            'mkdir -p /airflow/xcom/;echo \'[1,2,3,4]\' > /airflow/xcom/return.json'
        ],
        name="test-pod-xcom",
    )

    pod_task_xcom_result = BashOperator(
        bash_command=
        "echo \"{{ task_instance.xcom_pull('pod_task_xcom')[0] }}\"",
        task_id="pod_task_xcom_result",
    )

    delete_cluster = GKEClusterDeleteOperator(
        task_id="delete_cluster",
        name=CLUSTER_NAME,
        project_id=GCP_PROJECT_ID,
        location=GCP_LOCATION,
    )

    create_cluster >> pod_task >> delete_cluster
    create_cluster >> pod_task_xcom >> delete_cluster
    pod_task_xcom >> pod_task_xcom_result