From 80d3f90e3880f1dd48b9b380337569fe69b3772c Mon Sep 17 00:00:00 2001 From: Leo Romanovsky Date: Sat, 12 Sep 2026 04:58:39 +0000 Subject: [PATCH] test(dotnet): enable agentless EVP exposure egress --- manifests/dotnet.yml | 15 +++++-- .../test_dotnet_direct_evp_activation.py | 44 +++++++++++++++++++ utils/build/docker/dotnet/weblog/Program.cs | 18 +++++++- utils/build/docker/dotnet/weblog/app.sh | 4 ++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tests/test_the_test/test_dotnet_direct_evp_activation.py diff --git a/manifests/dotnet.yml b/manifests/dotnet.yml index ea58d370235..3b1d3cc6dc6 100644 --- a/manifests/dotnet.yml +++ b/manifests/dotnet.yml @@ -779,9 +779,18 @@ manifest: tests/ffe/test_dynamic_evaluation.py::Test_FFE_Flag_Parse_Error_Isolation: bug (FFL-2184) tests/ffe/test_dynamic_evaluation.py::Test_FFE_Unknown_Operator_Tolerance: bug (FFL-2184) tests/ffe/test_exposure_egress.py: v3.36.0 - tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Direct: missing_feature (Not yet implemented) - tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Direct_Shutdown: missing_feature (Not yet implemented) - tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Sidecar: missing_feature (Not yet implemented) + tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Direct: + - weblog_declaration: + "*": irrelevant + poc: v3.54.0 + tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Direct_Shutdown: + - weblog_declaration: + "*": irrelevant + poc: v3.54.0 + tests/ffe/test_exposure_egress.py::Test_FFE_Exposure_Egress_Agentless_Sidecar: + - weblog_declaration: + "*": irrelevant + poc: v3.54.0 tests/ffe/test_exposures_datadog_agent.py: v3.36.0 tests/ffe/test_exposures_datadog_agent.py::Test_FFE_Exposure_Caching_Serial_Id_Appears: missing_feature (EX-3416) tests/ffe/test_exposures_datadog_agent.py::Test_FFE_Exposure_Caching_Serial_Id_Cycle: missing_feature (EX-3416) diff --git a/tests/test_the_test/test_dotnet_direct_evp_activation.py b/tests/test_the_test/test_dotnet_direct_evp_activation.py new file mode 100644 index 00000000000..183337b1782 --- /dev/null +++ b/tests/test_the_test/test_dotnet_direct_evp_activation.py @@ -0,0 +1,44 @@ +"""Guard the .NET-only activation and lifecycle for direct-EVP validation.""" + +from pathlib import Path + +from utils import features, scenarios + + +@scenarios.test_the_test +@features.not_reported +def test_dotnet_direct_evp_activation_is_exposure_only_and_poc_scoped() -> None: + manifest = Path("manifests/dotnet.yml").read_text(encoding="utf-8") + + for test_class in ( + "Test_FFE_Exposure_Egress_Agentless_Direct", + "Test_FFE_Exposure_Egress_Agentless_Direct_Shutdown", + "Test_FFE_Exposure_Egress_Agentless_Sidecar", + ): + declaration = ( + f"tests/ffe/test_exposure_egress.py::{test_class}:\n" + ' - weblog_declaration:\n "*": irrelevant\n poc: v3.54.0' + ) + assert declaration in manifest + + assert "tests/ffe/test_flag_eval_evp.py: missing_feature (FFL-2446)" in manifest + + +@scenarios.test_the_test +@features.not_reported +def test_dotnet_direct_evp_shutdown_execs_runtime_and_marks_server_closed() -> None: + app_script = Path("utils/build/docker/dotnet/weblog/app.sh").read_text(encoding="utf-8") + program = Path("utils/build/docker/dotnet/weblog/Program.cs").read_text(encoding="utf-8") + + shutdown_switch = 'SYSTEM_TESTS_FFE_SHUTDOWN_FLUSH_ENABLED:-}" = "true"' + assert shutdown_switch in app_script + assert "exec dotnet app.dll" in app_script + assert app_script.index(shutdown_switch) < app_script.index("exec dotnet app.dll") + assert app_script.index("exec dotnet app.dll") < app_script.index("if ( ! dotnet app.dll)") + + assert 'GetEnvironmentVariable("SYSTEM_TESTS_FFE_SHUTDOWN_FLUSH_ENABLED") == "true"' in program + assert "GetRequiredService().ApplicationStopped.Register" in program + assert 'event = "system_tests.ffe.shutdown.server_closed"' in program + assert 'timestamp = DateTimeOffset.UtcNow.ToString("O")' in program + assert "Console.Out.Flush();" in program + assert program.index("ApplicationStopped.Register") < program.index("host.Run();") diff --git a/utils/build/docker/dotnet/weblog/Program.cs b/utils/build/docker/dotnet/weblog/Program.cs index 684ffb681ab..d773b53cd1a 100644 --- a/utils/build/docker/dotnet/weblog/Program.cs +++ b/utils/build/docker/dotnet/weblog/Program.cs @@ -1,6 +1,8 @@ using System; +using System.Text.Json; using System.Threading; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Http; using Datadog.Trace; @@ -37,7 +39,21 @@ public static void Main(string[] args) settings.LogsInjectionEnabled = true; Tracer.Configure(settings); } - CreateHostBuilder(args).Build().Run(); + var host = CreateHostBuilder(args).Build(); + if (Environment.GetEnvironmentVariable("SYSTEM_TESTS_FFE_SHUTDOWN_FLUSH_ENABLED") == "true") + { + host.Services.GetRequiredService().ApplicationStopped.Register(() => + { + Console.WriteLine(JsonSerializer.Serialize(new + { + @event = "system_tests.ffe.shutdown.server_closed", + timestamp = DateTimeOffset.UtcNow.ToString("O") + })); + Console.Out.Flush(); + }); + } + + host.Run(); } public static IHostBuilder CreateHostBuilder(string[] args) { diff --git a/utils/build/docker/dotnet/weblog/app.sh b/utils/build/docker/dotnet/weblog/app.sh index e1e317f764b..182fac2b980 100755 --- a/utils/build/docker/dotnet/weblog/app.sh +++ b/utils/build/docker/dotnet/weblog/app.sh @@ -8,6 +8,10 @@ if [ "${UDS_WEBLOG:-0}" = "1" ]; then ./set-uds-transport.sh fi +if [ "${SYSTEM_TESTS_FFE_SHUTDOWN_FLUSH_ENABLED:-}" = "true" ]; then + exec dotnet app.dll +fi + if ( ! dotnet app.dll); then echo recovering dump to /var/log/system-tests/dumps mkdir -p /var/log/system-tests/dumps