-
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 3 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
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>\</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>\</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import com.azure.core.http.policy.HttpPipelinePolicy | |
import com.azure.core.test.InterceptorManager | ||
import com.azure.core.test.TestMode | ||
import com.azure.core.util.ServiceVersion | ||
import com.azure.storage.common.test.shared.extensions.TestHeaderExtension | ||
import spock.lang.Specification | ||
|
||
class StorageSpec extends Specification { | ||
|
@@ -19,10 +20,9 @@ class StorageSpec extends Specification { | |
private StorageResourceNamer namer | ||
|
||
def setup() { | ||
def testName = getTestName() | ||
def testName = TestHeaderExtension.FeatureInterceptor.getTestName(specificationContext.getCurrentIteration()) | ||
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. we should create |
||
interceptorManager = new InterceptorManager(testName, ENVIRONMENT.testMode) | ||
namer = new StorageResourceNamer(testName, ENVIRONMENT.testMode, interceptorManager.getRecordedData()) | ||
System.out.printf("========================= %s =========================%n", testName) | ||
} | ||
|
||
def cleanup() { | ||
|
@@ -75,19 +75,4 @@ class StorageSpec extends Specification { | |
return interceptorManager.getPlaybackClient() | ||
} | ||
} | ||
|
||
private String getTestName() { | ||
def iterationInfo = specificationContext.currentIteration | ||
def featureInfo = iterationInfo.getParent() | ||
def specInfo = featureInfo.getParent() | ||
def fullName = specInfo.getName() + featureInfo.getName().split(" ").collect { it.capitalize() }.join("") | ||
|
||
if (iterationInfo.getDataValues().length == 0) { | ||
return fullName | ||
} | ||
def prefix = fullName | ||
def suffix = "[" + iterationInfo.getIterationIndex() + "]" | ||
|
||
return prefix + suffix | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...st-shared/java/com/azure/storage/common/test/shared/extensions/TestHeaderExtension.groovy
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,42 @@ | ||
package com.azure.storage.common.test.shared.extensions | ||
|
||
import org.spockframework.runtime.extension.AbstractGlobalExtension | ||
import org.spockframework.runtime.extension.IMethodInterceptor | ||
import org.spockframework.runtime.extension.IMethodInvocation | ||
import org.spockframework.runtime.extension.MethodInvocation | ||
import org.spockframework.runtime.model.FieldInfo | ||
import org.spockframework.runtime.model.IterationInfo | ||
import org.spockframework.runtime.model.SpecInfo | ||
|
||
class TestHeaderExtension extends AbstractGlobalExtension { | ||
@Override | ||
void visitSpec(SpecInfo spec) { | ||
spec.allFeatures*.addIterationInterceptor(new FeatureInterceptor()); | ||
spec.addInitializerInterceptor(new FeatureInterceptor()); | ||
} | ||
|
||
static class FeatureInterceptor implements IMethodInterceptor { | ||
@Override | ||
void intercept(IMethodInvocation inv) { | ||
// Print out the test name to create breadcrumbs in our test logging in case anything hangs. | ||
System.out.printf("========================= %s =========================%n", getTestName(inv.getIteration())) | ||
inv.proceed(); | ||
FieldInfo field = new FieldInfo(); | ||
inv | ||
} | ||
|
||
static String getTestName(IterationInfo iterationInfo) { | ||
def featureInfo = iterationInfo.getParent() | ||
def specInfo = featureInfo.getParent() | ||
def fullName = specInfo.getName() + featureInfo.getName().split(" ").collect { it.capitalize() }.join("") | ||
|
||
if (iterationInfo.getDataValues().length == 0) { | ||
return fullName | ||
} | ||
def prefix = fullName | ||
def suffix = "[" + iterationInfo.getIterationIndex() + "]" | ||
|
||
return prefix + suffix | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Release History | ||
|
||
## 12.0.0-beta.1 (Unreleased) | ||
|
||
### Features included in `azure-storage-data-movement` | ||
- This package supports functionality for storage data movement library. | ||
- Reactive streams support using [Project Reactor](https://projectreactor.io/). |
Empty file.
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