Skip to content

Commit

Permalink
Update test dotnet targets
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Jul 17, 2024
1 parent 92d1d97 commit b834605
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;</TargetFrameworks>
<TargetFrameworks>net9.0;</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;</TargetFrameworks>
<TargetFrameworks>net9.0;</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<UserSecretsId>3648c5f3-f642-441e-979e-d4624cd39e49</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Platforms>AnyCPU</Platforms>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net9.0</TargetFrameworks>
<Platforms>AnyCPU</Platforms>

<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net8.0;</TargetFrameworks>
<TargetFrameworks>net462;net9.0;</TargetFrameworks>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
Expand Down Expand Up @@ -56,10 +56,10 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0|AnyCPU'">
<NoWarn>1701;1702;NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0|AnyCPU'">
<NoWarn>1701;1702;NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
Expand Down
30 changes: 15 additions & 15 deletions src/Certify.Tests/Certify.Core.Tests.Unit/Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ To build the Docker Images for the Certify Core Unit Tests, first navigate to `c
To build the Linux images, use the following Docker build commands (make sure Docker Desktop is switched to Linux containers):

```
// For .NET Core 8.0
docker build ..\..\..\..\ -t certify-core-tests-unit-8_0-linux -f .\certify-core-tests-unit-8_0-linux.dockerfile
// For .NET Core 9.0
docker build ..\..\..\..\ -t certify-core-tests-unit-9_0-linux -f .\certify-core-tests-unit-9_0-linux.dockerfile
```

### Windows Images
Expand All @@ -21,8 +21,8 @@ To build the Windows images, use the following Docker build commands (make sure
// For .NET 4.6.2
docker build ..\..\..\..\ -t certify-core-tests-unit-4_6_2-win -f .\certify-core-tests-unit-4_6_2-win.dockerfile -m 8GB
// For .NET Core 8.0
docker build ..\..\..\..\ -t certify-core-tests-unit-8_0-win -f .\certify-core-tests-unit-8_0-win.dockerfile -m 8GB
// For .NET Core 9.0
docker build ..\..\..\..\ -t certify-core-tests-unit-9_0-win -f .\certify-core-tests-unit-9_0-win.dockerfile -m 8GB
// For the step-ca-win image
docker build . -t step-ca-win -f .\step-ca-win.dockerfile
Expand Down Expand Up @@ -56,8 +56,8 @@ To run the Windows Tests in Docker, use the following Docker Compose command:
// For .NET 4.6.2
docker compose --profile 4_6_2 -f windows_compose.yaml up -d
// For .NET Core 8.0
docker compose --profile 8_0 -f windows_compose.yaml up -d
// For .NET Core 9.0
docker compose --profile 9_0 -f windows_compose.yaml up -d
```

To stop the Windows Tests in Docker, use the following Docker Compose command:
Expand All @@ -67,7 +67,7 @@ To stop the Windows Tests in Docker, use the following Docker Compose command:
docker compose --profile 4_6_2 -f windows_compose.yaml down -v
// For .NET Core 8.0
docker compose --profile 8_0 -f windows_compose.yaml down -v
docker compose --profile 9_0 -f windows_compose.yaml down -v
```

### Debugging Tests Running in Containers with Docker Compose in Visual Studio
Expand All @@ -77,14 +77,14 @@ Within each test Docker Compose file are commented out lines for debugging subse
To run an individual class of tests, uncomment the following section of the corresponding Docker Compose file, with the name of the test class you wish to run following `ClassName=`:

```
entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
```

To run an individual test, uncomment the following section of the corresponding Docker Compose file, with
the name of the test you wish to run following `Name=`:

```
entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'Name=TestCertifyManagerGetAccountDetailsDefinedCertificateAuthorityId'"
entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'Name=TestCertifyManagerGetAccountDetailsDefinedCertificateAuthorityId'"
```

To run tests using the Visual Studio debugger, first ensure that you have the `Containers` window visible (`View -> Other Windows -> Containers`)
Expand Down Expand Up @@ -131,25 +131,25 @@ To do this, first navigate to `certify\src\Certify.Tests\Certify.Core.Tests.Unit
To run all of the Certify Core Unit Tests in a Linux container, use the following command:

```
docker run --name core-tests-unit-8_0-linux --rm -it -v ${pwd}\bin\Debug\net8.0:/app -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet test Certify.Core.Tests.Unit.dll -f net8.0
docker run --name core-tests-unit-9_0-linux --rm -it -v ${pwd}\bin\Debug\net9.0:/app -w /app mcr.microsoft.com/dotnet/sdk:9.0 dotnet test Certify.Core.Tests.Unit.dll -f net9.0
```

To run a specific class of Certify Core Unit Tests in a Linux container, use the following command, substituting the Class Name of the tests after `--filter "ClassName=`:

