Skip to content

Commit 069653d

Browse files
committed
Fix AWS nio tests [ci fast]
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent 46f5023 commit 069653d

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jobs:
8484
env:
8585
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
8686
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
87+
AWS_S3FS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
88+
AWS_S3FS_SECRET_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8789
NXF_BITBUCKET_ACCESS_TOKEN: ${{ secrets.NXF_BITBUCKET_ACCESS_TOKEN }}
8890
NXF_GITHUB_ACCESS_TOKEN: ${{ secrets.NXF_GITHUB_ACCESS_TOKEN }}
8991
NXF_GITLAB_ACCESS_TOKEN: ${{ secrets.NXF_GITLAB_ACCESS_TOKEN }}
@@ -95,6 +97,7 @@ jobs:
9597
AZURE_BATCH_ACCOUNT_KEY: ${{ secrets.AZURE_BATCH_ACCOUNT_KEY }}
9698

9799
- name: Publish tests report
100+
if: always()
98101
uses: actions/upload-artifact@v4
99102
with:
100103
name: report-unit-tests-jdk-${{ matrix.java_version }}

modules/nf-commons/src/main/nextflow/file/FileHelper.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import nextflow.extension.FilesEx
4949
import nextflow.plugin.Plugins
5050
import nextflow.util.CacheHelper
5151
import nextflow.util.Escape
52+
import nextflow.util.StringUtils
5253
/**
5354
* Provides some helper method handling files
5455
*
@@ -618,7 +619,7 @@ class FileHelper {
618619
}
619620

620621
/**
621-
* Caches File system providers
622+
* Caches File system providers
622623
*/
623624
@PackageScope
624625
static final Map<String, FileSystemProvider> providersMap = [:]
@@ -722,7 +723,7 @@ class FileHelper {
722723
try { fs = provider.getFileSystem(uri) }
723724
catch( FileSystemNotFoundException e ) { fs=null }
724725
if( !fs ) {
725-
log.debug "Creating a file system instance for provider: ${provider.class.simpleName}"
726+
log.debug "Creating a file system instance for provider: ${provider.class.simpleName}; config=${StringUtils.stripSecrets(config)}"
726727
fs = provider.newFileSystem(uri, config!=null ? config : envFor(uri.scheme))
727728
}
728729
return fs

modules/nf-commons/src/main/nextflow/util/StringUtils.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class StringUtils {
8787

8888

8989
static Map stripSecrets(Map map) {
90+
if( map==null )
91+
return null
9092
final copy = new HashMap(map.size())
9193
for( Map.Entry entry : map.entrySet() ) {
9294
if( entry.value instanceof Map ) {

modules/nf-commons/src/test/nextflow/util/StringUtilsTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class StringUtilsTest extends Specification {
8383

8484
where:
8585
SECRET | EXPECTED
86+
null | null
8687
[foo:'Hello'] | [foo:'Hello']
8788
[foo: [bar: 'World']] | [foo: [bar: 'World']]
8889
[foo: [password:'hola', token:'hi']] | [foo: [password:'****', token:'****']]

plugins/nf-amazon/src/main/nextflow/cloud/aws/AwsClientFactory.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class AwsClientFactory {
159159
return new InstanceMetadataRegionProvider().getRegion()
160160
}
161161
catch (AmazonClientException e) {
162-
log.debug "Cannot fetch AWS region", e
162+
log.debug("Cannot fetch AWS region", e as Throwable)
163163
return null
164164
}
165165
}

plugins/nf-amazon/src/main/nextflow/cloud/aws/nio/S3FileSystemProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V>
669669
throw new RuntimeException("Unable read attributes for file: " + FilesEx.toUriString(s3Path), e);
670670
}
671671
}
672-
throw new UnsupportedOperationException("Not a valid S3 file system provider file attribute view: " + type.getName());
672+
log.trace("Unsupported S3 file system provider file attribute view: " + type.getName());
673+
return null;
673674
}
674675

675676

plugins/nf-amazon/src/test/nextflow/cloud/aws/nio/AwsS3NioTest.groovy

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import java.nio.file.StandardOpenOption
3131
import java.nio.file.attribute.BasicFileAttributes
3232

3333
import com.amazonaws.services.s3.AmazonS3
34-
import com.amazonaws.services.s3.model.AmazonS3Exception
3534
import com.amazonaws.services.s3.model.Tag
3635
import groovy.util.logging.Slf4j
3736
import nextflow.Global
@@ -58,22 +57,20 @@ import spock.lang.Unroll
5857
class AwsS3NioTest extends Specification implements AwsS3BaseSpec {
5958

6059
@Shared
61-
static AmazonS3 s3Client0
60+
private AmazonS3 s3Client0
6261

6362
AmazonS3 getS3Client() { s3Client0 }
6463

65-
static {
66-
def fs = (S3FileSystem)FileHelper.getOrCreateFileSystemFor(URI.create("s3:///"), config0())
67-
s3Client0 = fs.client.getClient()
68-
}
69-
7064
static private Map config0() {
7165
def accessKey = System.getenv('AWS_S3FS_ACCESS_KEY')
7266
def secretKey = System.getenv('AWS_S3FS_SECRET_KEY')
73-
return [aws: [access_key: accessKey, secret_key: secretKey]]
67+
return [aws:[accessKey: accessKey, secretKey: secretKey]]
7468
}
7569

7670
def setup() {
71+
def fs = (S3FileSystem)FileHelper.getOrCreateFileSystemFor(URI.create("s3:///"), config0().aws)
72+
s3Client0 = fs.client.getClient()
73+
and:
7774
def cfg = config0()
7875
Global.config = cfg
7976
Global.session = Mock(Session) { getConfig()>>cfg }
@@ -207,7 +204,6 @@ class AwsS3NioTest extends Specification implements AwsS3BaseSpec {
207204
if( bucketName ) deleteBucket(bucketName)
208205
}
209206

210-
211207
def 'should copy a stream to bucket' () {
212208
given:
213209
def TEXT = "Hello world!"
@@ -240,7 +236,6 @@ class AwsS3NioTest extends Specification implements AwsS3BaseSpec {
240236
if( bucketName ) deleteBucket(bucketName)
241237
}
242238

243-
244239
def 'copy local file to a bucket' () {
245240
given:
246241
def TEXT = "Hello world!"

0 commit comments

Comments
 (0)