Skip to content
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

Extract Aspire.Hosting.MongoDB.Tests project #5017

Merged
merged 24 commits into from
Aug 6, 2024

Conversation

Alirexaa
Copy link
Contributor

@Alirexaa Alirexaa commented Jul 22, 2024

Contributes to #3185
Contributes to #4294
Fixes #5184

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-codeflow for labeling automated codeflow. intentionally a different color! label Jul 22, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 22, 2024
@radical radical added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication testing ☑️ and removed area-codeflow for labeling automated codeflow. intentionally a different color! labels Jul 24, 2024
@sebastienros
Copy link
Member

Maybe tests have feelings and don't like me.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

What's the status of this PR? Is anyone working on getting the tests passing in CI?

tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj Outdated Show resolved Hide resolved
tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj Outdated Show resolved Hide resolved
Comment on lines +147 to +148
//mongodb shutdown has delay,so without delay to running instance using same data and second instance failed to start.
await Task.Delay(TimeSpan.FromSeconds(10));
Copy link
Member

Choose a reason for hiding this comment

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

We need to make this more deterministic. Waiting for X seconds is usually how we get random/flakey failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's your suggestion?
I don't have any idea.

Copy link
Member

Choose a reason for hiding this comment

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

Try to connect to the database until it fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any helper method exists to check container is fully stopped?

Copy link
Member

Choose a reason for hiding this comment

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

I was expecting something like #4878. If you want to prototype trying to make that work. cc @karolz-ms @DamianEdwards

Copy link
Member

Choose a reason for hiding this comment

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

@sebastienros - should we log an issue for this wait case, and then we can merge 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.

Filed #5199

@Alirexaa
Copy link
Contributor Author

What's the status of this PR? Is anyone working on getting the tests passing in CI?

I will check.

@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 1, 2024

Seems the test failed on Linux how can i see container logs?

@eerhardt
Copy link
Member

eerhardt commented Aug 1, 2024

Seems the test failed on Linux how can i see container logs?

Here's how I do it. I'm not sure if there is a faster way:

image

image

image

Then find the appropriate test under here:

image

@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 1, 2024

@eerhardt I can't open it!
temp 1

@eerhardt
Copy link
Member

eerhardt commented Aug 1, 2024

@eerhardt I can't open it!

Hmm, does it work if you "log in" (using any Microsoft account)?

@eerhardt
Copy link
Member

eerhardt commented Aug 1, 2024

Here's the log output:

=== COMMAND LINE ===
/mnt/vss/_work/1/s/.dotnet/dotnet test /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0/Aspire.Hosting.MongoDB.Tests.dll --logger:console;verbosity=normal --logger:trx;LogFileName=Aspire.Hosting.MongoDB.Tests_net8.0_x64.trx --logger:html;LogFileName=Aspire.Hosting.MongoDB.Tests_net8.0_x64.html --ResultsDirectory:/mnt/vss/_work/1/s/artifacts/TestResults/Release --Framework:.NETCoreApp,Version=v8.0 --settings:/mnt/vss/_work/1/s/eng/testing/.runsettings
Microsoft (R) Test Execution Command Line Tool Version 17.10.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 8.0.7)
[xUnit.net 00:00:05.50]   Discovering: Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.60]   Discovered:  Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.61]   Starting:    Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.86]     Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount [FAIL]
[xUnit.net 00:00:05.86]       System.IO.FileNotFoundException : Could not find file '/tmp/W0apBK/mongo-init.js'.
[xUnit.net 00:00:05.86]       Stack Trace:
[xUnit.net 00:00:05.86]            at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
[xUnit.net 00:00:05.86]            at Interop.CheckIo(Int64 result, String path, Boolean isDirError)
[xUnit.net 00:00:05.86]            at System.IO.FileStatus.SetUnixFileMode(SafeFileHandle handle, String path, UnixFileMode mode)
[xUnit.net 00:00:05.86]            at System.IO.File.SetUnixFileMode(String path, UnixFileMode mode)
[xUnit.net 00:00:05.86]         /_/tests/Aspire.Hosting.MongoDB.Tests/MongoDbFunctionalTests.cs(226,0): at Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount()
[xUnit.net 00:00:05.86]         --- End of stack trace from previous location ---
  Failed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount [18 ms]
  Error Message:
   System.IO.FileNotFoundException : Could not find file '/tmp/W0apBK/mongo-init.js'.
  Stack Trace:
     at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Interop.CheckIo(Int64 result, String path, Boolean isDirError)
   at System.IO.FileStatus.SetUnixFileMode(SafeFileHandle handle, String path, UnixFileMode mode)
   at System.IO.File.SetUnixFileMode(String path, UnixFileMode mode)
   at Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount() in /_/tests/Aspire.Hosting.MongoDB.Tests/MongoDbFunctionalTests.cs:line 226
