-
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
Refactored test header logic into a global spock extension #22573
Conversation
I should've marked this as a draft; this likely isn't ready for merge before decoupling the extension and spec. |
Did you just solve the |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
we should create TestNameProvider
or something like this and extract getTestName
there and use it in both places.
Can be static code.
<descriptors> | ||
<descriptor>src/test-shared/assembly/assembly.xml</descriptor> | ||
</descriptors> |
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 the target/test-classes
folder, preventing it from getting caught with common tests, and the assembly plugin maps it where it needs to go in the artifact
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, 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
Appears you've found a bug in the |
@alzimmermsft Does that mean this solution will stop working and we should fall back to option 2 mentioned in PR description? |
This PR should resolve the infinite recursion in the Python script: #22583 |
The current approach is good, I'd rather wrangle a bit more infrastructure that only affects testing rather than move classes around before compilation and clean the up after it. |
I think either way, the bug fix was necessary; both solutions rely on the META-INF being found in the test jar instead of living in the target folder for common, meaning the self-dependency would have to be there for both options. I've mirrored your changes, let's see if CI is happy. I've pointed this PR to the |
Yes, I think that would be fine if you point this PR to main and then once this PR is merged, merge main into the DataMovement branch |
…nt overriding parent POM + better relay execution goals, removed maven self-dependency (now using surefire classpath dependency)
…er changes to target path), fixed assembly paths for *nix-compatibility
…med variables/class names for clarity, final on new classes
Changes until this point:
|
@alzimmermsft Any issues here? |
Resolves #22458 |
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.
Looks good to me!
Sooo this is one possible solution for centralizing the header logic, I've gone ahead and removed all header prints throughout the storage SDK in this branch as well. To deal with the classpath issue, I've changed the bundling for shared resources to use
maven-assembly-plugin
rather than the jar plugin; this way, we can have theMETA-INF
folder somewhere that won't conflict, and redirect it within the jar.The other solution was using
maven-resources-plugin
andmaven-clean-plugin
to move the extension manifest from some location intotarget/test-classes/META-INF/services
right before thetest-compile
phase, then clean the file out right after (withprocess-test-classes
), but the assembly sol seemed a bit tidier.File locations and stuff could use some change, I just put everything somewhere it would work.
assembly.xml
/themanifests
folder might do better in a centralized location, since they're only used by the shared build; maybetest-shared/resources
(if that doesn't automatically get sent by maven totarget/test-classes
). We could also put theSpockConfig.groovy
into there to separate shared tests resources fully from just common test resources.One iffy thing in here; I nabbed the
getTestName
logic fromStorageSpec
and put it into the extensions for use with printing headers, and this caused code duplication; for now, there's a static reference fromStorageSpec
into the extension to call the method, which probably should be changed. Any thoughts on fixing that? Maybe just aTestNamer
or something that both the spec and extension can use?