Skip to content

Commit

Permalink
Merge branch 'main' into test/lambda-tooling-update
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr authored Jan 23, 2025
2 parents ee716f2 + a985696 commit 2c1932d
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 37 deletions.
70 changes: 63 additions & 7 deletions .github/workflows/run_linux_container_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ permissions:

jobs:

run-linux-container-tests:
name: Run Linux Container Integration Tests
run-amd64-linux-container-tests:
name: Run amd64 Linux Container Integration Tests
runs-on: ubuntu-latest

env:
Expand All @@ -46,9 +46,6 @@ jobs:
with:
egress-policy: audit

- name: Docker Setup QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand Down Expand Up @@ -82,5 +79,64 @@ jobs:
with:
dotnet-version: '9.0.x'

- name: Build & Run Linux Container Integration Tests
run: dotnet test ./tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerIntegrationTests.csproj --framework net9.0
- name: Build & Run amd64 Linux Container Integration Tests
env:
BUILD_ARCH: amd64
run: dotnet test ./tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerIntegrationTests.csproj --framework net9.0 --filter Architecture=amd64

run-arm64-linux-container-tests:
name: Run arm64 Linux Container Integration Tests
runs-on: ubuntu-24.04-arm

env:
test_results_path: tests\TestResults
integration_tests_shared_project: ${{ github.workspace }}/tests/Agent/IntegrationTests/Shared
NR_DOTNET_TEST_SAVE_WORKING_DIRECTORY: 1
# Make this variable true to enable extra data-gathering and logging to help troubleshoot test failures, at the cost of additional time and resources
enhanced_logging: false


steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0

- name: Download Agent Home Folders (Call)
if: ${{ inputs.external_call }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: homefolders
path: src/Agent

- name: Download Agent Home Folders (Dispatch)
if: ${{ !inputs.external_call }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ inputs.run_id }}
name: homefolders
path: ${{ github.workspace }}/src/Agent
repository: ${{ github.repository }}

- name: Set up secrets
env:
INTEGRATION_TEST_SECRETS: ${{ secrets.TEST_SECRETS }}
run: |
echo $INTEGRATION_TEST_SECRETS | dotnet user-secrets set --project ${{ env.integration_tests_shared_project }}
- name: Install .NET 9
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: '9.0.x'

- name: Build & Run arm64 Linux Container Integration Tests
env:
BUILD_ARCH: arm64
run: dotnet test ./tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerIntegrationTests.csproj --framework net9.0 --filter Architecture=arm64

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ARG DOTNET_VERSION
ARG DISTRO_TAG
ARG TARGET_ARCH
ARG BUILD_ARCH
FROM --platform=${TARGET_ARCH} mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-${DISTRO_TAG} AS base
WORKDIR /app
EXPOSE 80

# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
ARG DOTNET_VERSION
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-${DISTRO_TAG} AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-${DISTRO_TAG} AS build
ARG TARGET_ARCH
WORKDIR /src

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ From a Powershell command prompt in the same folder as this README file:
docker buildx build --build-arg DOTNET_VERSION="8.0" -f Dockerfile.AmazonBaseImage --tag dotnetreg.azurecr.io/amazonlinux-aspnet:8.0 --platform linux/amd64,linux/arm64/v8 --push .
docker buildx build --build-arg DOTNET_VERSION="9.0" -f Dockerfile.AmazonBaseImage --tag dotnetreg.azurecr.io/amazonlinux-aspnet:9.0 --platform linux/amd64,linux/arm64/v8 --push .
docker buildx build --build-arg DOTNET_VERSION="8.0" -f Dockerfile.FedoraBaseImage --tag fedora-aspnet:8.0 --platform linux/amd64,linux/arm64/v8 -push .
docker buildx build --build-arg DOTNET_VERSION="9.0" -f Dockerfile.FedoraBaseImage --tag fedora-aspnet:9.0 --platform linux/amd64,linux/arm64/v8 -push .
docker buildx build --build-arg DOTNET_VERSION="8.0" -f Dockerfile.FedoraBaseImage --tag dotnetreg.azurecr.io/fedora-aspnet:8.0 --platform linux/amd64,linux/arm64/v8 --push .
docker buildx build --build-arg DOTNET_VERSION="9.0" -f Dockerfile.FedoraBaseImage --tag dotnetreg.azurecr.io/fedora-aspnet:9.0 --platform linux/amd64,linux/arm64/v8 --push .
```

4. Disable buildx in Docker Desktop
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARG DISTRO_TAG
ARG BUILD_ARCH
FROM --platform=amd64 mcr.microsoft.com/dotnet/aspnet:9.0-bookworm-slim AS base
WORKDIR /app
EXPOSE 80
Expand All @@ -10,9 +11,8 @@ RUN apt-get update \
&& apt-get update \
&& apt-get install -y aspnetcore-runtime-8.0


# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
RUN apt-get update \
&& apt-get install -y wget \
&& wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARG DISTRO_TAG
ARG BUILD_ARCH
FROM --platform=amd64 mcr.microsoft.com/dotnet/aspnet:9.0-bookworm-slim AS base
WORKDIR /app
EXPOSE 80
Expand All @@ -10,9 +11,8 @@ RUN apt-get update \
&& apt-get update \
&& apt-get install -y aspnetcore-runtime-8.0


# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
RUN apt-get update \
&& apt-get install -y wget \
&& wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ARG DOTNET_VERSION
ARG DISTRO_TAG
ARG TARGET_ARCH
ARG BUILD_ARCH
FROM --platform=${TARGET_ARCH} mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}-${DISTRO_TAG} AS base
WORKDIR /app
EXPOSE 80

# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
ARG DOTNET_VERSION
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-${DISTRO_TAG} AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-${DISTRO_TAG} AS build
ARG TARGET_ARCH
WORKDIR /src
COPY ["SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
ARG DOTNET_VERSION
ARG TARGET_ARCH
ARG BUILD_ARCH
# Uses a custom-built Amazon Linux image with ASP.NET Core pre-installed, served from a private
# container repository under the .NET Team Sandbox Azure subscription
FROM --platform=${TARGET_ARCH} dotnetreg.azurecr.io/amazonlinux-aspnet:${DOTNET_VERSION} AS base
WORKDIR /app
EXPOSE 80

# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
ARG TARGET_ARCH
WORKDIR /src
COPY ["SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ARG DOTNET_VERSION
ARG TARGET_ARCH
ARG BUILD_ARCH
FROM --platform=${TARGET_ARCH} quay.io/centos/centos:stream9 AS base
WORKDIR /app
EXPOSE 80

# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
ARG TARGET_ARCH
WORKDIR /src
COPY ["SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
Expand Down Expand Up @@ -40,4 +41,4 @@ NEW_RELIC_LOG_DIRECTORY=/app/logs
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "SmokeTestApp.dll"]
ENTRYPOINT ["dotnet", "SmokeTestApp.dll"]
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ARG DOTNET_VERSION
ARG TARGET_ARCH
ARG BUILD_ARCH
# Uses a custom-built Fedora image with ASP.NET Core pre-installed, served from a private
# container repository under the .NET Team Sandbox Azure subscription
FROM --platform=${TARGET_ARCH} dotnetreg.azurecr.io/fedora-aspnet:${DOTNET_VERSION} AS base
FROM dotnetreg.azurecr.io/fedora-aspnet:${DOTNET_VERSION} AS base
WORKDIR /app
EXPOSE 80

# build image is always amd64 (to match the runner architecture), even though the target architecture may be arm64
FROM --platform=amd64 mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
# build arch may be different from target arch (i.e., when running locally with QEMU)
FROM --platform=${BUILD_ARCH} mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
ARG TARGET_ARCH
WORKDIR /src
COPY ["SmokeTestApp/SmokeTestApp.csproj", "SmokeTestApp/"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container
# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container
# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 8.0-bookworm-slim, 8.0-alpine, 8.0-jammy
# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64
# TARGET_ARCH the target architecture for the run -- either amd64 or arm64
# BUILD_ARCH the build architecture-- either amd64 or arm64
# PORT external port for the smoketest API
# CONTAINER_NAME The name for the container
# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8
Expand Down Expand Up @@ -54,6 +55,7 @@ services:
args:
DISTRO_TAG: ${DISTRO_TAG}
TARGET_ARCH: ${TARGET_ARCH}
BUILD_ARCH: ${BUILD_ARCH}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container
# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container
# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 8.0-bookworm-slim, 8.0-alpine, 8.0-jammy
# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64
# TARGET_ARCH the target architecture for the run -- either amd64 or arm64
# BUILD_ARCH the build architecture -- either amd64 or arm64
# PORT external port for the smoketest API
# CONTAINER_NAME The name for the container
# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8
Expand Down Expand Up @@ -32,6 +33,7 @@ services:
args:
DISTRO_TAG: ${DISTRO_TAG}
TARGET_ARCH: ${TARGET_ARCH}
BUILD_ARCH: ${BUILD_ARCH}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container
# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container
# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 8.0-bookworm-slim, 8.0-alpine, 8.0-jammy
# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64
# TARGET_ARCH the target architecture for the run -- either amd64 or arm64
# BUILD_ARCH the build architecture -- either amd64 or arm64
# PORT external port for the smoketest API
# CONTAINER_NAME The name for the container
# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8
Expand Down Expand Up @@ -32,6 +33,7 @@ services:
args:
DISTRO_TAG: ${DISTRO_TAG}
TARGET_ARCH: ${TARGET_ARCH}
BUILD_ARCH: ${BUILD_ARCH}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# AGENT_PATH host path to the Agent linux home folder - will map to /usr/local/newrelic-dotnet-agent in the container
# LOG_PATH host path for Agent logfile output - will map to /app/logs in the container
# DISTRO_TAG distro tag for build, not including the architecture suffix - possible values 9.0-bookworm-slim, 9.0-alpine, 9.0-noble
# TARGET_ARCH the target architecture for the build and run -- either amd64 or arm64
# TARGET_ARCH the target architecture for the run -- either amd64 or arm64
# BUILD_ARCH the build architecture -- either amd64 or arm64
# PORT external port for the smoketest API
# CONTAINER_NAME The name for the container
# PLATFORM The platform that the service runs on -- linux/amd64 or linux/arm64/v8
Expand All @@ -30,6 +31,7 @@ services:
args:
DISTRO_TAG: ${DISTRO_TAG}
TARGET_ARCH: ${TARGET_ARCH}
BUILD_ARCH: ${BUILD_ARCH}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_HOST: ${NEW_RELIC_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public override void Start(string commandLineArguments, Dictionary<string, strin
startInfo.EnvironmentVariables.Add("APP_DOTNET_VERSION", _dotnetVersion);
startInfo.EnvironmentVariables.Add("DISTRO_TAG", _distroTag);
startInfo.EnvironmentVariables.Add("TARGET_ARCH", _targetArch);

// Workflow will set BUILD_ARCH if it's a CI build
// otherwise, assume it's a local build and set it to amd64
if (!startInfo.EnvironmentVariables.ContainsKey("BUILD_ARCH"))
startInfo.EnvironmentVariables.Add("BUILD_ARCH", "amd64");

startInfo.EnvironmentVariables.Add("PLATFORM", _containerPlatform);
startInfo.EnvironmentVariables.Add("NEW_RELIC_LICENSE_KEY", testConfiguration.LicenseKey);
startInfo.EnvironmentVariables.Add("NEW_RELIC_HOST", testConfiguration.CollectorUrl);
Expand Down Expand Up @@ -193,10 +199,15 @@ public override void Shutdown(bool force = false)
TestLogger?.WriteLine($"[{AppName}] Sending shutdown signal to {ContainerName} container.");

// stop and remove the container, no need to kill RemoteProcess, as it will die when this command runs
// wait up to 5 seconds for the app to terminate gracefully before forcefully closing it
Process.Start("docker", $"compose -p {ContainerName.ToLower()} down --rmi local --remove-orphans");
// wait up to 20 seconds for the app to terminate gracefully before forcefully closing it
var proc = Process.Start("docker", $"compose -p {ContainerName.ToLower()} down --rmi local --remove-orphans -t 20");

Thread.Sleep(TimeSpan.FromSeconds(5)); // give things a chance to settle before destroying the container
// wait for the process to complete
if (!proc.WaitForExit(30000))
{
Console.WriteLine($"[{AppName} {DateTime.Now}] Timed out waiting for {ContainerName} container to stop.");
TestLogger?.WriteLine($"[{AppName}] Timed out waiting for {ContainerName} container to stop.");
}
}

private void CleanupContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace NewRelic.Agent.ContainerIntegrationTests.Tests.AwsSdk;

[Trait("Architecture", "amd64")]
public class AwsSdkDynamoDBTest : NewRelicIntegrationTest<AwsSdkContainerDynamoDBTestFixture>
{
private readonly AwsSdkContainerDynamoDBTestFixture _fixture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace NewRelic.Agent.ContainerIntegrationTests.Tests.AwsSdk;

[Trait("Architecture", "amd64")]
public class AwsSdkMultiServiceTest : NewRelicIntegrationTest<AwsSdkContainerMultiServiceTestFixture>
{
private readonly AwsSdkContainerMultiServiceTestFixture _fixture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
using NewRelic.Testing.Assertions;
using Xunit;
using Xunit.Abstractions;
using Assert = Xunit.Assert;

namespace NewRelic.Agent.ContainerIntegrationTests.Tests.AwsSdk;

[Trait("Architecture", "amd64")]
public abstract class AwsSdkSQSTestBase : NewRelicIntegrationTest<AwsSdkContainerSQSTestFixture>
{
private readonly AwsSdkContainerSQSTestFixture _fixture;
Expand Down
Loading

0 comments on commit 2c1932d

Please sign in to comment.