--- End of stack trace from previous location ---
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressUsesContainerHost(containerHost: "host.containers.internal") [351 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressUsesContainerHost(containerHost: "host.docker.internal") [51 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.AddMongoDBContainerWithDefaultsAddsAnnotationMetadata [40 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.CanAddDatabasesWithDifferentNamesOnSingleServer [37 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressSupportsChangingContainerImageValues [6 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.MongoDBCreatesConnectionString [45 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.ThrowsWithIdenticalChildResourceNamesDifferentParents [19 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressAddsContainer [21 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressOnMultipleResources [14 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.ThrowsWithIdenticalChildResourceNames [7 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.AddMongoDBContainerAddsAnnotationMetadata [15 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.VerifyManifest [66 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressSupportsChangingHostPort [5 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.CanAddDatabasesWithTheSameNameOnMultipleServers [23 ms]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.XSgQYK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 34989}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      1 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:35417" }", EndPoint: "Unspecified/localhost:35417", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:19.9663882Z" }] } Waiting for suitable server to become available 29995
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-44f6771f is now in state Ready	{"ServiceName": {"name":"mongodb-44f6771f"}, "Reconciliation": 4}
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.Rc1bvM/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 34499}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      2 CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } 4 find { ClusterId : "2", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 2, EndPoint : "Unspecified/localhost:44957" }", EndPoint: "Unspecified/localhost:44957", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:46.7078602Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-4fe4832a is now in state Ready	{"ServiceName": {"name":"mongodb-4fe4832a"}, "Reconciliation": 4}
Aspire.Hosting.Tests-mongodb-WithDataShouldPersistStateBetweenUsages
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.WithDataShouldPersistStateBetweenUsages(useVolume: True) [36 s]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.zAb2nK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 38549}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      3 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "3", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 3, EndPoint : "Unspecified/localhost:40211" }", EndPoint: "Unspecified/localhost:40211", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:52.1137718Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-4ed68fc1 is now in state Ready	{"ServiceName": {"name":"mongodb-4ed68fc1"}, "Reconciliation": 4}
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.NESYhK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 44327}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      4 CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } 8 find { ClusterId : "4", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 4, EndPoint : "Unspecified/localhost:41959" }", EndPoint: "Unspecified/localhost:41959", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:44:08.2359169Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-65151e58 is now in state Ready	{"ServiceName": {"name":"mongodb-65151e58"}, "Reconciliation": 4}
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.WithDataShouldPersistStateBetweenUsages(useVolume: False) [19 s]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.Tmff3K/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 37313}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      5 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "5", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 5, EndPoint : "Unspecified/localhost:38933" }", EndPoint: "Unspecified/localhost:38933", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:44:12.0861956Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-7705c23b is now in state Ready	{"ServiceName": {"name":"mongodb-7705c23b"}, "Reconciliation": 4}
[xUnit.net 00:01:06.14]   Finished:    Aspire.Hosting.MongoDB.Tests
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyMongoDBResource [4 s]

Test Run Failed.
Total tests: 18
     Passed: 17
     Failed: 1
 Total time: 1.1269 Minutes
Results File: /mnt/vss/_work/1/s/artifacts/TestResults/Release/Aspire.Hosting.MongoDB.Tests_net8.0_x64.trx
Html test results file : /mnt/vss/_work/1/s/artifacts/TestResults/Release/Aspire.Hosting.MongoDB.Tests_net8.0_x64.html

@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 1, 2024

@eerhardt I can't open it!

Hmm, does it work if you "log in" (using any Microsoft account)?

didn't work

@Alirexaa
Copy link
Contributor Author

Alirexaa commented Aug 1, 2024

Here's the log output:

=== COMMAND LINE ===
/mnt/vss/_work/1/s/.dotnet/dotnet test /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0/Aspire.Hosting.MongoDB.Tests.dll --logger:console;verbosity=normal --logger:trx;LogFileName=Aspire.Hosting.MongoDB.Tests_net8.0_x64.trx --logger:html;LogFileName=Aspire.Hosting.MongoDB.Tests_net8.0_x64.html --ResultsDirectory:/mnt/vss/_work/1/s/artifacts/TestResults/Release --Framework:.NETCoreApp,Version=v8.0 --settings:/mnt/vss/_work/1/s/eng/testing/.runsettings
Microsoft (R) Test Execution Command Line Tool Version 17.10.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 8.0.7)
[xUnit.net 00:00:05.50]   Discovering: Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.60]   Discovered:  Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.61]   Starting:    Aspire.Hosting.MongoDB.Tests
[xUnit.net 00:00:05.86]     Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount [FAIL]
[xUnit.net 00:00:05.86]       System.IO.FileNotFoundException : Could not find file '/tmp/W0apBK/mongo-init.js'.
[xUnit.net 00:00:05.86]       Stack Trace:
[xUnit.net 00:00:05.86]            at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
[xUnit.net 00:00:05.86]            at Interop.CheckIo(Int64 result, String path, Boolean isDirError)
[xUnit.net 00:00:05.86]            at System.IO.FileStatus.SetUnixFileMode(SafeFileHandle handle, String path, UnixFileMode mode)
[xUnit.net 00:00:05.86]            at System.IO.File.SetUnixFileMode(String path, UnixFileMode mode)
[xUnit.net 00:00:05.86]         /_/tests/Aspire.Hosting.MongoDB.Tests/MongoDbFunctionalTests.cs(226,0): at Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount()
[xUnit.net 00:00:05.86]         --- End of stack trace from previous location ---
  Failed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount [18 ms]
  Error Message:
   System.IO.FileNotFoundException : Could not find file '/tmp/W0apBK/mongo-init.js'.
  Stack Trace:
     at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Interop.CheckIo(Int64 result, String path, Boolean isDirError)
   at System.IO.FileStatus.SetUnixFileMode(SafeFileHandle handle, String path, UnixFileMode mode)
   at System.IO.File.SetUnixFileMode(String path, UnixFileMode mode)
   at Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount() in /_/tests/Aspire.Hosting.MongoDB.Tests/MongoDbFunctionalTests.cs:line 226
--- End of stack trace from previous location ---
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressUsesContainerHost(containerHost: "host.containers.internal") [351 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressUsesContainerHost(containerHost: "host.docker.internal") [51 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.AddMongoDBContainerWithDefaultsAddsAnnotationMetadata [40 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.CanAddDatabasesWithDifferentNamesOnSingleServer [37 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressSupportsChangingContainerImageValues [6 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.MongoDBCreatesConnectionString [45 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.ThrowsWithIdenticalChildResourceNamesDifferentParents [19 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressAddsContainer [21 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressOnMultipleResources [14 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.ThrowsWithIdenticalChildResourceNames [7 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.AddMongoDBContainerAddsAnnotationMetadata [15 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.VerifyManifest [66 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.WithMongoExpressSupportsChangingHostPort [5 ms]
  Passed Aspire.Hosting.MongoDB.Tests.AddMongoDBTests.CanAddDatabasesWithTheSameNameOnMultipleServers [23 ms]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.XSgQYK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 34989}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      1 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:35417" }", EndPoint: "Unspecified/localhost:35417", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:19.9663882Z" }] } Waiting for suitable server to become available 29995
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-44f6771f is now in state Ready	{"ServiceName": {"name":"mongodb-44f6771f"}, "Reconciliation": 4}
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.Rc1bvM/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 34499}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      2 CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } 4 find { ClusterId : "2", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 2, EndPoint : "Unspecified/localhost:44957" }", EndPoint: "Unspecified/localhost:44957", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:46.7078602Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-4fe4832a is now in state Ready	{"ServiceName": {"name":"mongodb-4fe4832a"}, "Reconciliation": 4}
Aspire.Hosting.Tests-mongodb-WithDataShouldPersistStateBetweenUsages
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.WithDataShouldPersistStateBetweenUsages(useVolume: True) [36 s]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.zAb2nK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 38549}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      3 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "3", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 3, EndPoint : "Unspecified/localhost:40211" }", EndPoint: "Unspecified/localhost:40211", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:43:52.1137718Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-4ed68fc1 is now in state Ready	{"ServiceName": {"name":"mongodb-4ed68fc1"}, "Reconciliation": 4}
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.NESYhK/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 44327}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      4 CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } 8 find { ClusterId : "4", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 4, EndPoint : "Unspecified/localhost:41959" }", EndPoint: "Unspecified/localhost:41959", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:44:08.2359169Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-65151e58 is now in state Ready	{"ServiceName": {"name":"mongodb-65151e58"}, "Reconciliation": 4}
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.WithDataShouldPersistStateBetweenUsages(useVolume: False) [19 s]
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.1-ci
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 19633 --detach --kubeconfig "/tmp/aspire.Tmff3K/kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started	{"Address": "127.0.0.1", "Port": 37313}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services	{"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /mnt/vss/_work/1/s/artifacts/bin/Aspire.Hosting.MongoDB.Tests/Release/net8.0
info: MongoDB.ServerSelection[0]
      5 CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector } (null) create { ClusterId : "5", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 5, EndPoint : "Unspecified/localhost:38933" }", EndPoint: "Unspecified/localhost:38933", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2024-08-01T13:44:12.0861956Z" }] } Waiting for suitable server to become available 29999
info: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      service /mongodb-7705c23b is now in state Ready	{"ServiceName": {"name":"mongodb-7705c23b"}, "Reconciliation": 4}
[xUnit.net 00:01:06.14]   Finished:    Aspire.Hosting.MongoDB.Tests
  Passed Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyMongoDBResource [4 s]

Test Run Failed.
Total tests: 18
     Passed: 17
     Failed: 1
 Total time: 1.1269 Minutes
Results File: /mnt/vss/_work/1/s/artifacts/TestResults/Release/Aspire.Hosting.MongoDB.Tests_net8.0_x64.trx
Html test results file : /mnt/vss/_work/1/s/artifacts/TestResults/Release/Aspire.Hosting.MongoDB.Tests_net8.0_x64.html

Thanks, maybe i need logs again.

@eerhardt
Copy link
Member

eerhardt commented Aug 1, 2024

@eerhardt I can't open it!

Hmm, does it work if you "log in" (using any Microsoft account)?

didn't work

I got an answer from some of my team members that if you aren't a Microsoft employee, you can download the whole artifacts by click the little three dots on the right:

image

That will get you all the artifacts for that leg.


if (!OperatingSystem.IsWindows())
{
System.Diagnostics.Process.Start("/usr/bin/env", $"sudo chmod -R a+rwx {bindMountPath}").WaitForExit();
Copy link
Member

Choose a reason for hiding this comment

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

Why can't this use File.SetUnixFileMode?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we shouldn't use Directory.CreateTempSubdirectory() in this case since we need other users to be able to see it? Directory.CreateTempSubdirectory() explicitly only gives the current user access to the directory, for security reasons. We might as well make a normal folder if we need other users to access it.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

My only concern is the "wait 10 seconds" in the test. But I think we could log an issue for it to unblock merging this PR.

@sebastienros sebastienros merged commit 1f52231 into dotnet:main Aug 6, 2024
11 checks passed
@Alirexaa Alirexaa deleted the mongodb-tests branch August 6, 2024 16:21
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication community-contribution Indicates that the PR has been added by a community member testing ☑️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure on CI : Aspire.Hosting.MongoDB.Tests.MongoDbFunctionalTests.VerifyWithInitBindMount
4 participants