```
docker run --name core-tests-unit-8_0-linux --rm -it -v ${pwd}\bin\Debug\net8.0:/app -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter "ClassName=Certify.Core.Tests.Unit.DnsQueryTests"
docker run --name core-tests-unit-9_0-linux --rm -it -v ${pwd}\bin\Debug\net9.0:/app -w /app mcr.microsoft.com/dotnet/sdk:9.0 dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter "ClassName=Certify.Core.Tests.Unit.DnsQueryTests"
```

To run a single Certify Core Unit Test in a Linux container, use the following command, substituting the Test Name of the tests after `--filter "Name=`:

```
docker run --name core-tests-unit-8_0-linux --rm -it -v ${pwd}\bin\Debug\net8.0:/app -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter "Name=MixedIPBindingChecksNoPreview"
docker run --name core-tests-unit-9_0-linux --rm -it -v ${pwd}\bin\Debug\net9.0:/app -w /app mcr.microsoft.com/dotnet/sdk:9.0 dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter "Name=MixedIPBindingChecksNoPreview"
```

To run Certify Core Unit Tests with Debugging in a Linux container, use the following command, add `-e VSTEST_HOST_DEBUG=1` as a `docker run` parameter like so:

```
docker run --name core-tests-unit-8_0-linux --rm -it -e VSTEST_HOST_DEBUG=1 -v ${pwd}\bin\Debug\net8.0:/app -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet test Certify.Core.Tests.Unit.dll -f net8.0"
docker run --name core-tests-unit-9_0-linux --rm -it -e VSTEST_HOST_DEBUG=1 -v ${pwd}\bin\Debug\net9.0:/app -w /app mcr.microsoft.com/dotnet/sdk:9.0 dotnet test Certify.Core.Tests.Unit.dll -f net9.0"
```

### Running Certify Core Unit Tests with a Windows Base Image
Expand All @@ -160,10 +160,10 @@ To run all of the Certify Core Unit Tests in a Windows container, use the follow

```
// For .NET 4.6.2
docker run --name core-tests-unit-4_6_2-win --rm -it -v ${pwd}\bin\Debug\net462:C:\app -w C:\app mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 dotnet test Certify.Core.Tests.Unit.dll -f net462
docker run --name core-tests-unit-4_6_2-win --rm -it -v ${pwd}\bin\Debug\net462:C:\app -w C:\app mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 dotnet test Certify.Core.Tests.Unit.dll -f net462
// For .NET Core 8.0
docker run --name core-tests-unit-8_0-win --rm -it -v ${pwd}\bin\Debug\net8.0:C:\app -w C:\app mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 dotnet test Certify.Core.Tests.Unit.dll -f net8.0
docker run --name core-tests-unit-9_0-win --rm -it -v ${pwd}\bin\Debug\net9.0:C:\app -w C:\app mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 dotnet test Certify.Core.Tests.Unit.dll -f net9.0
```

