-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Refactored test header logic into a global spock extension #22573
Merged
kasobol-msft
merged 12 commits into
Azure:main
from
rnpmsft:feature/storage/shared-test-header-logic
Jun 28, 2021
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
75c2943
Setup packages for the data movement library (#22303)
gapra-msft d61f4d4
Removed blob data movement package, renamed common data movement to d…
gapra-msft a248605
Refactored test header logic into a global spock extension
7c99eb9
Added version tag for assembly dependency
6963444
Resolved infinite recursion on self-dependency in generate_from_sourc…
6863ed1
Changed infinite recursion fix to @alzimmermsft implementation from #…
7d5f010
Created TestNameProvider, decoupled TestHeaderExtension/StorageSpec
f0a478f
Removed duplicate header print, changed maven execution id's to preve…
5d7f382
Changed surefire dependency to local repository (resists edge case us…
e221b6a
Merge branch 'main' into feature/storage/shared-test-header-logic
rnpmsft 1f50fce
Removed DMLib WIP files to merge into main
0f42c22
Changed TestHeaderExtension from groovy to java for consistency, rena…
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
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
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
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
29 changes: 29 additions & 0 deletions
29
sdk/storage/azure-storage-common/src/test-shared/assembly/assembly.xml
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,29 @@ | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> | ||
<id>tests</id> | ||
<formats> | ||
<format>jar</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/test-classes</directory> | ||
<outputDirectory>${file.separator}</outputDirectory> | ||
<includes> | ||
<include>com/azure/storage/common/test/shared/**/*</include> | ||
<include>SpockConfig.groovy</include> | ||
</includes> | ||
<useDefaultExcludes>true</useDefaultExcludes> | ||
</fileSet> | ||
<fileSet> | ||
<directory>${project.build.directory}/test-classes/manifests</directory> | ||
<outputDirectory>${file.separator}</outputDirectory> | ||
<includes> | ||
<include>**/*</include> | ||
</includes> | ||
<useDefaultExcludes>true</useDefaultExcludes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
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
26 changes: 26 additions & 0 deletions
26
...ge-common/src/test-shared/java/com/azure/storage/common/test/shared/TestNameProvider.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,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.storage.common.test.shared; | ||
|
||
import org.spockframework.runtime.model.FeatureInfo; | ||
import org.spockframework.runtime.model.IterationInfo; | ||
import org.spockframework.runtime.model.SpecInfo; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public final class TestNameProvider { | ||
public static String getTestName(IterationInfo iterationInfo) { | ||
FeatureInfo featureInfo = iterationInfo.getFeature(); | ||
SpecInfo specInfo = featureInfo.getSpec(); | ||
|
||
String fullName = specInfo.getName() + Arrays.stream(featureInfo.getName().split(" ")) | ||
.map(it -> it.substring(0, 1).toUpperCase() + it.substring(1)) | ||
.collect(Collectors.joining("")); | ||
|
||
return (iterationInfo.getDataValues().length == 0) | ||
? fullName | ||
: String.format("%s[%d]", fullName, iterationInfo.getIterationIndex()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...test-shared/java/com/azure/storage/common/test/shared/extensions/TestHeaderExtension.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,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.storage.common.test.shared.extensions; | ||
|
||
import com.azure.storage.common.test.shared.TestNameProvider; | ||
import org.spockframework.runtime.extension.AbstractGlobalExtension; | ||
import org.spockframework.runtime.extension.IMethodInterceptor; | ||
import org.spockframework.runtime.extension.IMethodInvocation; | ||
import org.spockframework.runtime.model.SpecInfo; | ||
|
||
public final class TestHeaderExtension extends AbstractGlobalExtension { | ||
|
||
@Override | ||
public void visitSpec(SpecInfo specInfo) { | ||
specInfo.getAllFeatures().forEach(feature -> | ||
feature.addIterationInterceptor(new TestHeaderIterationInterceptor())); | ||
} | ||
|
||
private static class TestHeaderIterationInterceptor implements IMethodInterceptor { | ||
@Override | ||
public void intercept(IMethodInvocation invocation) { | ||
// Print out the test name to create breadcrumbs in our test logging in case anything hangs. | ||
String testName = TestNameProvider.getTestName(invocation.getIteration()); | ||
System.out.printf("========================= %s =========================%n", testName); | ||
try { | ||
invocation.proceed(); | ||
} catch (Throwable throwable) { | ||
throwable.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
...sources/manifests/META-INF/services/org.spockframework.runtime.extension.IGlobalExtension
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 @@ | ||
com.azure.storage.common.test.shared.extensions.TestHeaderExtension |
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
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.
how does the output of this look like in target folder when you run mvn install?
@alzimmermsft does this affect how commons is released to mvncentral anyhow that we should be worried about?
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.
maven doesnt copy over the assembly folder/file into target since it's not specified as a resource. the manifests get transferred as a
manifests
folder into thetarget/test-classes
folder, preventing it from getting caught with common tests, and the assembly plugin maps it where it needs to go in the artifactThere 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, but does test jar look the same ?
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 ran
jar xf
on it and the contents are the same.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.
This shouldn't affect releasing to Maven central as this only affect building the library from source