@@ -1204,8 +1204,9 @@ class TestDataProcHiveOperator(unittest.TestCase):
1204
1204
query = "define sin HiveUDF('sin');"
1205
1205
variables = {"key" : "value" }
1206
1206
job_id = "uuid_id"
1207
+ job_name = "simple"
1207
1208
job = {
1208
- "reference" : {"project_id" : GCP_PROJECT , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1209
+ "reference" : {"project_id" : GCP_PROJECT , "job_id" : f" { job_name } _ { job_id } " },
1209
1210
"placement" : {"cluster_name" : "cluster-1" },
1210
1211
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1211
1212
"hive_job" : {"query_list" : {"queries" : [query ]}, "script_variables" : variables },
@@ -1226,6 +1227,7 @@ def test_execute(self, mock_hook, mock_uuid):
1226
1227
mock_hook .return_value .submit_job .return_value .reference .job_id = self .job_id
1227
1228
1228
1229
op = DataprocSubmitHiveJobOperator (
1230
+ job_name = self .job_name ,
1229
1231
task_id = TASK_ID ,
1230
1232
region = GCP_LOCATION ,
1231
1233
gcp_conn_id = GCP_CONN_ID ,
@@ -1249,6 +1251,7 @@ def test_builder(self, mock_hook, mock_uuid):
1249
1251
mock_uuid .return_value = self .job_id
1250
1252
1251
1253
op = DataprocSubmitHiveJobOperator (
1254
+ job_name = self .job_name ,
1252
1255
task_id = TASK_ID ,
1253
1256
region = GCP_LOCATION ,
1254
1257
gcp_conn_id = GCP_CONN_ID ,
@@ -1263,8 +1266,9 @@ class TestDataProcPigOperator(unittest.TestCase):
1263
1266
query = "define sin HiveUDF('sin');"
1264
1267
variables = {"key" : "value" }
1265
1268
job_id = "uuid_id"
1269
+ job_name = "simple"
1266
1270
job = {
1267
- "reference" : {"project_id" : GCP_PROJECT , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1271
+ "reference" : {"project_id" : GCP_PROJECT , "job_id" : f" { job_name } _ { job_id } " },
1268
1272
"placement" : {"cluster_name" : "cluster-1" },
1269
1273
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1270
1274
"pig_job" : {"query_list" : {"queries" : [query ]}, "script_variables" : variables },
@@ -1285,6 +1289,7 @@ def test_execute(self, mock_hook, mock_uuid):
1285
1289
mock_hook .return_value .submit_job .return_value .reference .job_id = self .job_id
1286
1290
1287
1291
op = DataprocSubmitPigJobOperator (
1292
+ job_name = self .job_name ,
1288
1293
task_id = TASK_ID ,
1289
1294
region = GCP_LOCATION ,
1290
1295
gcp_conn_id = GCP_CONN_ID ,
@@ -1308,6 +1313,7 @@ def test_builder(self, mock_hook, mock_uuid):
1308
1313
mock_uuid .return_value = self .job_id
1309
1314
1310
1315
op = DataprocSubmitPigJobOperator (
1316
+ job_name = self .job_name ,
1311
1317
task_id = TASK_ID ,
1312
1318
region = GCP_LOCATION ,
1313
1319
gcp_conn_id = GCP_CONN_ID ,
@@ -1321,15 +1327,16 @@ def test_builder(self, mock_hook, mock_uuid):
1321
1327
class TestDataProcSparkSqlOperator (unittest .TestCase ):
1322
1328
query = "SHOW DATABASES;"
1323
1329
variables = {"key" : "value" }
1330
+ job_name = "simple"
1324
1331
job_id = "uuid_id"
1325
1332
job = {
1326
- "reference" : {"project_id" : GCP_PROJECT , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1333
+ "reference" : {"project_id" : GCP_PROJECT , "job_id" : f" { job_name } _ { job_id } " },
1327
1334
"placement" : {"cluster_name" : "cluster-1" },
1328
1335
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1329
1336
"spark_sql_job" : {"query_list" : {"queries" : [query ]}, "script_variables" : variables },
1330
1337
}
1331
1338
other_project_job = {
1332
- "reference" : {"project_id" : "other-project" , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1339
+ "reference" : {"project_id" : "other-project" , "job_id" : f" { job_name } _ { job_id } " },
1333
1340
"placement" : {"cluster_name" : "cluster-1" },
1334
1341
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1335
1342
"spark_sql_job" : {"query_list" : {"queries" : [query ]}, "script_variables" : variables },
@@ -1350,6 +1357,7 @@ def test_execute(self, mock_hook, mock_uuid):
1350
1357
mock_hook .return_value .submit_job .return_value .reference .job_id = self .job_id
1351
1358
1352
1359
op = DataprocSubmitSparkSqlJobOperator (
1360
+ job_name = self .job_name ,
1353
1361
task_id = TASK_ID ,
1354
1362
region = GCP_LOCATION ,
1355
1363
gcp_conn_id = GCP_CONN_ID ,
@@ -1375,6 +1383,7 @@ def test_execute_override_project_id(self, mock_hook, mock_uuid):
1375
1383
mock_hook .return_value .submit_job .return_value .reference .job_id = self .job_id
1376
1384
1377
1385
op = DataprocSubmitSparkSqlJobOperator (
1386
+ job_name = self .job_name ,
1378
1387
project_id = "other-project" ,
1379
1388
task_id = TASK_ID ,
1380
1389
region = GCP_LOCATION ,
@@ -1399,6 +1408,7 @@ def test_builder(self, mock_hook, mock_uuid):
1399
1408
mock_uuid .return_value = self .job_id
1400
1409
1401
1410
op = DataprocSubmitSparkSqlJobOperator (
1411
+ job_name = self .job_name ,
1402
1412
task_id = TASK_ID ,
1403
1413
region = GCP_LOCATION ,
1404
1414
gcp_conn_id = GCP_CONN_ID ,
@@ -1412,10 +1422,11 @@ def test_builder(self, mock_hook, mock_uuid):
1412
1422
class TestDataProcSparkOperator (DataprocJobTestBase ):
1413
1423
main_class = "org.apache.spark.examples.SparkPi"
1414
1424
jars = ["file:///usr/lib/spark/examples/jars/spark-examples.jar" ]
1425
+ job_name = "simple"
1415
1426
job = {
1416
1427
"reference" : {
1417
1428
"project_id" : GCP_PROJECT ,
1418
- "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + TEST_JOB_ID ,
1429
+ "job_id" : f" { job_name } _ { TEST_JOB_ID } " ,
1419
1430
},
1420
1431
"placement" : {"cluster_name" : "cluster-1" },
1421
1432
"labels" : {"airflow-version" : AIRFLOW_VERSION },
@@ -1440,6 +1451,7 @@ def test_execute(self, mock_hook, mock_uuid):
1440
1451
self .extra_links_manager_mock .attach_mock (mock_hook , 'hook' )
1441
1452
1442
1453
op = DataprocSubmitSparkJobOperator (
1454
+ job_name = self .job_name ,
1443
1455
task_id = TASK_ID ,
1444
1456
region = GCP_LOCATION ,
1445
1457
gcp_conn_id = GCP_CONN_ID ,
@@ -1505,9 +1517,10 @@ def test_submit_spark_job_operator_extra_links(mock_hook, dag_maker, create_task
1505
1517
class TestDataProcHadoopOperator (unittest .TestCase ):
1506
1518
args = ["wordcount" , "gs://pub/shakespeare/rose.txt" ]
1507
1519
jar = "file:///usr/lib/spark/examples/jars/spark-examples.jar"
1520
+ job_name = "simple"
1508
1521
job_id = "uuid_id"
1509
1522
job = {
1510
- "reference" : {"project_id" : GCP_PROJECT , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1523
+ "reference" : {"project_id" : GCP_PROJECT , "job_id" : f" { job_name } _ { job_id } " },
1511
1524
"placement" : {"cluster_name" : "cluster-1" },
1512
1525
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1513
1526
"hadoop_job" : {"main_jar_file_uri" : jar , "args" : args },
@@ -1529,6 +1542,7 @@ def test_execute(self, mock_hook, mock_uuid):
1529
1542
mock_uuid .return_value = self .job_id
1530
1543
1531
1544
op = DataprocSubmitHadoopJobOperator (
1545
+ job_name = self .job_name ,
1532
1546
task_id = TASK_ID ,
1533
1547
region = GCP_LOCATION ,
1534
1548
gcp_conn_id = GCP_CONN_ID ,
@@ -1542,8 +1556,9 @@ def test_execute(self, mock_hook, mock_uuid):
1542
1556
class TestDataProcPySparkOperator (unittest .TestCase ):
1543
1557
uri = "gs://{}/{}"
1544
1558
job_id = "uuid_id"
1559
+ job_name = "simple"
1545
1560
job = {
1546
- "reference" : {"project_id" : GCP_PROJECT , "job_id" : "{{task.task_id}}_{{ds_nodash}}_" + job_id },
1561
+ "reference" : {"project_id" : GCP_PROJECT , "job_id" : f" { job_name } _ { job_id } " },
1547
1562
"placement" : {"cluster_name" : "cluster-1" },
1548
1563
"labels" : {"airflow-version" : AIRFLOW_VERSION },
1549
1564
"pyspark_job" : {"main_python_file_uri" : uri },
@@ -1562,7 +1577,11 @@ def test_execute(self, mock_hook, mock_uuid):
1562
1577
mock_uuid .return_value = self .job_id
1563
1578
1564
1579
op = DataprocSubmitPySparkJobOperator (
1565
- task_id = TASK_ID , region = GCP_LOCATION , gcp_conn_id = GCP_CONN_ID , main = self .uri
1580
+ job_name = self .job_name ,
1581
+ task_id = TASK_ID ,
1582
+ region = GCP_LOCATION ,
1583
+ gcp_conn_id = GCP_CONN_ID ,
1584
+ main = self .uri ,
1566
1585
)
1567
1586
job = op .generate_job ()
1568
1587
assert self .job == job
0 commit comments