See the above Linux examples to see how to run tests selectively or with debugging enabled.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public async Task TestDNS_CheckTXT()
{
var net = new NetworkUtils(enableProxyValidationAPI: true);

var logImp = new LoggerConfiguration()
.WriteTo.Debug()
.CreateLogger();

var log = new Loggy(logImp);
var log = new Loggy(null);

// check invalid domain
var result = await net.GetDNSRecordTXT(log, "_acme-challenge-test.cointelligence.io");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS base
FROM mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 9696

# define build and copy required source files
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 AS build
WORKDIR /src
COPY ./certify/src ./certify/src
COPY ./certify-plugins/src ./certify-plugins/src
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 9696
RUN wget https://dl.smallstep.com/gh-release/cli/docs-cli-install/v0.23.0/step-cli_0.23.0_amd64.deb && dpkg -i step-cli_0.23.0_amd64.deb

# define build and copy required source files
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ./certify/src ./certify/src
COPY ./certify-plugins/src ./certify-plugins/src
Expand All @@ -15,8 +15,8 @@ COPY ./libs/anvil ./libs/anvil

# build and publish (as Release mode) to /app/publish
FROM build AS publish
RUN dotnet publish ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/Certify.Core.Tests.Unit.csproj -f net8.0 -c Debug -o /app/publish
RUN dotnet publish ./certify-internal/src/Certify.Plugins/Plugins.All/Plugins.All.csproj -f net8.0 -c Debug -o /app/publish/plugins
RUN dotnet publish ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/Certify.Core.Tests.Unit.csproj -f net9.0 -c Debug -o /app/publish
RUN dotnet publish ./certify-internal/src/Certify.Plugins/Plugins.All/Plugins.All.csproj -f net9.0 -c Debug -o /app/publish/plugins
COPY ./libs/Posh-ACME/Posh-ACME /app/publish/Scripts/DNS/PoshACME

# copy build from /app/publish in sdk image to final image
Expand All @@ -25,4 +25,4 @@ WORKDIR /app
COPY --from=publish /app/publish .

# run the service, alternatively we could runs tests etc
ENTRYPOINT ["dotnet", "test", "Certify.Core.Tests.Unit.dll", "-f", "net8.0"]
ENTRYPOINT ["dotnet", "test", "Certify.Core.Tests.Unit.dll", "-f", "net9.0"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS base
FROM mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
Expand All @@ -9,7 +9,7 @@ RUN setx /M PATH "%PATH%;C:\Program Files\step_0.24.4\bin"
USER ContainerUser

# define build and copy required source files
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0-preview-windowsservercore-ltsc2022 AS build
WORKDIR /src
COPY ./certify/src ./certify/src
COPY ./certify-plugins/src ./certify-plugins/src
Expand All @@ -18,8 +18,8 @@ COPY ./libs/anvil ./libs/anvil

# build and publish (as Debug mode) to /app/publish
FROM build AS publish
RUN dotnet publish ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/Certify.Core.Tests.Unit.csproj -f net8.0 -c Debug -o /app/publish
RUN dotnet publish ./certify-internal/src/Certify.Plugins/Plugins.All/Plugins.All.csproj -f net8.0 -c Debug -o /app/publish/plugins
RUN dotnet publish ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/Certify.Core.Tests.Unit.csproj -f net9.0 -c Debug -o /app/publish
RUN dotnet publish ./certify-internal/src/Certify.Plugins/Plugins.All/Plugins.All.csproj -f net9.0 -c Debug -o /app/publish/plugins
COPY ./libs/Posh-ACME/Posh-ACME /app/publish/Scripts/DNS/PoshACME

# copy build from /app/publish in sdk image to final image
Expand All @@ -28,4 +28,4 @@ WORKDIR /app
COPY --from=publish /app/publish .

# run the service, alternatively we could runs tests etc
ENTRYPOINT ["dotnet", "test", "Certify.Core.Tests.Unit.dll", "-f", "net8.0"]
ENTRYPOINT ["dotnet", "test", "Certify.Core.Tests.Unit.dll", "-f", "net9.0"]
10 changes: 5 additions & 5 deletions src/Certify.Tests/Certify.Core.Tests.Unit/linux_compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: certify-core-tests-unit-linux
services:

certify-core-tests-unit-8_0:
image: certify-core-tests-unit-8_0-linux:latest
certify-core-tests-unit-9_0:
image: certify-core-tests-unit-9_0-linux:latest
build:
context: ../../../../
dockerfile: ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/certify-core-tests-unit-8_0-linux.dockerfile
dockerfile: ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/certify-core-tests-unit-9_0-linux.dockerfile
ports:
- 80:80
- 443:443
Expand All @@ -14,8 +14,8 @@ services:
# VSTEST_HOST_DEBUG: 1
volumes:
- step:/mnt/step_share
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'Name=TestCertifyManagerGetAccountDetails'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'Name=TestCertifyManagerGetAccountDetails'"
depends_on:
step-ca:
condition: service_healthy
Expand Down
14 changes: 7 additions & 7 deletions src/Certify.Tests/Certify.Core.Tests.Unit/windows_compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: certify-core-tests-unit-win
services:

certify-core-tests-unit-8_0:
image: certify-core-tests-unit-8_0-win:latest
certify-core-tests-unit-9_0:
image: certify-core-tests-unit-9_0-win:latest
build:
context: ../../../../
dockerfile: ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/certify-core-tests-unit-8_0-win.dockerfile
dockerfile: ./certify/src/Certify.Tests/Certify.Core.Tests.Unit/certify-core-tests-unit-9_0-win.dockerfile
# environment:
# VSTEST_HOST_DEBUG: 1
ports:
- 80:80
- 443:443
- 9696:9696
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net8.0 --filter 'Name=TestCertifyManagerGetAccountDetailsDefinedCertificateAuthorityId'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'ClassName=Certify.Core.Tests.Unit.CertifyManagerAccountTests'"
# entrypoint: "dotnet test Certify.Core.Tests.Unit.dll -f net9.0 --filter 'Name=TestCertifyManagerGetAccountDetailsDefinedCertificateAuthorityId'"
volumes:
- step:C:\step_share
profiles: ["8_0"]
profiles: ["9_0"]
depends_on:
step-ca:
condition: service_healthy
Expand Down Expand Up @@ -47,7 +47,7 @@ services:
context: .
dockerfile: ./step-ca-win.dockerfile
hostname: step-ca
profiles: ["4_6_2", "8_0"]
profiles: ["4_6_2", "9_0"]
ports:
- 9000:9000
environment:
Expand Down

0 comments on commit b834605

Please sign in to comment.