Skip to content

[s390x] Fix Extensions.ApiDescription.Client tests on s390x #58235

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saitama951
Copy link

Extensions.ApiDescription client tests cases were failing on s390x

Microsoft.Extensions.ApiDescription.Client.GetOpenApiReferenceMetadataTest.Execute_SetsClassName_BasedOnSanitizedOutputPath(outputPath: "aabb.cs", className: "aa__bb") [FAIL]
[xUnit.net 00:00:00.54]       Assert.Equal() Failure: Collections differ
[xUnit.net 00:00:00.54]       Expected: [["ClassName"] = "aa__bb", ["CodeGenerator"] = "NSwagCSharp", ["FirstForGenerator"] = "true", ["Namespace"] = "Console.Client", ["OriginalItemSpec"] = "TestProjects/files/NSwag.json", ···]
[xUnit.net 00:00:00.54]       Actual:   [["ClassName"] = "aa__bb", ["CodeGenerator"] = "NSwagCSharp", ["FirstForGenerator"] = "true", ["Namespace"] = "Console.Client", ["OriginalItemSpec"] = "TestProjects/files/NSwag.json", ···]
[xUnit.net 00:00:00.54]       Stack Trace:
[xUnit.net 00:00:00.54]         /home/sanjam/aspnetcore/src/Tools/Extensions.ApiDescription.Client/test/GetOpenApiReferenceMetadataTest.cs(450,0): at Microsoft.Extensions.ApiDescription.Client.GetOpenApiReferenceMetadataTest.Execute_SetsClassName_BasedOnSanitizedOutputPath(String outputPath, String className)
[xUnit.net 00:00:00.54]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:00.54]            at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[xUnit.net 00:00:00.54]    

according to the msdocs

For purposes of enumeration, each item in the dictionary is treated as a [KeyValuePair<TKey,TValue>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair-2?view=net-8.0) structure representing a value and its key. The order in which the items are returned is undefined.

This is just a snippet of a particular failure, I have attached the other failures as well
Untitled.txt

* The enumeration of dictionary is undefined according to msdocs.
* Sort the values of the expected and the actual in the test cases.
@ghost ghost added the area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI label Oct 4, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 4, 2024
@captainsafia
Copy link
Member

according to the msdocs

Can you provide a link to the docs you're referencing here?

@saitama951
Copy link
Author

according to the msdocs

Can you provide a link to the docs you're referencing here?

Sure . https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?view=net-8.0#remarks

Copy link
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 19, 2024
@@ -60,7 +60,9 @@ public void Execute_AddsExpectedMetadata()
orderedMetadata.Add(key, metadata[key]);
}

Assert.Equal(expectedMetadata, orderedMetadata);
expectedMetadata["SerializedMetadata"] = string.Join("|", expectedMetadata["SerializedMetadata"].Split('|').OrderBy(s => s));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why we need to make this mutation to the SerializedMetadata field on S390X targets. Can you provide an example of what the current metadata output looks like? The logs you shared appear to be truncated and don't show the actual comparison of the SerializedMetadata field.

Copy link
Author

@saitama951 saitama951 Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to my understanding, This might be due to when serializing metadata


where CloneCustomMetadata usually returns an Dictionary where the order might be undefined.

Here is the difference in this particular test case on s390x

Expected: [ClassName, NSwagClient][CodeGenerator, NSwagCSharp][FirstForGenerator, true][Namespace, Console.Client][OriginalItemSpec, TestProjects/files/NSwag.json][OutputPath, obj/NSwagClient.cs][SerializedMetadata, Identity=TestProjects/files/NSwag.json|FirstForGenerator=true|CodeGenerator=NSwagCSharp|OutputPath=obj/NSwagClient.cs|Namespace=Console.Client|OriginalItemSpec=TestProjects/files/NSwag.json|ClassName=NSwagClient]
--------------------------------------------------------------------------------------------
Actual: [ClassName, NSwagClient][CodeGenerator, NSwagCSharp][FirstForGenerator, true][Namespace, Console.Client][OriginalItemSpec, TestProjects/files/NSwag.json][OutputPath, obj/NSwagClient.cs][SerializedMetadata, Identity=TestProjects/files/NSwag.json|FirstForGenerator=true|Namespace=Console.Client|OriginalItemSpec=TestProjects/files/NSwag.json|ClassName=NSwagClient|OutputPath=obj/NSwagClient.cs|CodeGenerator=NSwagCSharp]

Note this change in order is not only wrt architecture but with runtime's as well.
here is the change in order for x64 mono

expected: [ClassName, NSwagClient][CodeGenerator, NSwagCSharp][FirstForGenerator, true][Namespace, Console.Client][OriginalItemSpec, TestProjects/files/NSwag.json][OutputPath, obj/NSwagClient.cs][SerializedMetadata, Identity=TestProjects/files/NSwag.json|FirstForGenerator=true|CodeGenerator=NSwagCSharp|OutputPath=obj/NSwagClient.cs|Namespace=Console.Client|OriginalItemSpec=TestProjects/files/NSwag.json|ClassName=NSwagClient]
--------------------------------------------------------------------------------------------
Actual: [ClassName, NSwagClient][CodeGenerator, NSwagCSharp][FirstForGenerator, true][Namespace, Console.Client][OriginalItemSpec, TestProjects/files/NSwag.json][OutputPath, obj/NSwagClient.cs][SerializedMetadata, Identity=TestProjects/files/NSwag.json|CodeGenerator=NSwagCSharp|OriginalItemSpec=TestProjects/files/NSwag.json|FirstForGenerator=true|OutputPath=obj/NSwagClient.cs|ClassName=NSwagClient|Namespace=Console.Client]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@captainsafia can we reopen this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change makes sense to me, maybe we could add a little helper method to do the reordering so we don't have all the repetitive code?

@captainsafia captainsafia added pr: pending author input For automation. Specifically separate from Needs: Author Feedback and removed pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun labels Oct 23, 2024
Copy link
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 31, 2024
@dotnet-policy-service dotnet-policy-service bot added the stale Indicates a stale issue. These issues will be closed automatically soon. label Nov 10, 2024
@akoeplinger
Copy link
Member

I was asked to reopen this so here you go.

@akoeplinger akoeplinger reopened this May 22, 2025
@akoeplinger akoeplinger removed stale Indicates a stale issue. These issues will be closed automatically soon. pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun pr: pending author input For automation. Specifically separate from Needs: Author Feedback labels May 22, 2025
Copy link
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants