potiuk commented on a change in pull request #6922: [AIRFLOW-5385] spark hook
does not work on spark 2.3/2.4
URL: https://github.com/apache/airflow/pull/6922#discussion_r361842287
##########
File path: tests/contrib/hooks/test_spark_submit_hook.py
##########
@@ -166,6 +166,38 @@ def test_build_spark_submit_command(self):
]
self.assertEqual(expected_build_cmd, cmd)
+ def test_build_track_driver_status_command(self):
+ # note this function is only relevant for spark setup matching below
condition
+ # 'spark://' in self._connection['master'] and
self._connection['deploy_mode'] == 'cluster'
+
+ # Given
+ hook_spark_standalone_cluster = SparkSubmitHook(
+ conn_id='spark_standalone_cluster')
+ hook_spark_standalone_cluster._driver_id = 'driver-20171128111416-0001'
+ hook_spark_yarn_cluster = SparkSubmitHook(
+ conn_id='spark_yarn_cluster')
+ hook_spark_yarn_cluster._driver_id = 'driver-20171128111417-0001'
+
+ # When
+ build_track_driver_status_spark_standalone_cluster = \
+ hook_spark_standalone_cluster._build_track_driver_status_command()
+ build_track_driver_status_spark_yarn_cluster = \
+ hook_spark_yarn_cluster._build_track_driver_status_command()
+
+ # Then
+ expected_build_track_driver_status_spark_standalone_cluster = [
+ '/usr/bin/curl',
+ '--max-time',
+ '30',
+
'http://spark-standalone-master:6066/v1/submissions/status/driver-20171128111416-0001']
+ expected_build_track_driver_status_spark_yarn_cluster = [
+ 'spark-submit', '--master', 'yarn://yarn-master', '--status',
'driver-20171128111417-0001']
+
+
self.assertListEqual(expected_build_track_driver_status_spark_standalone_cluster,
Review comment:
Since we are switching to pytest, it would be great to use the standard
asserts from python.
Pytest does all the heavy lifting and rewrites the assertions so `assert a
== b` works very well also for iterables (and provides useful comparison
report).
https://docs.pytest.org/en/latest/example/reportingdemo.html#tbreportdemo
```
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
def test_eq_list(self):
> assert [0, 1, 2] == [0, 1, 3]
E assert [0, 1, 2] == [0, 1, 3]
E At index 2 diff: 2 != 3
E Use -v to get the full diff
failure_demo.py:64: AssertionError
```
We have switched now to use the standard python asserts wherever possible.
See https://github.com/apache/airflow/blob/master/TESTING.rst#writing-unit-tests
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services