-
Notifications
You must be signed in to change notification settings - Fork 1
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
Recursively put files sometimes #10
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
333a324
Recursively put files sometimes
garyluu e7f4bdc
Feature/localstack (#11)
garyluu 266a37d
Enable test
garyluu f1e5722
Clean up, wait for localstack better
garyluu 6c2d923
Cleanup
garyluu 09e86ec
Comments
garyluu c21fc90
Test for s3cmd install directory
garyluu 7ee46da
Fix for new s3cmd
garyluu 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
sudo: required | ||
language: java | ||
services: | ||
- docker | ||
jdk: | ||
- oraclejdk8 | ||
install: | ||
- pip install --user -r requirements.txt | ||
before_script: | ||
- bash start-localstack.sh | ||
script: | ||
- mvn clean install | ||
|
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,3 @@ | ||
pip==9.0.1 | ||
localstack==0.8.5 | ||
s3cmd==2.0.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
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,87 @@ | ||
package io.dockstore.provision; | ||
|
||
import java.io.File; | ||
import java.lang.reflect.Method; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.HashMap; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author gluu | ||
* @since 07/03/17 | ||
*/ | ||
public class S3CmdPluginTest { | ||
S3CmdPlugin.S3CmdProvision icgcGetProvision; | ||
final String resourcesDirectory = new File("src/test/resources").getAbsolutePath(); | ||
@Before | ||
public void before() throws Exception { | ||
icgcGetProvision = new S3CmdPlugin.S3CmdProvision(); | ||
setConfiguration(); | ||
} | ||
|
||
private void setConfiguration() throws Exception { | ||
HashMap hm = new HashMap(); | ||
hm.put("client", "/home/travis/.local/bin/s3cmd"); | ||
// hm.put("client", "/usr/local/bin/s3cmd"); | ||
hm.put("config-file-location", resourcesDirectory + "/.s3cfg"); | ||
hm.put("verbosity", "Minimal"); | ||
icgcGetProvision.setConfiguration(hm); | ||
} | ||
|
||
private void download(String source, String destination) { | ||
String sourcePath = source; | ||
File f = new File(destination); | ||
assertFalse(f.getAbsolutePath() + " already exists.",f.exists()); | ||
Path destinationPath = Paths.get(f.getAbsolutePath()); | ||
assertTrue(icgcGetProvision.downloadFrom(sourcePath, destinationPath)); | ||
assertTrue(f.getAbsolutePath() + " not downloaded." , f.exists()); | ||
} | ||
|
||
/** | ||
* This tests if a file can be uploaded to another file and then downloaded as a different file | ||
*/ | ||
@Test | ||
public void uploadFileToFile() { | ||
String destPath = "s3cmd://test-bucket1/file2.txt"; | ||
Path sourceFile = Paths.get(resourcesDirectory + "/inputFilesDirectory/file.txt"); | ||
icgcGetProvision.uploadTo(destPath, sourceFile, null); | ||
String source = "s3cmd://test-bucket1/file2.txt"; | ||
String destination = resourcesDirectory +"/outputFilesDirectory1/file3.txt"; | ||
download(source, destination); | ||
} | ||
|
||
/** | ||
* This tests if a file can be uploaded to a directory then downloaded as a different file | ||
*/ | ||
@Test | ||
public void uploadFileToDirectory() { | ||
String destPath = "s3cmd://test-bucket2/"; | ||
Path sourceFile = Paths.get(resourcesDirectory + "/inputFilesDirectory/file.txt"); | ||
icgcGetProvision.uploadTo(destPath, sourceFile, null); | ||
String source = "s3cmd://test-bucket2/file.txt"; | ||
String destination = resourcesDirectory +"/outputFilesDirectory2/file2.txt"; | ||
download(source, destination); | ||
} | ||
|
||
/** | ||
* This tests if a directory can be uploaded to another directory and then all of its files could be downloaded | ||
*/ | ||
@Test | ||
public void uploadDirectoryToDirectory() { | ||
String destPath = "s3cmd://test-bucket3/"; | ||
Path sourceFile = Paths.get(resourcesDirectory + "/inputFilesDirectory"); | ||
icgcGetProvision.uploadTo(destPath, sourceFile, null); | ||
String source = "s3cmd://test-bucket3/inputFilesDirectory/file.txt"; | ||
String destination = resourcesDirectory +"/outputFilesDirectory3/file.txt"; | ||
download(source, destination); | ||
source = "s3cmd://test-bucket3/inputFilesDirectory/file2.txt"; | ||
destination = resourcesDirectory +"/outputFilesDirectory3/file2.txt"; | ||
download(source, destination); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/io/dockstore/provision/VerbosityEnumTest.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,25 @@ | ||
package io.dockstore.provision; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author gluu | ||
* @since 14/02/18 | ||
*/ | ||
public class VerbosityEnumTest { | ||
/** | ||
* This tests if the enum can be converted to the correct integer | ||
*/ | ||
@Test | ||
public void getLevel() throws Exception { | ||
Assert.assertEquals(1 ,VerbosityEnum.QUIET.getLevel()); | ||
Assert.assertEquals(2 ,VerbosityEnum.MINIMAL.getLevel()); | ||
Assert.assertEquals(3 ,VerbosityEnum.NORMAL.getLevel()); | ||
Assert.assertEquals(4 ,VerbosityEnum.DETAILED.getLevel()); | ||
Assert.assertEquals(5 ,VerbosityEnum.DIAGNOSTIC.getLevel()); | ||
} | ||
|
||
} |
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,76 @@ | ||
[default] | ||
access_key = potato | ||
access_token = | ||
add_encoding_exts = | ||
add_headers = | ||
bucket_location = potato | ||
ca_certs_file = | ||
cache_file = | ||
check_ssl_certificate = True | ||
check_ssl_hostname = True | ||
cloudfront_host = cloudfront.amazonaws.com | ||
default_mime_type = binary/octet-stream | ||
delay_updates = False | ||
delete_after = False | ||
delete_after_fetch = False | ||
delete_removed = False | ||
dry_run = False | ||
enable_multipart = True | ||
encoding = UTF-8 | ||
encrypt = False | ||
expiry_date = | ||
expiry_days = | ||
expiry_prefix = | ||
follow_symlinks = False | ||
force = False | ||
get_continue = False | ||
gpg_command = /usr/bin/gpg | ||
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s | ||
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s | ||
gpg_passphrase = | ||
guess_mime_type = True | ||
host_base = localhost:4572 | ||
host_bucket = | ||
human_readable_sizes = False | ||
invalidate_default_index_on_cf = False | ||
invalidate_default_index_root_on_cf = True | ||
invalidate_on_cf = False | ||
kms_key = | ||
limit = -1 | ||
limitrate = 0 | ||
list_md5 = False | ||
log_target_prefix = | ||
long_listing = False | ||
max_delete = -1 | ||
mime_type = | ||
multipart_chunk_size_mb = 15 | ||
multipart_max_chunks = 10000 | ||
preserve_attrs = True | ||
progress_meter = True | ||
proxy_host = | ||
proxy_port = 0 | ||
put_continue = False | ||
recursive = False | ||
recv_chunk = 65536 | ||
reduced_redundancy = False | ||
requester_pays = False | ||
restore_days = 1 | ||
restore_priority = Standard | ||
secret_key = | ||
send_chunk = 65536 | ||
server_side_encryption = False | ||
signature_v2 = False | ||
simpledb_host = sdb.amazonaws.com | ||
skip_existing = False | ||
socket_timeout = 300 | ||
stats = False | ||
stop_on_error = False | ||
storage_class = | ||
urlencoding_mode = normal | ||
use_http_expect = False | ||
use_https = False | ||
use_mime_magic = True | ||
verbosity = WARNING | ||
website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com/ | ||
website_error = | ||
website_index = index.html |
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 @@ | ||
asdf |
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 @@ | ||
asdf |
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,6 @@ | ||
localstack start > localstack.log & | ||
while ! less localstack.log | grep Ready. ; do | ||
sleep 1 | ||
done | ||
echo 'done' | ||
|
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.
Does this have to be manually uncommented to run locally?
If yes, just use https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#exists(java.nio.file.Path,%20java.nio.file.LinkOption...)
If no (i.e. this is superfluous, just delete it)
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.
It depends on where s3cmd is installed. I happen to have mine installed in
/usr/local/bin/s3cmd
. Travis by default installs it in/home/travis/.local/bin/s3cmd
instead. If the local user doesn't even have s3cmd installed, the tests would fail also.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.
Yeah, I would just check the two locations using Files.exists and fail otherwise indicating just that