Skip to content

Add test for PostgresServerResource.WithInitBindMount#4926

Merged
sebastienros merged 8 commits intomainfrom
sebros/initpgsql
Jul 18, 2024
Merged

Add test for PostgresServerResource.WithInitBindMount#4926
sebastienros merged 8 commits intomainfrom
sebros/initpgsql

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

@sebastienros sebastienros commented Jul 16, 2024

Realized it was missing when I extracted MySql which has the same one.

Microsoft Reviewers: Open in CodeFlow

@sebastienros sebastienros requested a review from mitchdenny as a code owner July 16, 2024 08:24
@ghost ghost added the area-integrations Issues pertaining to Aspire Integrations packages label Jul 16, 2024
Copy link
Copy Markdown
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.

Looks good. Just some minor tweaks.

command.CommandText = $"SELECT * FROM cars;";
var results = await command.ExecuteReaderAsync(token);

Assert.Single(results);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be useful to assert the contents of the result too?

@radical
Copy link
Copy Markdown
Member

radical commented Jul 17, 2024

Test failing with:

Npgsql.NpgsqlException : Exception while reading from stream
---- System.TimeoutException : Timeout during reading attempt
CallStack
   at Npgsql.Internal.NpgsqlReadBuffer.<Ensure>g__EnsureLong|55_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
   at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|213_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
   at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.PoolingDataSource.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.PoolingDataSource.<Get>g__RentAsync|34_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|42_0(Boolean async, CancellationToken cancellationToken)
   at Aspire.Hosting.PostgreSQL.Tests.PostgresFunctionalTests.<>c__DisplayClass4_0.<<VerifyWithInitBindMount>b__0>d.MoveNext() in /_/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresFunctionalTests.cs:line 277
--- End of stack trace from previous location ---
   at Polly.ResiliencePipeline.<>c.<<ExecuteAsync>b__3_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Polly.Outcome`1.GetResultOrRethrow()
   at Polly.ResiliencePipeline.ExecuteAsync(Func`2 callback, CancellationToken cancellationToken)
   at Aspire.Hosting.PostgreSQL.Tests.PostgresFunctionalTests.VerifyWithInitBindMount() in /_/tests/Aspire.Hosting.PostgreSQL.Tests/PostgresFunctionalTests.cs:line 274
--- End of stack trace from previous location ---
----- Inner Stack Trace -----

And the log has this:

Aspire.Hosting.DistributedApplication Information: Aspire version: 8.1.0-ci
Aspire.Hosting.DistributedApplication Information: Distributed application starting.
Aspire.Hosting.DistributedApplication Information: Application host directory is: /mnt/vss/_work/1/s/tests/Aspire.Hosting.Tests
Aspire.Hosting.Dcp.DcpHostService Information: Starting DCP with arguments: start-apiserver --monitor 31344 --detach --kubeconfig "/tmp/aspire.3Rh1Ng/kubeconfig"
Aspire.Hosting.Dcp.start-apiserver.api-server Information: Starting API server...
Aspire.Hosting.Dcp.start-apiserver.api-server Information: API server started	{"Address": "127.0.0.1", "Port": 40475}
Aspire.Hosting.Dcp.start-apiserver.dcp-host Information: Starting DCP controller host
Aspire.Hosting.Dcp.start-apiserver.dcp-host Information: Started all services	{"count": 1}
Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner Information: Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
Aspire.Hosting.Dcp.dcpctrl Information: starting controller manager
Aspire.Hosting.DistributedApplication Information: Distributed application started. Press Ctrl+C to shut down.
Aspire.Hosting.Dcp.dcpctrl.ContainerReconciler
	Error: could not determine host address and port for container port	{"Container": {"name":"pg-cudsemnp-ac4b991"}, "Reconciliation": 5, "error": "container '/pg-cudsemnp-ac4b991' is not running: exited"}
Aspire.Hosting.Dcp.dcpctrl.ContainerReconciler
	Error: could not create Endpoint object	{"Container": {"name":"pg-cudsemnp-ac4b991"}, "Reconciliation": 5, "ServiceName": "pg-ac4b991", "Workload": "/pg-cudsemnp-ac4b991", "error": "container '/pg-cudsemnp-ac4b991' is not running: exited"}

@sebastienros
Copy link
Copy Markdown
Contributor Author

@radical do you know if there is a way to get the Docker logs for the failure? I want to see if there is an issue during the initialization of the image, since we are passing a custom bind mount and the DCP errors seems to indicate that the container hasn't started for this test only.

@mitchdenny
Copy link
Copy Markdown
Member

@sebastienros
Copy link
Copy Markdown
Contributor Author

Worked like a charm, so I know what's happening now:

84: 2024-07-18T09:38:12.907160440Z ls: cannot open directory '/docker-entrypoint-initdb.d/': Permission denied

@sebastienros sebastienros merged commit 604f62f into main Jul 18, 2024
@sebastienros sebastienros deleted the sebros/initpgsql branch July 18, 2024 15:46
@github-actions github-actions bot locked and limited conversation to collaborators Aug 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants