@@ -4372,7 +4372,7 @@ def test_setup_storage_connector_jdbc(self, mocker):
4372
4372
assert mock_spark_engine_setup_adls_hadoop_conf .call_count == 0
4373
4373
assert mock_spark_engine_setup_gcp_hadoop_conf .call_count == 0
4374
4374
4375
- def test_setup_s3_hadoop_conf (self , mocker ):
4375
+ def test_setup_s3_hadoop_conf_legacy (self , mocker ):
4376
4376
# Arrange
4377
4377
mock_pyspark_getOrCreate = mocker .patch (
4378
4378
"pyspark.sql.session.SparkSession.builder.getOrCreate"
@@ -4384,6 +4384,7 @@ def test_setup_s3_hadoop_conf(self, mocker):
4384
4384
id = 1 ,
4385
4385
name = "test_connector" ,
4386
4386
featurestore_id = 99 ,
4387
+ bucket = "bucket-name" ,
4387
4388
access_key = "1" ,
4388
4389
secret_key = "2" ,
4389
4390
server_encryption_algorithm = "3" ,
@@ -4402,7 +4403,7 @@ def test_setup_s3_hadoop_conf(self, mocker):
4402
4403
assert result == "s3a_test_path"
4403
4404
assert (
4404
4405
mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .call_count
4405
- == 7
4406
+ == 14
4406
4407
)
4407
4408
mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4408
4409
"fs.s3a.access.key" , s3_connector .access_key
@@ -4428,6 +4429,65 @@ def test_setup_s3_hadoop_conf(self, mocker):
4428
4429
"fs.s3a.endpoint" , s3_connector .arguments .get ("fs.s3a.endpoint" )
4429
4430
)
4430
4431
4432
+ def test_setup_s3_hadoop_conf_bucket_scope (self , mocker ):
4433
+ # Arrange
4434
+ mock_pyspark_getOrCreate = mocker .patch (
4435
+ "pyspark.sql.session.SparkSession.builder.getOrCreate"
4436
+ )
4437
+
4438
+ spark_engine = spark .Engine ()
4439
+
4440
+ s3_connector = storage_connector .S3Connector (
4441
+ id = 1 ,
4442
+ name = "test_connector" ,
4443
+ featurestore_id = 99 ,
4444
+ bucket = "bucket-name" ,
4445
+ access_key = "1" ,
4446
+ secret_key = "2" ,
4447
+ server_encryption_algorithm = "3" ,
4448
+ server_encryption_key = "4" ,
4449
+ session_token = "5" ,
4450
+ arguments = [{"name" : "fs.s3a.endpoint" , "value" : "testEndpoint" }],
4451
+ )
4452
+
4453
+ # Act
4454
+ result = spark_engine ._setup_s3_hadoop_conf (
4455
+ storage_connector = s3_connector ,
4456
+ path = "s3_test_path" ,
4457
+ )
4458
+
4459
+ # Assert
4460
+ assert result == "s3a_test_path"
4461
+ assert (
4462
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .call_count
4463
+ == 14
4464
+ )
4465
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4466
+ "fs.s3a.bucket.bucket-name.access.key" , s3_connector .access_key
4467
+ )
4468
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4469
+ "fs.s3a.bucket.bucket-name.secret.key" , s3_connector .secret_key
4470
+ )
4471
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4472
+ "fs.s3a.bucket.bucket-name.server-side-encryption-algorithm" ,
4473
+ s3_connector .server_encryption_algorithm ,
4474
+ )
4475
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4476
+ "fs.s3a.bucket.bucket-name.server-side-encryption-key" ,
4477
+ s3_connector .server_encryption_key ,
4478
+ )
4479
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4480
+ "fs.s3a.bucket.bucket-name.aws.credentials.provider" ,
4481
+ "org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider" ,
4482
+ )
4483
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4484
+ "fs.s3a.bucket.bucket-name.session.token" , s3_connector .session_token
4485
+ )
4486
+ mock_pyspark_getOrCreate .return_value .sparkContext ._jsc .hadoopConfiguration .return_value .set .assert_any_call (
4487
+ "fs.s3a.bucket.bucket-name.endpoint" ,
4488
+ s3_connector .arguments .get ("fs.s3a.endpoint" ),
4489
+ )
4490
+
4431
4491
def test_setup_adls_hadoop_conf (self , mocker ):
4432
4492
# Arrange
4433
4493
mock_pyspark_getOrCreate = mocker .patch (
0 commit comments