forked from logicalclocks/feature-store-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FSTORE-331] BigQuery connector doesn't work if the application is ex… (
logicalclocks#809) * [FSTORE-331] BigQuery connector doesn't work if the application is executed on multiple nodes * Change the BigQuery configuration so that it uses the credential field (base64 encoding of the content of the credential file) instead of providing the path in the credentialFile property. * For Java, updated the tests to use JUnit5 to allow for the @tmpdir annotation * Check if options is null before checking if it's empty and try again.
- Loading branch information
Showing
13 changed files
with
160 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
java/src/test/java/com/logicalclocks/hsfs/TestStorageConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2022 Hopsworks AB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.logicalclocks.hsfs; | ||
|
||
import com.logicalclocks.hsfs.util.Constants; | ||
import org.apache.spark.sql.SparkSession; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Base64; | ||
import java.util.Map; | ||
|
||
public class TestStorageConnector { | ||
|
||
@Test | ||
public void testBigQueryCredentialsBase64Encoded(@TempDir Path tempDir) throws IOException { | ||
// Arrange | ||
String credentials = "{\"type\": \"service_account\", \"project_id\": \"test\"}"; | ||
Path credentialsFile = tempDir.resolve("bigquery.json"); | ||
Files.write(credentialsFile, credentials.getBytes()); | ||
|
||
StorageConnector.BigqueryConnector bigqueryConnector = new StorageConnector.BigqueryConnector(); | ||
bigqueryConnector.setKeyPath("file://" + credentialsFile); | ||
|
||
// Act | ||
Map<String, String> sparkOptions = bigqueryConnector.sparkOptions(); | ||
|
||
// Assert | ||
Assertions.assertEquals(credentials, | ||
new String(Base64.getDecoder().decode(sparkOptions.get(Constants.BIGQ_CREDENTIALS)), StandardCharsets.UTF_8)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spark.master=local[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
exclude: setup.py | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
rev: 22.8.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
language_version: python3 | ||
args: [--config=python/.flake8] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.4.0 | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.