test: add dotnet runtime tests for base container#17959
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new Dockerfile-based runtime test (test_dotnet) under the container-base image test suite to validate that the .NET 10 runtime works on the Azure Linux 4.0 base container. It follows the established pattern used by the existing test_nodejs/test_python/test_php suites: a Dockerfile layers the dotnet-sdk-10.0 on top of the image-under-test, publishes two small apps, and pytest exercises them via the shared container fixtures. The PR description frames this as a rework/rename of older base and base-extended container tests.
Changes:
- Adds
test_dotnet.pywith three tests (dotnet --version, anHttpListenerweb app served over HTTP, and a RestSharp client that confirms outbound connectivity). - Adds two .NET projects (
webapp,restclient) withProgram.cs/app.csproj, both producingapp.dll. - Adds a
Dockerfilethat installs the .NET SDK + curl and publishes both apps to/app/....
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test_dotnet/test_dotnet.py |
New pytest cases using container_exec_shell/assert_http_server; the rest-client test depends on live outbound network. |
test_dotnet/Dockerfile |
Builds on BASE_IMAGE, installs dotnet-sdk-10.0+curl, publishes both apps; consistent with sibling Dockerfiles. |
test_dotnet/webapp/Program.cs |
Minimal HttpListener server on port 8080 returning "Hello World!". |
test_dotnet/webapp/app.csproj |
net10.0 exe named app; sets InvariantGlobalization. |
test_dotnet/restclient/Program.cs |
RestSharp GET to microsoft.com, prints reachability. |
test_dotnet/restclient/app.csproj |
net10.0 exe named app; references RestSharp 112.1.0; omits InvariantGlobalization (inconsistent with webapp). |
| @pytest.mark.dockerfile() | ||
| def test_dotnet_rest_client(container_exec_shell) -> None: | ||
| """RestSharp must reach microsoft.com over the network.""" | ||
| result = container_exec_shell("dotnet /app/restclient/app.dll") | ||
| assert result.exit_code == 0, f"dotnet app failed: {result.output}" | ||
| assert "Microsoft.com is reachable." in result.output |
There was a problem hiding this comment.
@realsdx Please see if you can address this comment, and use a local endpoint instead. I hope we can avoid requiring access to public internet in the test harness.
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <AssemblyName>app</AssemblyName> | ||
| </PropertyGroup> |
| @pytest.mark.dockerfile() | ||
| def test_dotnet_rest_client(container_exec_shell) -> None: | ||
| """RestSharp must reach microsoft.com over the network.""" | ||
| result = container_exec_shell("dotnet /app/restclient/app.dll") | ||
| assert result.exit_code == 0, f"dotnet app failed: {result.output}" | ||
| assert "Microsoft.com is reachable." in result.output |
There was a problem hiding this comment.
@realsdx Please see if you can address this comment, and use a local endpoint instead. I hope we can avoid requiring access to public internet in the test harness.
| @@ -0,0 +1,9 @@ | |||
| ARG BASE_IMAGE | |||
| FROM ${BASE_IMAGE} | |||
| RUN dnf install -y dotnet-sdk-10.0 curl && dnf clean all | |||
There was a problem hiding this comment.
question (non-blocking): We will eventually be shipping multiple dotnet versions (i.e., 10 and 11). How do you propose we expand our dotnet test coverage?
Add dotnet-10.0 runtime tests for 4.0, this is a rework of our older base and base extended container tests, renamed to reflect it's true nature.