-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove RSA Public Key #21
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cadb9ec
upgrade jackson libs to 2.9.6
binglihub fa941f7
create two new constructors which requested private key string only
binglihub d0a49a0
use PrivateKey object instead of string value
binglihub 7a68697
setup integration test and create simple test exmple
binglihub de78eea
move test1.csv to resource folder
binglihub d02112d
setup it test
binglihub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.iml | ||
.idea | ||
target/ | ||
profile.json |
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,13 @@ | ||
{ | ||
"user": "user name", | ||
"account": "account name", | ||
"private_key": "PEM Private Key", | ||
"port": 443, | ||
"host": "account_name.snowflakecomputing.com", | ||
"schema": "schema", | ||
"scheme": "https", | ||
"database": "database name", | ||
"connect_string": "jdbc:snowflake://account_name.snowflakecomputing.com:443", | ||
"ssl": "on", | ||
"warehouse": "warehouse name" | ||
} |
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
167 changes: 167 additions & 0 deletions
167
src/test/java/net/snowflake/ingest/SimpleIngestSuite.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,167 @@ | ||
package net.snowflake.ingest; | ||
|
||
import net.snowflake.ingest.connection.HistoryResponse; | ||
import net.snowflake.ingest.connection.IngestResponse; | ||
import net.snowflake.ingest.utils.StagedFileWrapper; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.After; | ||
|
||
import java.sql.Connection; | ||
import java.util.Random; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Example ingest sdk integration test | ||
*/ | ||
public class SimpleIngestSuite | ||
{ | ||
private Connection conn = null; | ||
private SimpleIngestManager manager = null; | ||
|
||
private final String TEST_FILE_PATH = "file://test_files/test1.csv"; | ||
private final String TEST_FILE_NAME = "test1.csv"; | ||
|
||
private String tableName = ""; | ||
private String pipeName = ""; | ||
private String stageName = ""; | ||
|
||
/** | ||
* Create test table and pipe | ||
*/ | ||
@Before | ||
public void beforeAll() throws Exception | ||
{ | ||
Random rand = new Random(); | ||
|
||
Long num = Math.abs(rand.nextLong()); | ||
|
||
tableName = "ingest_sdk_test_table_" + num; | ||
|
||
pipeName = "ingest_sdk_test_pipe_" + num; | ||
|
||
stageName = "ingest_sdk_test_stage_" + num; | ||
|
||
|
||
TestUtils.executeQuery( | ||
"create or replace table " + tableName + " (str string, num int)" | ||
); | ||
|
||
TestUtils.executeQuery( | ||
"create or replace stage " + stageName | ||
); | ||
|
||
TestUtils.executeQuery( | ||
"create or replace pipe " + pipeName + " as copy into " + tableName + | ||
" from @" + stageName | ||
); | ||
|
||
} | ||
|
||
/** | ||
* Remove test table and pipe | ||
*/ | ||
@After | ||
public void afterAll() | ||
{ | ||
//System.out.println(111); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
TestUtils.executeQuery( | ||
"drop pipe if exists " + pipeName | ||
); | ||
|
||
TestUtils.executeQuery( | ||
"drop stage if exists " + stageName | ||
); | ||
|
||
TestUtils.executeQuery( | ||
"drop table if exists " + tableName | ||
); | ||
} | ||
|
||
/** | ||
* ingest test | ||
*/ | ||
@Test | ||
public void test1() throws Exception | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a better name? testSimpleIngest? |
||
{ | ||
//put | ||
TestUtils.executeQuery( | ||
"put " + TEST_FILE_PATH + " @" + stageName | ||
); | ||
|
||
//keeps track of whether we've loaded the file | ||
boolean loaded = false; | ||
|
||
//create ingest manager | ||
SimpleIngestManager manager = TestUtils.getManager(pipeName); | ||
|
||
//create a file wrapper | ||
StagedFileWrapper myFile = new StagedFileWrapper(TEST_FILE_NAME, null); | ||
|
||
//get an insert response after we submit | ||
IngestResponse insertResponse = manager.ingestFile(myFile, null); | ||
|
||
//create a new thread | ||
ExecutorService service = Executors.newSingleThreadExecutor(); | ||
|
||
//fork off waiting for a load to the service | ||
Future<?> result = service.submit(() -> | ||
{ | ||
|
||
String beginMark = null; | ||
|
||
while (true) | ||
{ | ||
|
||
try | ||
{ | ||
Thread.sleep(5000); | ||
HistoryResponse response = manager.getHistory(null, null, | ||
beginMark); | ||
|
||
if (response != null && response.getNextBeginMark() != null) | ||
{ | ||
beginMark = response.getNextBeginMark(); | ||
} | ||
if (response != null && response.files != null) | ||
{ | ||
for (HistoryResponse.FileEntry entry : response.files) | ||
{ | ||
//if we have a complete file that we've | ||
// loaded with the same name.. | ||
String filename = entry.getPath(); | ||
if (entry.getPath() != null && entry.isComplete() && | ||
filename.equals(TEST_FILE_NAME)) | ||
{ | ||
return; | ||
} | ||
} | ||
} | ||
} catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
); | ||
|
||
//try to wait until the future is done | ||
try | ||
{ | ||
//wait up to 1 minutes to load | ||
result.get(2, TimeUnit.MINUTES); | ||
loaded = true; | ||
} finally | ||
{ | ||
assertTrue(loaded); | ||
|
||
|
||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw proper user error in case user is passing in a PrivateKey not instancesof RSAPrivateCrtKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a checker
if(!(privateKey instanceof RSAPrivateCrtKey))
throw new IllegalArgumentException("Input private key is not a RSA private key");