You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/10 15:25:56 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #15726: Add more integration tests to the kubernetes executor

ephraimbuddy commented on a change in pull request #15726:
URL: https://github.com/apache/airflow/pull/15726#discussion_r629455917



##########
File path: kubernetes_tests/test_kubernetes_executor.py
##########
@@ -173,41 +190,24 @@ def start_dag(self, dag_id, host):
         print(f"Calling [start_dag]#2 {post_string}")
         # Trigger a new dagrun
         result = self.session.post(post_string, json={})
-        try:
-            result_json = result.json()
-        except ValueError:
-            result_json = str(result)
+        result_json = result.json()
         print(f"Received [start_dag]#2 {result_json}")
         assert result.status_code == 200, f"Could not trigger a DAG-run: {result_json}"
-
+        execution_date = result_json['execution_date']
+        dag_run_id = result_json['dag_run_id']
         time.sleep(1)
-
         get_string = f'http://{host}/api/v1/dags/{dag_id}/dagRuns'
         print(f"Calling [start_dag]#3 {get_string}")
         result = self.session.get(get_string)
         assert result.status_code == 200, f"Could not get DAGRuns: {result.json()}"
         result_json = result.json()
         print(f"Received: [start_dag]#3 {result_json}")
-        return result_json
-
-    def start_job_in_kubernetes(self, dag_id, host):
-        result_json = self.start_dag(dag_id=dag_id, host=host)
-        dag_runs = result_json['dag_runs']
-        assert len(dag_runs) > 0
-        execution_date = None
-        dag_run_id = None
-        for dag_run in dag_runs:
-            if dag_run['dag_id'] == dag_id:
-                execution_date = dag_run['execution_date']
-                dag_run_id = dag_run['dag_run_id']
-                break
-        assert execution_date is not None, f"No execution_date can be found for the dag with {dag_id}"

Review comment:
       This is not needed and it gives the wrong dag_run_id and execution date. Since all it does is get the dag_run_id and execution date, I had to remove it and get the exact dag_run_id and execution date from the time we triggered the DagRuns. 
   This code block tricked me into thinking there was an issue hence my earlier commits




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org