From 27bd6a4ff26eb90b832a2d9d7183efb7c51abe00 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Tue, 29 Oct 2024 15:43:08 -0700 Subject: [PATCH 01/91] test - wip --- .github/workflows/cicd.yml | 556 ---------------------------- .github/workflows/reusable-test.yml | 4 +- 2 files changed, 3 insertions(+), 557 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 3caca0d7dd..ce371e7dfb 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -91,110 +91,6 @@ jobs: build_nuget: true configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - # Run the unit tests in GitHub. - unit_tests_appverif: - # Always run this job. - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: unit_tests - pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe - # Exclude [processes] test that CodeCoverage can't work with. - test_command: .\unit_tests.exe -d yes ~[processes] - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: true - gather_dumps: true - capture_etw: true - leak_detection: true - - # Run the unit tests in GitHub. - unit_tests: - # Always run this job. - needs: regular - if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' - uses: ./.github/workflows/reusable-test.yml - with: - name: unit_tests - pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe - # Exclude [processes] test that CodeCoverage can't work with. - test_command: .\unit_tests.exe -d yes ~[processes] - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: true - gather_dumps: true - capture_etw: true - leak_detection: true - - # Run the unit tests for NativeOnly build in GitHub. - unit_tests_native_only: - # Always run this job. - needs: regular_native-only - uses: ./.github/workflows/reusable-test.yml - with: - name: unit_tests - pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe - # Exclude [processes] test that CodeCoverage can't work with. - test_command: .\unit_tests.exe -d yes ~[processes] - build_artifact: Build-x64-native-only - environment: windows-2022 - code_coverage: true - gather_dumps: true - capture_etw: true - leak_detection: true - configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - - # Run the netebpfext unit tests in GitHub. - netebpf_ext_unit_tests: - # Always run this job. - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: netebpf_ext_unit_tests - pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe - test_command: .\netebpfext_unit.exe -d yes - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: true - gather_dumps: true - capture_etw: true - leak_detection: true - - # Run the bpf2c tests in GitHub. - bpf2c: - # Always run this job. - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - test_command: .\bpf2c_tests.exe -d yes - name: bpf2c - build_artifact: Build-x64 - environment: windows-2022 - vs_dev: true - code_coverage: true - gather_dumps: true - capture_etw: true - - # Run the bpf2c conformance tests in GitHub. - bpf2c_conformance: - # Always run this job. - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.6/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe - test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --exclude_regex local --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include" - name: bpf2c_conformance - build_artifact: Build-x64 - environment: windows-2022 - vs_dev: true - code_coverage: true - gather_dumps: true - capture_etw: true - # Run the driver tests on self-hosted runners. driver_ws2019: # Always run this job. @@ -213,455 +109,3 @@ jobs: gather_dumps: false # driver tests manually gather code coverage code_coverage: false - - # Run the driver tests on self-hosted runners. - driver_ws2022: - # Always run this job. - # Only run this on repos that have self-host runners. - needs: regular - if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - name: driver_ws2022 - build_artifact: Build-x64 - environment: ebpf_cicd_tests_ws2022 - # driver test copies dumps to testlog folder. - gather_dumps: false - # driver tests manually gather code coverage - code_coverage: false - - # Run the native-only driver tests on self-hosted runners. - driver_native_only_ws2019: - # Always run this job. - # Only run this on repos that have self-host runners. - needs: regular_native-only - if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - name: driver_native_only_ws2019 - build_artifact: Build-x64-native-only - environment: ebpf_cicd_tests_ws2019 - # driver test copies dumps to testlog folder. - gather_dumps: false - # driver tests manually gather code coverage - code_coverage: false - configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - - driver_native_only_ws2022: - # Always run this job. - # Only run this on repos that have self-host runners. - needs: regular_native-only - if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - name: driver_native_only_ws2022 - build_artifact: Build-x64-native-only - environment: ebpf_cicd_tests_ws2022 - # driver test copies dumps to testlog folder. - gather_dumps: false - # driver tests manually gather code coverage - code_coverage: false - configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - - # Run the regression driver tests on self-hosted runners (only for 2022). - regression_driver_ws2022: - # Always run this job. - # Only run this on repos that have self-host runners. - needs: regular - if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" -TestMode "Regression" -RegressionArtifactsVersion "0.17.0" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Regression" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - name: regression_driver_ws2022 - build_artifact: Build-x64 - environment: ebpf_cicd_tests_ws2022 - # driver test copies dumps to testlog folder. - gather_dumps: false - # driver tests manually gather code coverage - code_coverage: false - - ossar: - # Always run this job. - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/ossar-scan.yml - with: - build_artifact: Build-x64 - - # Additional jobs to run on pull and schedule only (skip push). - # --------------------------------------------------------------------------- - # Build with C++ static analyzer. - analyze: - # Only run on schedule and pull request. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64-Analyze - # Analysis on external projects is conditional, as on small CI/CD VMs the compiler can run OOM - build_options: /p:Analysis='True' /p:AnalysisOnExternal='False' - - # Build with C++ address sanitizer. - sanitize: - # Only run on schedule and pull request. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64-Sanitize - build_options: /p:AddressSanitizer='True' - - bpf2c_fuzzer: - needs: regular - if: github.event_name == 'pull_request' || github.event_name == 'merge_group' - uses: ./.github/workflows/reusable-test.yml - with: - name: bpf2c_fuzzer - test_command: .\bpf2c_fuzzer.exe bpf2c_fuzzer_corpus -use_value_profile=1 -max_total_time=300 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - bpf2c_fuzzer_scheduled: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: bpf2c_fuzzer - test_command: .\bpf2c_fuzzer.exe bpf2c_fuzzer_corpus -use_value_profile=1 -max_total_time=900 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - execution_context_fuzzer: - needs: regular - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: execution_context_fuzzer - test_command: .\execution_context_fuzzer.exe execution_context_fuzzer_corpus -use_value_profile=1 -runs=3000 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - # Run the verifier fuzzer. - verifier_fuzzer: - needs: regular - # Always run this job. - if: github.event_name == 'pull_request' || github.event_name == 'merge_group' - uses: ./.github/workflows/reusable-test.yml - with: - name: verifier_fuzzer - test_command: .\verifier_fuzzer.exe verifier_corpus -use_value_profile=1 -max_total_time=300 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - verifier_fuzzer_scheduled: - needs: regular - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: verifier_fuzzer - test_command: .\verifier_fuzzer.exe verifier_corpus -use_value_profile=1 -max_total_time=900 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - core_helper_fuzzer: - needs: regular - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: core_helper_fuzzer - test_command: .\core_helper_fuzzer core_helper_corpus -max_len=139 -runs=1000 -use_value_profile=1 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - netebpfext_fuzzer: - needs: regular - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: netebpfext_fuzzer - test_command: .\netebpfext_fuzzer netebpfext_corpus -max_len=12 -runs=1000 -use_value_profile=1 -artifact_prefix=Artifacts\ - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - configurations: '["FuzzerDebug"]' - - # Run Cilium regression tests in GitHub. - cilium_tests: - needs: regular - # Only run on schedule and pull request. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: cilium_tests - test_command: .\cilium_tests.exe -d yes - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - - # Run the quick stress tests in GitHub. - stress: - needs: regular - # Only run on schedule and pull request. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: stress - # Until there is a dedicated stress test, re-use the perf test. - test_command: .\ebpf_performance.exe -d yes - build_artifact: Build-x64 - environment: windows-2022 - # No code coverage on stress. - code_coverage: false - gather_dumps: true - - # Run the unit tests in GitHub with address sanitizer. - sanitize_unit_tests: - needs: sanitize - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: unit_tests - # Exclude [processes] test that ASAN can't work with. - test_command: .\unit_tests.exe -d yes ~[processes] - build_artifact: Build-x64-Sanitize - environment: windows-2022 - code_coverage: false - gather_dumps: true - capture_etw: true - - # Run the fault injection simulator in GitHub. - fault_injection: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: fault_injection - test_command: .\unit_tests.exe - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: true - gather_dumps: true - fault_injection: true - leak_detection: true - - # Run the low memory simulator for netebpfext_unit tests. - fault_injection_netebpfext_unit: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: netebpfext_fault_injection - test_command: .\netebpfext_unit.exe - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: true - gather_dumps: true - fault_injection: true - leak_detection: true - - # Run a fast multi-threaded stress test pass against the usersim user-mode 'mock' framework. - # Added as a 'per-PR' test to catch usersim regressions and/or run-time usage issues. - quick_user_mode_multi_threaded_stress_test: - needs: regular - if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' - uses: ./.github/workflows/reusable-test.yml - with: - name: quick_user_mode_multi_threaded_stress - test_command: .\ebpf_stress_tests_um -tt=8 -td=2 - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - leak_detection: false - gather_dumps: true - capture_etw: true - - # Additional jobs to run on a schedule only (skip push and pull request). - # --------------------------------------------------------------------------- - codeql: - # Only run during daily scheduled run - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64-CodeQl - build_codeql: true - - - # Run the complete fault injection simulator in GitHub. - # Runs on a schedule as this takes a long time to run. - fault_injection_full: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: fault_injection_full - test_command: .\unit_tests.exe - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - fault_injection: true - leak_detection: true - - # Run the complete fault injection simulator for netebpfext in GitHub. - # Runs on a schedule as this takes a long time to run. - netebpfext_fault_injection_full: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: netebpfext_fault_injection_full - test_command: .\netebpfext_unit.exe - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - gather_dumps: true - fault_injection: true - - # Run multi-threaded stress tests against the user mode 'mock' framework. - user_mode_multi_threaded_stress_test: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: user_mode_multi_threaded_stress - test_command: .\ebpf_stress_tests_um -tt=8 -td=10 - build_artifact: Build-x64 - environment: windows-2022 - code_coverage: false - leak_detection: false - gather_dumps: true - capture_etw: true - - # Run multi-threaded stress tests with 'restart extension' disabled (default behavior) - # against the kernel mode eBPF sub-system. - km_mt_stress_tests: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: km_mt_stress_tests - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "memory" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - build_artifact: Build-x64 - environment: ebpf_cicd_tests_ws2019 - code_coverage: false - # For this test, we only want kernel mode dumps and not user mode dumps. - gather_dumps: false - - # Run multi-threaded stress tests with 'restart extension' enabled - # against the kernel mode eBPF sub-system. - km_mt_stress_tests_restart_extension: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: km_mt_stress_tests_restart_extension - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "memory" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" -Options @("RestartExtension") - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - build_artifact: Build-x64 - environment: ebpf_cicd_tests_ws2019 - code_coverage: false - # For this test, we only want kernel mode dumps and not user mode dumps. - gather_dumps: false - - performance: - needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-test.yml - with: - name: km_performance - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Performance" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - build_artifact: Build-x64 - environment: ebpf_cicd_perf_ws2022 - configurations: '["Release"]' - - netperf: - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/netperf.yml - with: - sha: ${{ github.sha }} - ref: ${{ github.ref }} - pull_request: ${{ github.event.pull_request.number }} - secrets: - NET_PERF_TRIGGER: ${{ secrets.NET_PERF_TRIGGER }} - - upload_perf_results: - needs: performance - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/upload-perf-results.yml - with: - name: upload_perf_results - result_artifact: km_performance-x64-Release - secrets: - AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - upload_netperf_results_azure_2022: - needs: netperf - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/upload-perf-results.yml - with: - name: upload_netperf_results_azure_2022 - result_artifact: netperf_azure_2022_x64 - platform: Azure Windows 2022 - secrets: - AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - upload_netperf_results_lab_2022: - needs: netperf - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/upload-perf-results.yml - with: - name: upload_netperf_results_lab_2022 - result_artifact: netperf_lab_2022_x64 - platform: Lab Windows 2022 - secrets: - AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index e8e70080bd..aa17bbb72c 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -69,7 +69,9 @@ jobs: strategy: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{inputs.environment}} + runs-on: + - self-hosted + - "1ES.Pool=ebpf-cicd-runner-pool-server-2019" env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From 1c3de49402019bb90a936fb3a3a4184316e2d1f1 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Tue, 29 Oct 2024 15:47:18 -0700 Subject: [PATCH 02/91] TEST --- .github/workflows/reusable-test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index aa17bbb72c..5e938a224f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -233,6 +233,16 @@ jobs: .\export_program_info_sample.exe --clear .\export_program_info_sample.exe + - name: 1ES TEST + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + id: run_pre_test_command + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + hostname + whoami + powershell.exe Get-VM + dir /s + - name: Run pre test command if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') id: run_pre_test_command From f364af06bc03fced4028cf98eb8fc2a4e0a7b75b Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Tue, 29 Oct 2024 15:52:29 -0700 Subject: [PATCH 03/91] update --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 5e938a224f..f2aed9a228 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -235,7 +235,7 @@ jobs: - name: 1ES TEST if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: run_pre_test_command + id: 1es_test working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | hostname From 4f025006807b960f44e9f5a774c4a3afae0e1dfb Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Tue, 29 Oct 2024 15:54:35 -0700 Subject: [PATCH 04/91] fix --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index f2aed9a228..be3cb164a9 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -235,7 +235,7 @@ jobs: - name: 1ES TEST if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: 1es_test + id: test_1es working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | hostname From 4f3dbee0d4650553d927ac9f8df1ac590ee3add1 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Wed, 30 Oct 2024 09:39:12 -0700 Subject: [PATCH 05/91] more removal for now --- .github/workflows/cicd.yml | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ce371e7dfb..1926a3aa55 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -55,41 +55,7 @@ jobs: build_msi: true build_nuget: true build_options: /p:ReleaseJIT='True' - configurations: '["Debug", "FuzzerDebug", "Release"]' - - - onebranch: - strategy: - matrix: - Architecture: ['x64', 'ARM64'] - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-${{ matrix.Architecture }}-onebranch - generate_release_package: true - build_msi: true - build_nuget: true - configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - build_options: /p:BuildOneBranch='True' /t:tools\onebranch /t:installer\ebpf-for-windows - solution_file: "ebpf-for-windows.sln" - architecture: ${{ matrix.Architecture }} - download_demo_repository: false - - # Perform the native-only build. - regular_native-only: - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64-native-only - build_msi: true - build_nuget: true - configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + configurations: '["Release"]' # Run the driver tests on self-hosted runners. driver_ws2019: From ed51912b1033bc56a12800eaf90ef3773ef316ce Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Wed, 30 Oct 2024 12:38:57 -0700 Subject: [PATCH 06/91] WIP --- .github/workflows/cicd.yml | 30 +- .github/workflows/reusable-test.yml | 899 ++++++++++++++-------------- 2 files changed, 470 insertions(+), 459 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 1926a3aa55..1d172e2823 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -42,26 +42,26 @@ jobs: # Jobs to run on pull, push, and schedule. # --------------------------------------------------------------------------- - # Perform the regular build. - regular: - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64 - generate_release_package: true - build_msi: true - build_nuget: true - build_options: /p:ReleaseJIT='True' - configurations: '["Release"]' + # # Perform the regular build. + # regular: + # # Always run this job. + # if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + # uses: ./.github/workflows/reusable-build.yml + # with: + # ref: ${{ github.ref }} + # repository: ${{ github.repository }} + # build_artifact: Build-x64 + # generate_release_package: true + # build_msi: true + # build_nuget: true + # build_options: /p:ReleaseJIT='True' + # configurations: '["Release"]' # Run the driver tests on self-hosted runners. driver_ws2019: # Always run this job. # Only run this on repos that have self-host runners. - needs: regular + # needs: regular if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') uses: ./.github/workflows/reusable-test.yml with: diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index be3cb164a9..0a66a428b5 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -91,448 +91,459 @@ jobs: with: egress-policy: audit - - name: Print CPU information - run: - Get-WmiObject -Class Win32_Processor | Select-Object -Property Name, NumberOfCores, NumberOfLogicalProcessors - - - id: skip_check - uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 - with: - cancel_others: 'false' - paths_ignore: '["**.md", "**/docs/**"]' - - # Checking out the branch is needed to gather correct code coverage data. - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - # Only check out source code if code coverage is being gathered. - if: (inputs.code_coverage == true) && (steps.skip_check.outputs.should_skip != 'true') - with: - submodules: 'recursive' - ref: ${{ github.event.workflow_run.head_branch }} - - # Perform shallow checkout for self-hosted runner. - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - with: - ref: ${{ github.event.workflow_run.head_branch }} - - # Check if .github/workflows/reusable-test.yml exists locally. - - name: Check for .github/workflows/reusable-test.yml - # Check for test logs even if the workflow failed. - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - id: check_reusable_test_locally - with: - files: .github/workflows/reusable-test.yml - - # Check out just this file if code hasn't been checked out yet. - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - if: (steps.check_reusable_test_locally.outputs.files_exists != 'true') && (steps.skip_check.outputs.should_skip != 'true') - with: - sparse-checkout: | - .github/workflows/reusable-test.yml - sparse-checkout-cone-mode: false - - - name: Set up choco cache folder - # Set the choco cache to a local folder so that it can be cached. - if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - id: choco-cache - run: | - mkdir ${{github.workspace}}\choco_cache - choco config set --name cacheLocation --value ${{github.workspace}}\choco_cache - - - name: Cache choco packages - # Add cache entry for any choco packages that are installed. - # The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated. - if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 - env: - cache-name: cache-choco-packages - with: - path: ${{github.workspace}}\choco_cache - key: ${{ hashFiles('.github/workflows/reusable-test.yml') }} - - - name: Install ProcDump - id: install_procdump - if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - run: | - choco install -y procdump - where procdump.exe - - - name: Set up OpenCppCoverage and add to PATH - id: set_up_opencppcoverage - if: (inputs.code_coverage == true) && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - run: | - choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage - echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - where OpenCppCoverage.exe - - - name: Configure Windows Error Reporting to make a local copy of any crashes that occur. - id: configure_windows_error_reporting - if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - run: | - mkdir ${{env.DUMP_PATH}} - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue - $dump_path = "${{env.DUMP_PATH}}".Replace("/", "\") - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - - - name: Remove existing artifacts - if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - run: | - Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue - - - name: Download build artifact - if: (steps.skip_check.outputs.should_skip != 'true') && success() - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 - id: download_artifact - with: - name: ${{inputs.build_artifact}}-${{matrix.configurations}} - path: ${{github.workspace}} - - - name: Extract build artifact - if: steps.skip_check.outputs.should_skip != 'true' - working-directory: ${{github.workspace}} - run: | - mkdir ${{env.BUILD_PLATFORM}} - Expand-Archive .\build-${{ matrix.configurations }}.zip -DestinationPath .\${{env.BUILD_PLATFORM}} - - - name: Create generated artifact folder - if: (steps.skip_check.outputs.should_skip != 'true') - run: | - mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts - - - name: Start ETW tracing - id: start_etw_tracing - if: (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - shell: cmd - run: | - mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs - wpr.exe -start ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\ebpfforwindows.wprp -filemode - - - name: Set ASAN Environment Variable - if: steps.skip_check.outputs.should_skip != 'true' - id: set_asan_env_var - shell: cmd - run: | - powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" - powershell.exe "echo 'ASAN_OPTIONS=allocator_may_return_null=1' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" - - - name: Configure eBPF store - if: steps.skip_check.outputs.should_skip != 'true' - id: configure_ebpf_store - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - .\export_program_info.exe --clear - .\export_program_info.exe - - - name: Configure eBPF store (undocked) - if: (steps.skip_check.outputs.should_skip != 'true') && (matrix.configurations != 'FuzzerDebug') - id: configure_ebpf_store_undocked - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - .\export_program_info_sample.exe --clear - .\export_program_info_sample.exe - - - name: 1ES TEST - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: test_1es - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - hostname - whoami - powershell.exe Get-VM - dir /s - - - name: Run pre test command - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: run_pre_test_command - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - ${{env.PRE_COMMAND}} - - - name: Run pre test command on self-hosted runner - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') - id: run_pre_test_command_self_hosted - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - ${{env.PRE_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} -RegressionArtifactsConfiguration ${{env.BUILD_CONFIGURATION}} - - # TODO: Clean up the combination of options: https://github.com/microsoft/ebpf-for-windows/issues/1590 - - name: Run test with Code Coverage in VS Dev environment - if: (inputs.code_coverage == true) && (inputs.vs_dev == true) && (steps.skip_check.outputs.should_skip != 'true') - id: run_test_with_code_coverage_in_vs_dev - shell: cmd - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" - set EBPF_ENABLE_WER_REPORT=yes - OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\${{env.TEST_COMMAND}} - - - name: Run test with Code Coverage and low resource simulation - if: (inputs.code_coverage == true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') - id: run_test_with_code_coverage_in_fault_injection - shell: cmd - run: | - set EBPF_ENABLE_WER_REPORT=yes - OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 8 - - - name: Run test with low resource simulation - if: (inputs.code_coverage != true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') - id: run_test_with_fault_injection - shell: cmd - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - set EBPF_ENABLE_WER_REPORT=yes - powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 16 - - - name: Run test with Code Coverage - if: (inputs.code_coverage == true) && (inputs.vs_dev != true) && (inputs.fault_injection != true) && (steps.skip_check.outputs.should_skip != 'true') - id: run_test_with_code_coverage - shell: cmd - run: | - set EBPF_ENABLE_WER_REPORT=yes - OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - - - name: Run test on self-hosted runner - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) - id: run_test_self_hosted - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + - name: maige_test + id: maige-test run: | - ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - - - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) - id: run_test_without_code_coverage - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - shell: cmd - run: | - cd /d ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} - powershell.exe .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - - - name: Run post test command - # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: run_post_test_command - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - ${{env.POST_COMMAND}} - - - name: Run post test command on self-hosted runner - # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') - id: run_post_test_command_self_hosted - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - ${{env.POST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - - - name: Check for CodeCoverage - if: steps.skip_check.outputs.should_skip != 'true' - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - id: check_coverage - with: - files: ebpf_for_windows.xml - - - name: Upload Report to Codecov attempt 1 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_coverage.outputs.files_exists == 'true') - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - id: upload_code_coverage_report_1 - continue-on-error: true - with: - files: ebpf_for_windows.xml - fail_ci_if_error: true - functionalities: fix - root_dir: ${{github.workspace}} - - - name: Wait on failure 1 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') - run: Start-Sleep -Seconds 30 - - - name: Upload Report to Codecov attempt 2 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - id: upload_code_coverage_report_2 - continue-on-error: true - with: - files: ebpf_for_windows.xml - fail_ci_if_error: true - functionalities: fix - root_dir: ${{github.workspace}} - - - name: Wait on failure 2 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') - run: Start-Sleep -Seconds 60 - - - name: Upload Report to Codecov attempt 3 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - id: upload_code_coverage_report_3 - continue-on-error: true - with: - files: ebpf_for_windows.xml - fail_ci_if_error: true - functionalities: fix - root_dir: ${{github.workspace}} - - - name: Wait on failure 3 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') - run: Start-Sleep -Seconds 120 - - - name: Upload Report to Codecov attempt 4 - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - id: upload_code_coverage_report_4 - continue-on-error: true - with: - files: ebpf_for_windows.xml - fail_ci_if_error: true - functionalities: fix - root_dir: ${{github.workspace}} - - - name: Fail if code coverage upload fails - if: (steps.skip_check.outputs.should_skip != 'true') - run: | - if ($${{ steps.test.upload_code_coverage_report_1!='failure' }}) { exit 0 } - if ($${{ steps.test.upload_code_coverage_report_2!='failure' }}) { exit 0 } - if ($${{ steps.test.upload_code_coverage_report_3!='failure' }}) { exit 0 } - if ($${{ steps.test.upload_code_coverage_report_4!='failure' }}) { exit 0 } - exit 1 - - - name: Stop ETW tracing - id: stop_etw_tracing - if: always() && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - shell: cmd - run: | - wpr.exe -stop ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs\ebpfforwindows.etl - - - name: Copy any bpf2c test logs to TestLogs - if: (inputs.name == 'bpf2c') && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - shell: cmd - run: | - copy ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\*.log ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs - - - name: Check for crash dumps - # Check for crash dumps even if the workflow failed. - if: always() && (steps.skip_check.outputs.should_skip != 'true') - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - id: check_dumps - with: - files: ${{env.DUMP_PATH}}/*.dmp - - - name: Upload any crash dumps - # Upload crash dumps even if the workflow failed. - if: always() && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') && (inputs.gather_dumps == true) - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - id: upload_crash_dumps - with: - name: Crash-Dumps-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - path: ${{env.DUMP_PATH}} - retention-days: 10 - - - name: Check for TestLogs - # Check for test logs even if the workflow failed. - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - if: always() && (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') - id: check_logs - with: - files: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs/* - - - name: Upload log files - # Upload test logs even if the workflow failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_logs.outputs.files_exists == 'true') - id: upload_logs - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - continue-on-error: true - with: - name: Test-Logs-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - path: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs - retention-days: 10 - - - name: Check for generated artifacts - # Check for artifacts even if the workflow failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - id: check_artifacts - with: - files: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts\* - - - name: Upload generated artifacts - # Upload artifacts even if the workflow failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_artifacts.outputs.files_exists == 'true') - id: upload_artifacts - continue-on-error: true - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - with: - name: Artifacts-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts - retention-days: 10 - - - name: Mark run as failed if crash dumps are found - if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') - run: exit 1 - - create_or_update_issue: - needs: run_test - if: ${{ failure() }} - runs-on: ubuntu-latest - steps: - - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 - with: - disable-sudo: true - egress-policy: block - allowed-endpoints: > - api.github.com:443 - - - id: skip_check - uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 - with: - cancel_others: 'false' - paths_ignore: '["**.md", "**/docs/**"]' - - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - if: (github.event_name == 'schedule') || (github.event_name == 'push') && (steps.skip_check.outputs.should_skip != 'true') - env: - TITLE: Workflow failed - ${{inputs.name}} - BODY: | - [Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - [Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }}) - Test name - `${{ inputs.name }}` - LABELS: bug,ci/cd - - with: - script: | - const owner = process.env.GITHUB_REPOSITORY.split('/')[0] - const repo = process.env.GITHUB_REPOSITORY.split('/')[1] - const body = process.env.BODY; - const title = process.env.TITLE; - const labels = process.env.LABELS; - const label_array = labels ? labels.split(',') : []; - console.log(label_array); - // Get all issues that have these labels. - const opts = github.rest.issues.listForRepo.endpoint.merge({ - ...context.issue, - state: 'open', - labels: label_array, - }); - const issues = await github.paginate(opts); - // Look for an existing issue with the same title. - for (const issue of issues) { - if (issue.title === title) { - console.log(`Updating issue ${title}`); - await github.rest.issues.createComment({ - issue_number: issue.number, - owner, - repo, - body, - }); - return; - } - } - // Existing issue not found, create a new one. - console.log(`Creating issue ${title}`); - await github.rest.issues.create({ - owner: owner, - repo: repo, - title: title, - body: body, - labels: label_array, - }); + powershell.exe "Get-NetAdapter" + powershell.exe "Get-VMSwitch" + powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup.ps1" + powershell.exe "Get-NetAdapter" + powershell.exe "Get-VMSwitch" + powershell.exe "Get-VM" + + # - name: Print CPU information + # run: + # Get-WmiObject -Class Win32_Processor | Select-Object -Property Name, NumberOfCores, NumberOfLogicalProcessors + + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 + # with: + # cancel_others: 'false' + # paths_ignore: '["**.md", "**/docs/**"]' + + # # Checking out the branch is needed to gather correct code coverage data. + # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + # # Only check out source code if code coverage is being gathered. + # if: (inputs.code_coverage == true) && (steps.skip_check.outputs.should_skip != 'true') + # with: + # submodules: 'recursive' + # ref: ${{ github.event.workflow_run.head_branch }} + + # # Perform shallow checkout for self-hosted runner. + # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + # if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + # with: + # ref: ${{ github.event.workflow_run.head_branch }} + + # # Check if .github/workflows/reusable-test.yml exists locally. + # - name: Check for .github/workflows/reusable-test.yml + # # Check for test logs even if the workflow failed. + # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + # id: check_reusable_test_locally + # with: + # files: .github/workflows/reusable-test.yml + + # # Check out just this file if code hasn't been checked out yet. + # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + # if: (steps.check_reusable_test_locally.outputs.files_exists != 'true') && (steps.skip_check.outputs.should_skip != 'true') + # with: + # sparse-checkout: | + # .github/workflows/reusable-test.yml + # sparse-checkout-cone-mode: false + + + # - name: Set up choco cache folder + # # Set the choco cache to a local folder so that it can be cached. + # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + # id: choco-cache + # run: | + # mkdir ${{github.workspace}}\choco_cache + # choco config set --name cacheLocation --value ${{github.workspace}}\choco_cache + + # - name: Cache choco packages + # # Add cache entry for any choco packages that are installed. + # # The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated. + # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + # uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 + # env: + # cache-name: cache-choco-packages + # with: + # path: ${{github.workspace}}\choco_cache + # key: ${{ hashFiles('.github/workflows/reusable-test.yml') }} + + # - name: Install ProcDump + # id: install_procdump + # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + # run: | + # choco install -y procdump + # where procdump.exe + + # - name: Set up OpenCppCoverage and add to PATH + # id: set_up_opencppcoverage + # if: (inputs.code_coverage == true) && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + # run: | + # choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage + # echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + # where OpenCppCoverage.exe + + # - name: Configure Windows Error Reporting to make a local copy of any crashes that occur. + # id: configure_windows_error_reporting + # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + # run: | + # mkdir ${{env.DUMP_PATH}} + # New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue + # New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue + # $dump_path = "${{env.DUMP_PATH}}".Replace("/", "\") + # New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue + + # - name: Remove existing artifacts + # if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + # run: | + # Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue + + # - name: Download build artifact + # if: (steps.skip_check.outputs.should_skip != 'true') && success() + # uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 + # id: download_artifact + # with: + # name: ${{inputs.build_artifact}}-${{matrix.configurations}} + # path: ${{github.workspace}} + + # - name: Extract build artifact + # if: steps.skip_check.outputs.should_skip != 'true' + # working-directory: ${{github.workspace}} + # run: | + # mkdir ${{env.BUILD_PLATFORM}} + # Expand-Archive .\build-${{ matrix.configurations }}.zip -DestinationPath .\${{env.BUILD_PLATFORM}} + + # - name: Create generated artifact folder + # if: (steps.skip_check.outputs.should_skip != 'true') + # run: | + # mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts + + # - name: Start ETW tracing + # id: start_etw_tracing + # if: (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + # shell: cmd + # run: | + # mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs + # wpr.exe -start ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\ebpfforwindows.wprp -filemode + + # - name: Set ASAN Environment Variable + # if: steps.skip_check.outputs.should_skip != 'true' + # id: set_asan_env_var + # shell: cmd + # run: | + # powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" + # powershell.exe "echo 'ASAN_OPTIONS=allocator_may_return_null=1' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" + + # - name: Configure eBPF store + # if: steps.skip_check.outputs.should_skip != 'true' + # id: configure_ebpf_store + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # .\export_program_info.exe --clear + # .\export_program_info.exe + + # - name: Configure eBPF store (undocked) + # if: (steps.skip_check.outputs.should_skip != 'true') && (matrix.configurations != 'FuzzerDebug') + # id: configure_ebpf_store_undocked + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # .\export_program_info_sample.exe --clear + # .\export_program_info_sample.exe + + # - name: 1ES TEST + # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + # id: test_1es + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # hostname + # whoami + # powershell.exe Get-VM + # dir /s + + # - name: Run pre test command + # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + # id: run_pre_test_command + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # ${{env.PRE_COMMAND}} + + # - name: Run pre test command on self-hosted runner + # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + # id: run_pre_test_command_self_hosted + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # ${{env.PRE_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} -RegressionArtifactsConfiguration ${{env.BUILD_CONFIGURATION}} + + # # TODO: Clean up the combination of options: https://github.com/microsoft/ebpf-for-windows/issues/1590 + # - name: Run test with Code Coverage in VS Dev environment + # if: (inputs.code_coverage == true) && (inputs.vs_dev == true) && (steps.skip_check.outputs.should_skip != 'true') + # id: run_test_with_code_coverage_in_vs_dev + # shell: cmd + # run: | + # call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + # set EBPF_ENABLE_WER_REPORT=yes + # OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\${{env.TEST_COMMAND}} + + # - name: Run test with Code Coverage and low resource simulation + # if: (inputs.code_coverage == true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') + # id: run_test_with_code_coverage_in_fault_injection + # shell: cmd + # run: | + # set EBPF_ENABLE_WER_REPORT=yes + # OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 8 + + # - name: Run test with low resource simulation + # if: (inputs.code_coverage != true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') + # id: run_test_with_fault_injection + # shell: cmd + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # set EBPF_ENABLE_WER_REPORT=yes + # powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 16 + + # - name: Run test with Code Coverage + # if: (inputs.code_coverage == true) && (inputs.vs_dev != true) && (inputs.fault_injection != true) && (steps.skip_check.outputs.should_skip != 'true') + # id: run_test_with_code_coverage + # shell: cmd + # run: | + # set EBPF_ENABLE_WER_REPORT=yes + # OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} + + # - name: Run test on self-hosted runner + # if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + # id: run_test_self_hosted + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} + + # - name: Run test without Code Coverage + # if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + # id: run_test_without_code_coverage + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # shell: cmd + # run: | + # cd /d ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} + # powershell.exe .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} + + # - name: Run post test command + # # Run the post test command even if the workflow has failed. + # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + # id: run_post_test_command + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # ${{env.POST_COMMAND}} + + # - name: Run post test command on self-hosted runner + # # Run the post test command even if the workflow has failed. + # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + # id: run_post_test_command_self_hosted + # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + # run: | + # ${{env.POST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} + + # - name: Check for CodeCoverage + # if: steps.skip_check.outputs.should_skip != 'true' + # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + # id: check_coverage + # with: + # files: ebpf_for_windows.xml + + # - name: Upload Report to Codecov attempt 1 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_coverage.outputs.files_exists == 'true') + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + # id: upload_code_coverage_report_1 + # continue-on-error: true + # with: + # files: ebpf_for_windows.xml + # fail_ci_if_error: true + # functionalities: fix + # root_dir: ${{github.workspace}} + + # - name: Wait on failure 1 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') + # run: Start-Sleep -Seconds 30 + + # - name: Upload Report to Codecov attempt 2 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + # id: upload_code_coverage_report_2 + # continue-on-error: true + # with: + # files: ebpf_for_windows.xml + # fail_ci_if_error: true + # functionalities: fix + # root_dir: ${{github.workspace}} + + # - name: Wait on failure 2 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') + # run: Start-Sleep -Seconds 60 + + # - name: Upload Report to Codecov attempt 3 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + # id: upload_code_coverage_report_3 + # continue-on-error: true + # with: + # files: ebpf_for_windows.xml + # fail_ci_if_error: true + # functionalities: fix + # root_dir: ${{github.workspace}} + + # - name: Wait on failure 3 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') + # run: Start-Sleep -Seconds 120 + + # - name: Upload Report to Codecov attempt 4 + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + # id: upload_code_coverage_report_4 + # continue-on-error: true + # with: + # files: ebpf_for_windows.xml + # fail_ci_if_error: true + # functionalities: fix + # root_dir: ${{github.workspace}} + + # - name: Fail if code coverage upload fails + # if: (steps.skip_check.outputs.should_skip != 'true') + # run: | + # if ($${{ steps.test.upload_code_coverage_report_1!='failure' }}) { exit 0 } + # if ($${{ steps.test.upload_code_coverage_report_2!='failure' }}) { exit 0 } + # if ($${{ steps.test.upload_code_coverage_report_3!='failure' }}) { exit 0 } + # if ($${{ steps.test.upload_code_coverage_report_4!='failure' }}) { exit 0 } + # exit 1 + + # - name: Stop ETW tracing + # id: stop_etw_tracing + # if: always() && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + # shell: cmd + # run: | + # wpr.exe -stop ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs\ebpfforwindows.etl + + # - name: Copy any bpf2c test logs to TestLogs + # if: (inputs.name == 'bpf2c') && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + # shell: cmd + # run: | + # copy ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\*.log ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs + + # - name: Check for crash dumps + # # Check for crash dumps even if the workflow failed. + # if: always() && (steps.skip_check.outputs.should_skip != 'true') + # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + # id: check_dumps + # with: + # files: ${{env.DUMP_PATH}}/*.dmp + + # - name: Upload any crash dumps + # # Upload crash dumps even if the workflow failed. + # if: always() && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') && (inputs.gather_dumps == true) + # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + # id: upload_crash_dumps + # with: + # name: Crash-Dumps-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + # path: ${{env.DUMP_PATH}} + # retention-days: 10 + + # - name: Check for TestLogs + # # Check for test logs even if the workflow failed. + # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + # if: always() && (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') + # id: check_logs + # with: + # files: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs/* + + # - name: Upload log files + # # Upload test logs even if the workflow failed. + # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_logs.outputs.files_exists == 'true') + # id: upload_logs + # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + # continue-on-error: true + # with: + # name: Test-Logs-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + # path: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs + # retention-days: 10 + + # - name: Check for generated artifacts + # # Check for artifacts even if the workflow failed. + # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') + # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + # id: check_artifacts + # with: + # files: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts\* + + # - name: Upload generated artifacts + # # Upload artifacts even if the workflow failed. + # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_artifacts.outputs.files_exists == 'true') + # id: upload_artifacts + # continue-on-error: true + # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + # with: + # name: Artifacts-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + # path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts + # retention-days: 10 + + # - name: Mark run as failed if crash dumps are found + # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') + # run: exit 1 + + # create_or_update_issue: + # needs: run_test + # if: ${{ failure() }} + # runs-on: ubuntu-latest + # steps: + # - name: Harden Runner + # uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + # with: + # disable-sudo: true + # egress-policy: block + # allowed-endpoints: > + # api.github.com:443 + + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 + # with: + # cancel_others: 'false' + # paths_ignore: '["**.md", "**/docs/**"]' + + # - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + # if: (github.event_name == 'schedule') || (github.event_name == 'push') && (steps.skip_check.outputs.should_skip != 'true') + # env: + # TITLE: Workflow failed - ${{inputs.name}} + # BODY: | + # [Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + # [Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }}) + # Test name - `${{ inputs.name }}` + # LABELS: bug,ci/cd + + # with: + # script: | + # const owner = process.env.GITHUB_REPOSITORY.split('/')[0] + # const repo = process.env.GITHUB_REPOSITORY.split('/')[1] + # const body = process.env.BODY; + # const title = process.env.TITLE; + # const labels = process.env.LABELS; + # const label_array = labels ? labels.split(',') : []; + # console.log(label_array); + # // Get all issues that have these labels. + # const opts = github.rest.issues.listForRepo.endpoint.merge({ + # ...context.issue, + # state: 'open', + # labels: label_array, + # }); + # const issues = await github.paginate(opts); + # // Look for an existing issue with the same title. + # for (const issue of issues) { + # if (issue.title === title) { + # console.log(`Updating issue ${title}`); + # await github.rest.issues.createComment({ + # issue_number: issue.number, + # owner, + # repo, + # body, + # }); + # return; + # } + # } + # // Existing issue not found, create a new one. + # console.log(`Creating issue ${title}`); + # await github.rest.issues.create({ + # owner: owner, + # repo: repo, + # title: title, + # body: body, + # labels: label_array, + # }); From 7de87ddb61df2693d6fb0dc4fabf3eb42e383c3a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Wed, 30 Oct 2024 12:41:24 -0700 Subject: [PATCH 07/91] wip --- .github/workflows/cicd.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 1d172e2823..1926a3aa55 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -42,26 +42,26 @@ jobs: # Jobs to run on pull, push, and schedule. # --------------------------------------------------------------------------- - # # Perform the regular build. - # regular: - # # Always run this job. - # if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - # uses: ./.github/workflows/reusable-build.yml - # with: - # ref: ${{ github.ref }} - # repository: ${{ github.repository }} - # build_artifact: Build-x64 - # generate_release_package: true - # build_msi: true - # build_nuget: true - # build_options: /p:ReleaseJIT='True' - # configurations: '["Release"]' + # Perform the regular build. + regular: + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64 + generate_release_package: true + build_msi: true + build_nuget: true + build_options: /p:ReleaseJIT='True' + configurations: '["Release"]' # Run the driver tests on self-hosted runners. driver_ws2019: # Always run this job. # Only run this on repos that have self-host runners. - # needs: regular + needs: regular if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') uses: ./.github/workflows/reusable-test.yml with: From 88d29014f98caf8f6df198d303a291457f143203 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Wed, 30 Oct 2024 12:51:13 -0700 Subject: [PATCH 08/91] wip --- .github/workflows/reusable-test.yml | 892 ++++++++++++++-------------- 1 file changed, 446 insertions(+), 446 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 0a66a428b5..d07bc36045 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -101,449 +101,449 @@ jobs: powershell.exe "Get-VMSwitch" powershell.exe "Get-VM" - # - name: Print CPU information - # run: - # Get-WmiObject -Class Win32_Processor | Select-Object -Property Name, NumberOfCores, NumberOfLogicalProcessors - - # - id: skip_check - # uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 - # with: - # cancel_others: 'false' - # paths_ignore: '["**.md", "**/docs/**"]' - - # # Checking out the branch is needed to gather correct code coverage data. - # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - # # Only check out source code if code coverage is being gathered. - # if: (inputs.code_coverage == true) && (steps.skip_check.outputs.should_skip != 'true') - # with: - # submodules: 'recursive' - # ref: ${{ github.event.workflow_run.head_branch }} - - # # Perform shallow checkout for self-hosted runner. - # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - # if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - # with: - # ref: ${{ github.event.workflow_run.head_branch }} - - # # Check if .github/workflows/reusable-test.yml exists locally. - # - name: Check for .github/workflows/reusable-test.yml - # # Check for test logs even if the workflow failed. - # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - # id: check_reusable_test_locally - # with: - # files: .github/workflows/reusable-test.yml - - # # Check out just this file if code hasn't been checked out yet. - # - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 - # if: (steps.check_reusable_test_locally.outputs.files_exists != 'true') && (steps.skip_check.outputs.should_skip != 'true') - # with: - # sparse-checkout: | - # .github/workflows/reusable-test.yml - # sparse-checkout-cone-mode: false - - - # - name: Set up choco cache folder - # # Set the choco cache to a local folder so that it can be cached. - # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - # id: choco-cache - # run: | - # mkdir ${{github.workspace}}\choco_cache - # choco config set --name cacheLocation --value ${{github.workspace}}\choco_cache - - # - name: Cache choco packages - # # Add cache entry for any choco packages that are installed. - # # The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated. - # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - # uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 - # env: - # cache-name: cache-choco-packages - # with: - # path: ${{github.workspace}}\choco_cache - # key: ${{ hashFiles('.github/workflows/reusable-test.yml') }} - - # - name: Install ProcDump - # id: install_procdump - # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - # run: | - # choco install -y procdump - # where procdump.exe - - # - name: Set up OpenCppCoverage and add to PATH - # id: set_up_opencppcoverage - # if: (inputs.code_coverage == true) && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - # run: | - # choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage - # echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - # where OpenCppCoverage.exe - - # - name: Configure Windows Error Reporting to make a local copy of any crashes that occur. - # id: configure_windows_error_reporting - # if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') - # run: | - # mkdir ${{env.DUMP_PATH}} - # New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue - # New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue - # $dump_path = "${{env.DUMP_PATH}}".Replace("/", "\") - # New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - - # - name: Remove existing artifacts - # if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') - # run: | - # Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue - - # - name: Download build artifact - # if: (steps.skip_check.outputs.should_skip != 'true') && success() - # uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 - # id: download_artifact - # with: - # name: ${{inputs.build_artifact}}-${{matrix.configurations}} - # path: ${{github.workspace}} - - # - name: Extract build artifact - # if: steps.skip_check.outputs.should_skip != 'true' - # working-directory: ${{github.workspace}} - # run: | - # mkdir ${{env.BUILD_PLATFORM}} - # Expand-Archive .\build-${{ matrix.configurations }}.zip -DestinationPath .\${{env.BUILD_PLATFORM}} - - # - name: Create generated artifact folder - # if: (steps.skip_check.outputs.should_skip != 'true') - # run: | - # mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts - - # - name: Start ETW tracing - # id: start_etw_tracing - # if: (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - # shell: cmd - # run: | - # mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs - # wpr.exe -start ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\ebpfforwindows.wprp -filemode - - # - name: Set ASAN Environment Variable - # if: steps.skip_check.outputs.should_skip != 'true' - # id: set_asan_env_var - # shell: cmd - # run: | - # powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" - # powershell.exe "echo 'ASAN_OPTIONS=allocator_may_return_null=1' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" - - # - name: Configure eBPF store - # if: steps.skip_check.outputs.should_skip != 'true' - # id: configure_ebpf_store - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # .\export_program_info.exe --clear - # .\export_program_info.exe - - # - name: Configure eBPF store (undocked) - # if: (steps.skip_check.outputs.should_skip != 'true') && (matrix.configurations != 'FuzzerDebug') - # id: configure_ebpf_store_undocked - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # .\export_program_info_sample.exe --clear - # .\export_program_info_sample.exe - - # - name: 1ES TEST - # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - # id: test_1es - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # hostname - # whoami - # powershell.exe Get-VM - # dir /s - - # - name: Run pre test command - # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - # id: run_pre_test_command - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # ${{env.PRE_COMMAND}} - - # - name: Run pre test command on self-hosted runner - # if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') - # id: run_pre_test_command_self_hosted - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # ${{env.PRE_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} -RegressionArtifactsConfiguration ${{env.BUILD_CONFIGURATION}} - - # # TODO: Clean up the combination of options: https://github.com/microsoft/ebpf-for-windows/issues/1590 - # - name: Run test with Code Coverage in VS Dev environment - # if: (inputs.code_coverage == true) && (inputs.vs_dev == true) && (steps.skip_check.outputs.should_skip != 'true') - # id: run_test_with_code_coverage_in_vs_dev - # shell: cmd - # run: | - # call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" - # set EBPF_ENABLE_WER_REPORT=yes - # OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\${{env.TEST_COMMAND}} - - # - name: Run test with Code Coverage and low resource simulation - # if: (inputs.code_coverage == true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') - # id: run_test_with_code_coverage_in_fault_injection - # shell: cmd - # run: | - # set EBPF_ENABLE_WER_REPORT=yes - # OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 8 - - # - name: Run test with low resource simulation - # if: (inputs.code_coverage != true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') - # id: run_test_with_fault_injection - # shell: cmd - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # set EBPF_ENABLE_WER_REPORT=yes - # powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 16 - - # - name: Run test with Code Coverage - # if: (inputs.code_coverage == true) && (inputs.vs_dev != true) && (inputs.fault_injection != true) && (steps.skip_check.outputs.should_skip != 'true') - # id: run_test_with_code_coverage - # shell: cmd - # run: | - # set EBPF_ENABLE_WER_REPORT=yes - # OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - - # - name: Run test on self-hosted runner - # if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) - # id: run_test_self_hosted - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - - # - name: Run test without Code Coverage - # if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) - # id: run_test_without_code_coverage - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # shell: cmd - # run: | - # cd /d ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} - # powershell.exe .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - - # - name: Run post test command - # # Run the post test command even if the workflow has failed. - # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - # id: run_post_test_command - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # ${{env.POST_COMMAND}} - - # - name: Run post test command on self-hosted runner - # # Run the post test command even if the workflow has failed. - # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') - # id: run_post_test_command_self_hosted - # working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - # run: | - # ${{env.POST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - - # - name: Check for CodeCoverage - # if: steps.skip_check.outputs.should_skip != 'true' - # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - # id: check_coverage - # with: - # files: ebpf_for_windows.xml - - # - name: Upload Report to Codecov attempt 1 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_coverage.outputs.files_exists == 'true') - # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - # id: upload_code_coverage_report_1 - # continue-on-error: true - # with: - # files: ebpf_for_windows.xml - # fail_ci_if_error: true - # functionalities: fix - # root_dir: ${{github.workspace}} - - # - name: Wait on failure 1 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') - # run: Start-Sleep -Seconds 30 - - # - name: Upload Report to Codecov attempt 2 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') - # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - # id: upload_code_coverage_report_2 - # continue-on-error: true - # with: - # files: ebpf_for_windows.xml - # fail_ci_if_error: true - # functionalities: fix - # root_dir: ${{github.workspace}} - - # - name: Wait on failure 2 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') - # run: Start-Sleep -Seconds 60 - - # - name: Upload Report to Codecov attempt 3 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') - # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - # id: upload_code_coverage_report_3 - # continue-on-error: true - # with: - # files: ebpf_for_windows.xml - # fail_ci_if_error: true - # functionalities: fix - # root_dir: ${{github.workspace}} - - # - name: Wait on failure 3 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') - # run: Start-Sleep -Seconds 120 - - # - name: Upload Report to Codecov attempt 4 - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') - # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 - # id: upload_code_coverage_report_4 - # continue-on-error: true - # with: - # files: ebpf_for_windows.xml - # fail_ci_if_error: true - # functionalities: fix - # root_dir: ${{github.workspace}} - - # - name: Fail if code coverage upload fails - # if: (steps.skip_check.outputs.should_skip != 'true') - # run: | - # if ($${{ steps.test.upload_code_coverage_report_1!='failure' }}) { exit 0 } - # if ($${{ steps.test.upload_code_coverage_report_2!='failure' }}) { exit 0 } - # if ($${{ steps.test.upload_code_coverage_report_3!='failure' }}) { exit 0 } - # if ($${{ steps.test.upload_code_coverage_report_4!='failure' }}) { exit 0 } - # exit 1 - - # - name: Stop ETW tracing - # id: stop_etw_tracing - # if: always() && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - # shell: cmd - # run: | - # wpr.exe -stop ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs\ebpfforwindows.etl - - # - name: Copy any bpf2c test logs to TestLogs - # if: (inputs.name == 'bpf2c') && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') - # shell: cmd - # run: | - # copy ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\*.log ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs - - # - name: Check for crash dumps - # # Check for crash dumps even if the workflow failed. - # if: always() && (steps.skip_check.outputs.should_skip != 'true') - # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - # id: check_dumps - # with: - # files: ${{env.DUMP_PATH}}/*.dmp - - # - name: Upload any crash dumps - # # Upload crash dumps even if the workflow failed. - # if: always() && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') && (inputs.gather_dumps == true) - # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - # id: upload_crash_dumps - # with: - # name: Crash-Dumps-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - # path: ${{env.DUMP_PATH}} - # retention-days: 10 - - # - name: Check for TestLogs - # # Check for test logs even if the workflow failed. - # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - # if: always() && (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') - # id: check_logs - # with: - # files: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs/* - - # - name: Upload log files - # # Upload test logs even if the workflow failed. - # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_logs.outputs.files_exists == 'true') - # id: upload_logs - # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - # continue-on-error: true - # with: - # name: Test-Logs-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - # path: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs - # retention-days: 10 - - # - name: Check for generated artifacts - # # Check for artifacts even if the workflow failed. - # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') - # uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 - # id: check_artifacts - # with: - # files: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts\* - - # - name: Upload generated artifacts - # # Upload artifacts even if the workflow failed. - # if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_artifacts.outputs.files_exists == 'true') - # id: upload_artifacts - # continue-on-error: true - # uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 - # with: - # name: Artifacts-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} - # path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts - # retention-days: 10 - - # - name: Mark run as failed if crash dumps are found - # if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') - # run: exit 1 - - # create_or_update_issue: - # needs: run_test - # if: ${{ failure() }} - # runs-on: ubuntu-latest - # steps: - # - name: Harden Runner - # uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 - # with: - # disable-sudo: true - # egress-policy: block - # allowed-endpoints: > - # api.github.com:443 - - # - id: skip_check - # uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 - # with: - # cancel_others: 'false' - # paths_ignore: '["**.md", "**/docs/**"]' - - # - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea - # if: (github.event_name == 'schedule') || (github.event_name == 'push') && (steps.skip_check.outputs.should_skip != 'true') - # env: - # TITLE: Workflow failed - ${{inputs.name}} - # BODY: | - # [Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - # [Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }}) - # Test name - `${{ inputs.name }}` - # LABELS: bug,ci/cd - - # with: - # script: | - # const owner = process.env.GITHUB_REPOSITORY.split('/')[0] - # const repo = process.env.GITHUB_REPOSITORY.split('/')[1] - # const body = process.env.BODY; - # const title = process.env.TITLE; - # const labels = process.env.LABELS; - # const label_array = labels ? labels.split(',') : []; - # console.log(label_array); - # // Get all issues that have these labels. - # const opts = github.rest.issues.listForRepo.endpoint.merge({ - # ...context.issue, - # state: 'open', - # labels: label_array, - # }); - # const issues = await github.paginate(opts); - # // Look for an existing issue with the same title. - # for (const issue of issues) { - # if (issue.title === title) { - # console.log(`Updating issue ${title}`); - # await github.rest.issues.createComment({ - # issue_number: issue.number, - # owner, - # repo, - # body, - # }); - # return; - # } - # } - # // Existing issue not found, create a new one. - # console.log(`Creating issue ${title}`); - # await github.rest.issues.create({ - # owner: owner, - # repo: repo, - # title: title, - # body: body, - # labels: label_array, - # }); + - name: Print CPU information + run: + Get-WmiObject -Class Win32_Processor | Select-Object -Property Name, NumberOfCores, NumberOfLogicalProcessors + + - id: skip_check + uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 + with: + cancel_others: 'false' + paths_ignore: '["**.md", "**/docs/**"]' + + # Checking out the branch is needed to gather correct code coverage data. + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + # Only check out source code if code coverage is being gathered. + if: (inputs.code_coverage == true) && (steps.skip_check.outputs.should_skip != 'true') + with: + submodules: 'recursive' + ref: ${{ github.event.workflow_run.head_branch }} + + # Perform shallow checkout for self-hosted runner. + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + with: + ref: ${{ github.event.workflow_run.head_branch }} + + # Check if .github/workflows/reusable-test.yml exists locally. + - name: Check for .github/workflows/reusable-test.yml + # Check for test logs even if the workflow failed. + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + id: check_reusable_test_locally + with: + files: .github/workflows/reusable-test.yml + + # Check out just this file if code hasn't been checked out yet. + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + if: (steps.check_reusable_test_locally.outputs.files_exists != 'true') && (steps.skip_check.outputs.should_skip != 'true') + with: + sparse-checkout: | + .github/workflows/reusable-test.yml + sparse-checkout-cone-mode: false + + + - name: Set up choco cache folder + # Set the choco cache to a local folder so that it can be cached. + if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + id: choco-cache + run: | + mkdir ${{github.workspace}}\choco_cache + choco config set --name cacheLocation --value ${{github.workspace}}\choco_cache + + - name: Cache choco packages + # Add cache entry for any choco packages that are installed. + # The cache key is based on the hash of this file so if any choco packages are added or removed, the cache will be invalidated. + if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 + env: + cache-name: cache-choco-packages + with: + path: ${{github.workspace}}\choco_cache + key: ${{ hashFiles('.github/workflows/reusable-test.yml') }} + + - name: Install ProcDump + id: install_procdump + if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + run: | + choco install -y procdump + where procdump.exe + + - name: Set up OpenCppCoverage and add to PATH + id: set_up_opencppcoverage + if: (inputs.code_coverage == true) && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + run: | + choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage + echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + where OpenCppCoverage.exe + + - name: Configure Windows Error Reporting to make a local copy of any crashes that occur. + id: configure_windows_error_reporting + if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') + run: | + mkdir ${{env.DUMP_PATH}} + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue + $dump_path = "${{env.DUMP_PATH}}".Replace("/", "\") + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue + + - name: Remove existing artifacts + if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + run: | + Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue + + - name: Download build artifact + if: (steps.skip_check.outputs.should_skip != 'true') && success() + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 + id: download_artifact + with: + name: ${{inputs.build_artifact}}-${{matrix.configurations}} + path: ${{github.workspace}} + + - name: Extract build artifact + if: steps.skip_check.outputs.should_skip != 'true' + working-directory: ${{github.workspace}} + run: | + mkdir ${{env.BUILD_PLATFORM}} + Expand-Archive .\build-${{ matrix.configurations }}.zip -DestinationPath .\${{env.BUILD_PLATFORM}} + + - name: Create generated artifact folder + if: (steps.skip_check.outputs.should_skip != 'true') + run: | + mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts + + - name: Start ETW tracing + id: start_etw_tracing + if: (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + shell: cmd + run: | + mkdir ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs + wpr.exe -start ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\ebpfforwindows.wprp -filemode + + - name: Set ASAN Environment Variable + if: steps.skip_check.outputs.should_skip != 'true' + id: set_asan_env_var + shell: cmd + run: | + powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" + powershell.exe "echo 'ASAN_OPTIONS=allocator_may_return_null=1' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" + + - name: Configure eBPF store + if: steps.skip_check.outputs.should_skip != 'true' + id: configure_ebpf_store + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + .\export_program_info.exe --clear + .\export_program_info.exe + + - name: Configure eBPF store (undocked) + if: (steps.skip_check.outputs.should_skip != 'true') && (matrix.configurations != 'FuzzerDebug') + id: configure_ebpf_store_undocked + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + .\export_program_info_sample.exe --clear + .\export_program_info_sample.exe + + - name: 1ES TEST + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + id: test_1es + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + hostname + whoami + powershell.exe Get-VM + dir /s + + - name: Run pre test command + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + id: run_pre_test_command + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + ${{env.PRE_COMMAND}} + + - name: Run pre test command on self-hosted runner + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + id: run_pre_test_command_self_hosted + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + ${{env.PRE_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} -RegressionArtifactsConfiguration ${{env.BUILD_CONFIGURATION}} + + # TODO: Clean up the combination of options: https://github.com/microsoft/ebpf-for-windows/issues/1590 + - name: Run test with Code Coverage in VS Dev environment + if: (inputs.code_coverage == true) && (inputs.vs_dev == true) && (steps.skip_check.outputs.should_skip != 'true') + id: run_test_with_code_coverage_in_vs_dev + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" + set EBPF_ENABLE_WER_REPORT=yes + OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\${{env.TEST_COMMAND}} + + - name: Run test with Code Coverage and low resource simulation + if: (inputs.code_coverage == true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') + id: run_test_with_code_coverage_in_fault_injection + shell: cmd + run: | + set EBPF_ENABLE_WER_REPORT=yes + OpenCppCoverage.exe -q --cover_children --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 8 + + - name: Run test with low resource simulation + if: (inputs.code_coverage != true) && (inputs.fault_injection == true) && (steps.skip_check.outputs.should_skip != 'true') + id: run_test_with_fault_injection + shell: cmd + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + set EBPF_ENABLE_WER_REPORT=yes + powershell.exe .\Test-FaultInjection.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} 16 + + - name: Run test with Code Coverage + if: (inputs.code_coverage == true) && (inputs.vs_dev != true) && (inputs.fault_injection != true) && (steps.skip_check.outputs.should_skip != 'true') + id: run_test_with_code_coverage + shell: cmd + run: | + set EBPF_ENABLE_WER_REPORT=yes + OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} + + - name: Run test on self-hosted runner + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + id: run_test_self_hosted + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} + + - name: Run test without Code Coverage + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + id: run_test_without_code_coverage + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + shell: cmd + run: | + cd /d ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} + powershell.exe .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} + + - name: Run post test command + # Run the post test command even if the workflow has failed. + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + id: run_post_test_command + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + ${{env.POST_COMMAND}} + + - name: Run post test command on self-hosted runner + # Run the post test command even if the workflow has failed. + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + id: run_post_test_command_self_hosted + working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} + run: | + ${{env.POST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} + + - name: Check for CodeCoverage + if: steps.skip_check.outputs.should_skip != 'true' + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + id: check_coverage + with: + files: ebpf_for_windows.xml + + - name: Upload Report to Codecov attempt 1 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_coverage.outputs.files_exists == 'true') + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + id: upload_code_coverage_report_1 + continue-on-error: true + with: + files: ebpf_for_windows.xml + fail_ci_if_error: true + functionalities: fix + root_dir: ${{github.workspace}} + + - name: Wait on failure 1 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') + run: Start-Sleep -Seconds 30 + + - name: Upload Report to Codecov attempt 2 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_1.outcome == 'failure') + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + id: upload_code_coverage_report_2 + continue-on-error: true + with: + files: ebpf_for_windows.xml + fail_ci_if_error: true + functionalities: fix + root_dir: ${{github.workspace}} + + - name: Wait on failure 2 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') + run: Start-Sleep -Seconds 60 + + - name: Upload Report to Codecov attempt 3 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_2.outcome == 'failure') + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + id: upload_code_coverage_report_3 + continue-on-error: true + with: + files: ebpf_for_windows.xml + fail_ci_if_error: true + functionalities: fix + root_dir: ${{github.workspace}} + + - name: Wait on failure 3 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') + run: Start-Sleep -Seconds 120 + + - name: Upload Report to Codecov attempt 4 + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.upload_code_coverage_report_3.outcome == 'failure') + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 + id: upload_code_coverage_report_4 + continue-on-error: true + with: + files: ebpf_for_windows.xml + fail_ci_if_error: true + functionalities: fix + root_dir: ${{github.workspace}} + + - name: Fail if code coverage upload fails + if: (steps.skip_check.outputs.should_skip != 'true') + run: | + if ($${{ steps.test.upload_code_coverage_report_1!='failure' }}) { exit 0 } + if ($${{ steps.test.upload_code_coverage_report_2!='failure' }}) { exit 0 } + if ($${{ steps.test.upload_code_coverage_report_3!='failure' }}) { exit 0 } + if ($${{ steps.test.upload_code_coverage_report_4!='failure' }}) { exit 0 } + exit 1 + + - name: Stop ETW tracing + id: stop_etw_tracing + if: always() && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + shell: cmd + run: | + wpr.exe -stop ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs\ebpfforwindows.etl + + - name: Copy any bpf2c test logs to TestLogs + if: (inputs.name == 'bpf2c') && (inputs.capture_etw == true) && (steps.skip_check.outputs.should_skip != 'true') + shell: cmd + run: | + copy ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\*.log ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\TestLogs + + - name: Check for crash dumps + # Check for crash dumps even if the workflow failed. + if: always() && (steps.skip_check.outputs.should_skip != 'true') + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + id: check_dumps + with: + files: ${{env.DUMP_PATH}}/*.dmp + + - name: Upload any crash dumps + # Upload crash dumps even if the workflow failed. + if: always() && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') && (inputs.gather_dumps == true) + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + id: upload_crash_dumps + with: + name: Crash-Dumps-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + path: ${{env.DUMP_PATH}} + retention-days: 10 + + - name: Check for TestLogs + # Check for test logs even if the workflow failed. + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + if: always() && (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') + id: check_logs + with: + files: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs/* + + - name: Upload log files + # Upload test logs even if the workflow failed. + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_logs.outputs.files_exists == 'true') + id: upload_logs + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + continue-on-error: true + with: + name: Test-Logs-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + path: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/TestLogs + retention-days: 10 + + - name: Check for generated artifacts + # Check for artifacts even if the workflow failed. + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 + id: check_artifacts + with: + files: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts\* + + - name: Upload generated artifacts + # Upload artifacts even if the workflow failed. + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (steps.check_artifacts.outputs.files_exists == 'true') + id: upload_artifacts + continue-on-error: true + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + with: + name: Artifacts-${{env.NAME}}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}} + path: ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}}\Artifacts + retention-days: 10 + + - name: Mark run as failed if crash dumps are found + if: (steps.skip_check.outputs.should_skip != 'true') && (steps.check_dumps.outputs.files_exists == 'true') + run: exit 1 + + create_or_update_issue: + needs: run_test + if: ${{ failure() }} + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.github.com:443 + + - id: skip_check + uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 + with: + cancel_others: 'false' + paths_ignore: '["**.md", "**/docs/**"]' + + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + if: (github.event_name == 'schedule') || (github.event_name == 'push') && (steps.skip_check.outputs.should_skip != 'true') + env: + TITLE: Workflow failed - ${{inputs.name}} + BODY: | + [Failed Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + [Codebase](https://github.com/${{ github.repository }}/tree/${{ github.sha }}) + Test name - `${{ inputs.name }}` + LABELS: bug,ci/cd + + with: + script: | + const owner = process.env.GITHUB_REPOSITORY.split('/')[0] + const repo = process.env.GITHUB_REPOSITORY.split('/')[1] + const body = process.env.BODY; + const title = process.env.TITLE; + const labels = process.env.LABELS; + const label_array = labels ? labels.split(',') : []; + console.log(label_array); + // Get all issues that have these labels. + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + state: 'open', + labels: label_array, + }); + const issues = await github.paginate(opts); + // Look for an existing issue with the same title. + for (const issue of issues) { + if (issue.title === title) { + console.log(`Updating issue ${title}`); + await github.rest.issues.createComment({ + issue_number: issue.number, + owner, + repo, + body, + }); + return; + } + } + // Existing issue not found, create a new one. + console.log(`Creating issue ${title}`); + await github.rest.issues.create({ + owner: owner, + repo: repo, + title: title, + body: body, + labels: label_array, + }); From 40a3ad37f5d64988ff47260f49dc1208ee09d151 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Wed, 30 Oct 2024 14:23:57 -0700 Subject: [PATCH 09/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index d07bc36045..2463ea1f72 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -96,7 +96,7 @@ jobs: run: | powershell.exe "Get-NetAdapter" powershell.exe "Get-VMSwitch" - powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup.ps1" + powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" powershell.exe "Get-NetAdapter" powershell.exe "Get-VMSwitch" powershell.exe "Get-VM" From 68eb7185622ba28a086083f047d77998bf097d2e Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" Date: Tue, 12 Nov 2024 14:30:54 -0800 Subject: [PATCH 10/91] WIP --- 1es/Setup.ps1 | 29 ++++ 1es/Setup_orig.ps1 | 82 +++++++++ 1es/artifacts.json | 41 +++++ 1es/configure_vm.ps1 | 108 ++++++++++++ 1es/prepare_host.ps1 | 12 ++ 1es/prepare_vm_helpers.psm1 | 321 ++++++++++++++++++++++++++++++++++++ 1es/unattend.xml | 52 ++++++ 7 files changed, 645 insertions(+) create mode 100644 1es/Setup.ps1 create mode 100644 1es/Setup_orig.ps1 create mode 100644 1es/artifacts.json create mode 100644 1es/configure_vm.ps1 create mode 100644 1es/prepare_host.ps1 create mode 100644 1es/prepare_vm_helpers.psm1 create mode 100644 1es/unattend.xml diff --git a/1es/Setup.ps1 b/1es/Setup.ps1 new file mode 100644 index 0000000000..9b3994cd04 --- /dev/null +++ b/1es/Setup.ps1 @@ -0,0 +1,29 @@ +# Copyright (c) eBPF for Windows contributors +# SPDX-License-Identifier: MIT +# param( +# [Parameter(Mandatory=$False)][string]$VmUsername='Administrator', +# [Parameter(Mandatory=$False)][string]$VmPassword='P@ssw0rd', + +# [Parameter(Mandatory=$False)][string]$BaseUnattendPath='.\unattend.xml', +# [Parameter(Mandatory=$False)][string]$BaseVhdDirPath='.\', +# [Parameter(Mandatory=$False)][string]$WorkingPath='.\working', +# [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', +# [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch', + +# [Parameter(Mandatory=$False)][string]$VMCpuCount=4, +# [Parameter(Mandatory=$False)][string]$VMMemoryStartupBytes=512MB +# ) + +# $ErrorActionPreference = "Stop" + +# # Import helper functions +# Import-Module .\prepare_vm_helpers.psm1 -Force + +$hyperV = (Get-WindowsFeature -Name 'Hyper-V').Installed +Log-Message -Message "Hyper-V is installed: $hyperV" + +$names = (Get-NetAdapter).Name +Log-Message -Message "Network adapters: $names" + +$switches = Get-VMSwitch +Log-Message -Message "VM switches: $switches" diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 new file mode 100644 index 0000000000..9ef71a2100 --- /dev/null +++ b/1es/Setup_orig.ps1 @@ -0,0 +1,82 @@ +# Copyright (c) eBPF for Windows contributors +# SPDX-License-Identifier: MIT +param( + [Parameter(Mandatory=$False)][string]$VmUsername='Administrator', + [Parameter(Mandatory=$False)][string]$VmPassword='P@ssw0rd', + + [Parameter(Mandatory=$False)][string]$BaseUnattendPath='.\unattend.xml', + [Parameter(Mandatory=$False)][string]$BaseVhdDirPath='.\', + [Parameter(Mandatory=$False)][string]$WorkingPath='.\working', + [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', + [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch', + + [Parameter(Mandatory=$False)][string]$VMCpuCount=2, + [Parameter(Mandatory=$False)][string]$VMMemoryStartupBytes=512MB +) + +$ErrorActionPreference = "Stop" + +# Import helper functions +Import-Module .\prepare_vm_helpers.psm1 -Force + +Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName +$ExternalSwitches = Get-VMSwitch -SwitchType External +if (-not $ExternalSwitches) { + throw "No external switches found" +} +foreach ($switch in $ExternalSwitches) { + Log-Message "External switch: $switch" + Log-Message "External switch: $($switch.Name)" +} + +if (-not (Test-Path -Path $BaseUnattendPath)) { + throw "Unattend file not found at $BaseUnattendPath" +} + +if (-not (Test-Path -Path $BaseVhdDirPath)) { + throw "VHD directory not found at $BaseVhdDirPath" +} + +Create-DirectoryIfNotExists -Path $WorkingPath + +# Create-DirectoryIfNotExists -Path $OutVhdDirPath + +# Create credential object for executing commands on the VM +# TODO - maybe this can be read from the unattend file? Or passed as an azure parameter, which replaces in the unattend file. +# $vmCredential = Create-VMCredential -VmUsername $VmUsername -VmPassword $VmPassword + +# Read the input VHDs +$vhds = @((Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhd)) +$vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhdx +if ($vhds.Count -eq 0) { + throw "No VHDs found in $BaseVhdDirPath" +} + +for ($i = 0; $i -lt $vhds.Count; $i++) { + $vhd = $vhds[$i] + Log-Message -Message "Processing VHD: $($vhd.FullName)" + $vmName = "runner_vm" + if ($i -gt 0) { + $vmName += "_$i" + } + $outVMPath = Join-Path -Path $WorkingPath -ChildPath $VMName + + Create-VM ` + -VmName $vmName ` + -VhdPath $vhd.FullName ` + -VmStoragePath $outVMPath ` + -ExternalVMSwitchName $ExternalSwitchName ` + -MemoryStartupBytes $VMMemoryStartupBytes ` + -UnattendPath $BaseUnattendPath ` + -VmUsername $VmUsername ` + -VmPassword $VmPassword + + Configure-VM ` + -VmName $vmName ` + -CpuCount $VMCpuCount ` + -VmUsername $VmUsername ` + -VmPassword $VmPassword + + Export-VM -Name $vmName -Path $OutVhdDirPath + Log-Message -Message "Successfully exported VM: $VMName to $VMWorkingDirectory\$VMName.vhd" -ForegroundColor Green +} diff --git a/1es/artifacts.json b/1es/artifacts.json new file mode 100644 index 0000000000..2eb447c1eb --- /dev/null +++ b/1es/artifacts.json @@ -0,0 +1,41 @@ +{ + "license":["Copyright (c) eBPF for Windows contributors", "SPDX-License-Identifier: MIT"], + "artifacts": [ + { + "name": "windows-bcdedit-testsigning", + "parameters": { + "TestSigningOption": "On" + } + }, + { + "name": "windows-server-install-feature-hyperv" + }, + { + "name": "windows-HyperV-NewVMSwitch", + "parameters" : { + "VMSwitchName": "VMExternalSwitch" + } + }, + { + "name": "windows-gitinstall", + "parameters": { + "SetCredHelper": "false" + } + } + ] +} + + + { + "name": "windows-vcredist-x64" + } + +https://dev.azure.com/devdiv/XlabImageFactory/_git/XlabImageFactory?path=%2Fartifacts +/artifacts/windows-server-install-feature-hyperv/windows-server-install-feature-hyperv.ps1 +\ + +/artifacts/windows-HyperV-NewVMSwitch/windows-HyperV-NewVMSwitch.ps1 + + + +/artifacts/Windows-NestedVirtualization/Windows-NestedVirtualization.ps1 \ No newline at end of file diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 new file mode 100644 index 0000000000..a9d4481444 --- /dev/null +++ b/1es/configure_vm.ps1 @@ -0,0 +1,108 @@ +# Copyright (c) eBPF for Windows contributors +# SPDX-License-Identifier: MIT + +########## Helper Functions ########## +# Download and extract PSExec to run tests as SYSTEM. +function Get-PSExec { + $url = "https://download.sysinternals.com/files/PSTools.zip" + $DownloadPath = "$pwd\psexec" + mkdir $DownloadPath + Write-Host "Downloading PSExec from $url to $DownloadPath" + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest $url -OutFile "$DownloadPath\pstools.zip" + cd $DownloadPath + Expand-Archive -Path "$DownloadPath\pstools.zip" -Force + cd .. + Move-Item -Path "$DownloadPath\PSTools\PsExec64.exe" -Destination $pwd -Force + Remove-Item -Path $DownloadPath -Force -Recurse +} + +function Get-ZipFileFromUrl { + param( + [Parameter(Mandatory=$True)][string] $Url, + [Parameter(Mandatory=$True)][string] $DownloadFilePath, + [Parameter(Mandatory=$True)][string] $OutputDir + ) + + for ($i = 0; $i -lt 5; $i++) { + try { + Write-Host "Downloading $Url to $DownloadFilePath" + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $Url -OutFile $DownloadFilePath + + Write-Host "Extracting $DownloadFilePath to $OutputDir" + Expand-Archive -Path $DownloadFilePath -DestinationPath $OutputDir -Force + break + } catch { + Write-Host "Iteration $i failed to download $Url. Removing $DownloadFilePath" -ForegroundColor Red + Remove-Item -Path $DownloadFilePath -Force -ErrorAction Ignore + Start-Sleep -Seconds 5 + } + } +} + +# Copied from https://github.com/microsoft/msquic/blob/main/scripts/prepare-machine.ps1 +function Get-Duonic { + # Download and extract https://github.com/microsoft/corenet-ci. + $DownloadPath = "$pwd\corenet-ci" + mkdir $DownloadPath + Write-Host "Downloading CoreNet-CI to $DownloadPath" + Get-ZipFileFromUrl -Url "https://github.com/microsoft/corenet-ci/archive/refs/heads/main.zip" -DownloadFilePath "$DownloadPath\corenet-ci.zip" -OutputDir $DownloadPath + Move-Item -Path "$DownloadPath\corenet-ci-main\vm-setup\duonic\*" -Destination $pwd -Force + Move-Item -Path "$DownloadPath\corenet-ci-main\vm-setup\procdump64.exe" -Destination $pwd -Force + Move-Item -Path "$DownloadPath\corenet-ci-main\vm-setup\notmyfault64.exe" -Destination $pwd -Force + Remove-Item -Path $DownloadPath -Force -Recurse +} + +function Initialize-NetworkInterfacesOnVMs +{ + # param([parameter(Mandatory=$true)] $VMMap) + + # foreach ($VM in $VMMap) + # { + # $VMName = $VM.Name + + # Write-Log "Initializing network interfaces on $VMName" + # $TestCredential = New-Credential -Username $Admin -AdminPassword $AdminPassword + + # Invoke-Command -VMName $VMName -Credential $TestCredential -ScriptBlock { + # param([Parameter(Mandatory=$True)] [string] $WorkingDirectory) + + # Push-Location "$env:SystemDrive\$WorkingDirectory" + + Write-Host "Installing DuoNic driver" + .\duonic.ps1 -Install -NumNicPairs 2 + # Disable Duonic's fake checksum offload and force TCP/IP to calculate it. + Set-NetAdapterAdvancedProperty duo? -DisplayName Checksum -RegistryValue 0 + + # Pop-Location + # } -ArgumentList ("eBPF") -ErrorAction Stop + # } +} + +########## Main Execution ########## + +# Enable test signing. +bcdedit -set TESTSIGNING ON + +# Enable user-mode dumps. +New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -ErrorAction SilentlyContinue +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "c:\dumps" -PropertyType ExpandString -ErrorAction SilentlyContinue -Force + +# Enable kernel dumps. +New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -ErrorAction SilentlyContinue +New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "CrashDumpEnabled" -Value 2 -PropertyType DWord -ErrorAction SilentlyContinue + +# Enable driver verifier on the eBPF platform drivers. +verifier /standard /bootmode persistent /driver ebpfcore.sys netebpfext.sys sample_ebpf_ext.sys + +# Install duonic and configure it. +Get-Duonic +Initialize-NetworkInterfacesOnVMs + +# Get PSExec to run tests as SYSTEM. +Get-PSExec + +# Reboot the machine to apply the changes. +Restart-Computer -Force \ No newline at end of file diff --git a/1es/prepare_host.ps1 b/1es/prepare_host.ps1 new file mode 100644 index 0000000000..1ea39fe6e4 --- /dev/null +++ b/1es/prepare_host.ps1 @@ -0,0 +1,12 @@ +# Copyright (c) eBPF for Windows contributors +# SPDX-License-Identifier: MIT +param( + [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch' +) + +Import-Module .\prepare_vm_helpers.psm1 -Force + +Install-HyperVIfNeeded +Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName + +# TODO - Fetch VHDs \ No newline at end of file diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 new file mode 100644 index 0000000000..3404f90d4d --- /dev/null +++ b/1es/prepare_vm_helpers.psm1 @@ -0,0 +1,321 @@ +# Copyright (c) eBPF for Windows contributors +# SPDX-License-Identifier: MIT +$ErrorActionPreference = "Stop" + +function Log-Message { + param( + [Parameter(Mandatory=$True)][string]$Message, + [Parameter(Mandatory=$False)][string]$ForegroundColor='White' + ) + + # Get timestamp + $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + + Write-Host "[$timestamp] - $Message" -ForegroundColor $ForegroundColor +} + +function Create-DirectoryIfNotExists { + param ( + [Parameter(Mandatory=$True)][string]$Path + ) + + try { + if (-not (Test-Path -Path $Path -PathType Container)) { + New-Item -Path $Path -ItemType Directory -Force # -ErrorAction Ignore | Out-Null + } + + if (-not (Test-Path -PathType Container $Path)) { + throw "Failed to create directory: $Path" + } + } catch { + throw "Failed to create directory: $Path. $_" + } +} + +function Create-VMCredential { + param ( + [Parameter(Mandatory=$True)][string]$VmUsername, + [Parameter(Mandatory=$True)][string]$VmPassword + ) + + try { + $secureVmPassword = ConvertTo-SecureString $VmPassword -AsPlainText -Force + return New-Object System.Management.Automation.PSCredential($VmUsername, $secureVmPassword) + } catch { + throw "Failed to create VM credential: $_" + } +} + +function Replace-PlaceholderStrings { + param ( + [Parameter(Mandatory=$True)][string]$FilePath, + [Parameter(Mandatory=$True)][string]$SearchString, + [Parameter(Mandatory=$True)][string]$ReplaceString + ) + + try { + $content = Get-Content -Path $FilePath + $content = $content -replace $SearchString, $ReplaceString + Set-Content -Path $FilePath -Value $content + } catch { + throw "Failed to replace placeholder strings in file: $FilePath. Error: $_" + } +} + +function Execute-CommandOnVM { + param ( + [Parameter(Mandatory=$True)][string]$VMName, + [Parameter(Mandatory=$True)][System.Management.Automation.PSCredential]$VmCredential, + [Parameter(Mandatory=$True)][string]$Command + ) + + try { + $result = Invoke-Command -VMName $VMName -Credential $VmCredential -ScriptBlock { + param($Command) + Invoke-Expression $Command + } -ArgumentList $Command + + Log-Message -Message "Executed command on VM: $VMName. Command: $Command. Result: $result" + } catch { + throw "Failed to execute command on VM: $VMName. Error: $_" + } +} + +function Wait-ForVMReady { + param ( + [Parameter(Mandatory=$True)][string]$VMName, + [Parameter(Mandatory=$True)][System.Management.Automation.PSCredential]$VmCredential, + [Parameter(Mandatory=$False)][int]$TimeoutInMinutes=30 + ) + + # Attempt for a maximum of 30 minutes + $limit = (Get-Date).AddMinutes($TimeoutInMinutes) + while ((Get-Date) -le $limit) { + try { + # Ensure the VM is in running state + while ((Get-VM -Name $VMName).State -ne 'Running') { + Log-Message -Message "Waiting for $VMName to reach running state..." + Start-Sleep -Seconds 5 + } + + # Trivial command to ensure that we can connect to the VM. + try { + Execute-CommandOnVM -VMName $VMName -VmCredential $VmCredential -Command 'hostname' + } catch { + Log-Message -Message "Failed to connect to $VMName. Retrying..." + Start-Sleep -Seconds 5 + continue + } + + Log-Message -Message "Successfully connected to $VMName" + return + } catch { + # Do nothing. We will retry if we failed to connect to the VM. + } + + Log-Message -Message "Failed to connect to $VMName. Retrying..." + Start-Sleep -Seconds 5 + } + + # If we reached here, we failed to connect to the VM. + throw "Failed to connect to $VMName after timeout..." +} + +function Update-VM { + param ( + [Parameter(Mandatory=$True)][string]$VMName, + [Parameter(Mandatory=$True)][System.Management.Automation.PSCredential]$VmCredential + ) + +# TODO debugging output - remove later + Get-VMNetworkAdapter -All + try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "ipconfig /all" } catch { Log-Message -Message "Failed to query IP config: $_" -ForegroundColor Red } + + try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Invoke-WebRequest bing.com" } catch { Log-Message -Message "Failed to connect to the internet: $_" -ForegroundColor Red } + + try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-PackageProvider -Name NuGet -Force" } catch { Log-Message -Message "Failed to install NuGet provider: $_" -ForegroundColor Red } + try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-Module -Name PSWindowsUpdate -Force" } catch { Log-Message -Message "Failed to install PSWindowsUpdate module: $_" -ForegroundColor Red } + try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Get-WindowsUpdate -Install -AcceptAll -AutoReboot" } catch { Log-Message -Message "Failed to install updates: $_" -ForegroundColor Red } + + Sleep -Seconds 300 # Sleep for 5 minutes to let the VM start fetching updates, etc... + Wait-ForVMReady -VMName $VMName -VmCredential $VmCredential + Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green +} + +function Create-VM { + param( + [Parameter(Mandatory=$True)][string]$VmName, + [Parameter(Mandatory=$True)][string]$VmUsername, + [Parameter(Mandatory=$True)][string]$VmPassword, + [Parameter(Mandatory=$True)][string]$VhdPath, + [Parameter(Mandatory=$True)][string]$VmStoragePath, + [Parameter(Mandatory=$True)][string]$ExternalVMSwitchName, + [Parameter(Mandatory=$True)][Int64]$MemoryStartupBytes, + [Parameter(Mandatory=$True)][string]$UnattendPath + ) + + try { + ## Check for any pre-requisites + # Check that the External Switch exists + $externalSwitches = Get-VMSwitch -SwitchType External + if ($externalSwitches -eq $null) { + throw "No external switches found" + } + + # Check that the VHD exists + if (-not (Test-Path -Path $VhdPath)) { + throw "VHD not found at $VhdPath" + } + + ## Create the VM + # Create storage directory for the VM + Create-DirectoryIfNotExists -Path $VmStoragePath + + # Move the VHD to the path + Log-Message "Moving $VhdPath to $VmStoragePath" + Move-Item -Path $VhdPath -Destination $VmStoragePath -Force + $VmVhdPath = Join-Path -Path $VmStoragePath -ChildPath (Split-Path -Path $VhdPath -Leaf) + + # Move unattend to the path + Log-Message "Moving $UnattendPath file to $VmStoragePath" + Move-Item -Path $UnattendPath -Destination $VmStoragePath -Force + $VmUnattendPath = Join-Path -Path $VmStoragePath -ChildPath (Split-Path -Path $UnattendPath -Leaf) + Replace-PlaceholderStrings -FilePath $VmUnattendPath -SearchString 'PLACEHOLDER_USERNAME' -ReplaceString $VmUsername + Replace-PlaceholderStrings -FilePath $VmUnattendPath -SearchString 'PLACEHOLDER_PASSWORD' -ReplaceString $VmPassword + + # Configure the VHD with the unattend file. + Log-Message "Mounting VHD and applying unattend file" + $VmMountPath = Join-Path -Path $VmStoragePath -ChildPath 'mountedVhd' + if (-not (Test-Path -Path $VmMountPath)) { + New-Item -ItemType Directory -Path $VmMountPath + } + Mount-WindowsImage -ImagePath $VmVhdPath -Index 1 -Path $VmMountPath -ErrorAction Stop | Out-Null + Copy-Item -Path $VmUnattendPath -Destination $VmMountPath\Unattend.xml + Apply-WindowsUnattend -Path $VmMountPath -UnattendPath $VmMountPath\Unattend.xml -ErrorAction Stop | Out-Null + Dismount-WindowsImage -Path $VmMountPath -Save -ErrorAction Stop + + # Create the VM + Log-Message "Creating the VM" + New-VM -Name $VmName -MemoryStartupBytes $MemoryStartupBytes -VhdPath $VmVhdPath # -SwitchName $ExternalVMSwitchName + foreach ($switch in $externalSwitches) { + Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" + Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name + } + + if ((Get-VM -VMName $vmName) -eq $null) { + throw "Failed to create VM: $VMName" + } + + Log-Message -Message "Successfully created VM: $VMName" -ForegroundColor Green + } catch { + throw "Failed to create VM: $VmName. Error: $_" + } +} + +function Configure-VM { + param( + [Parameter(Mandatory=$True)][string]$VmName, + [Parameter(Mandatory=$True)][string]$VmUsername, + [Parameter(Mandatory=$True)][string]$VmPassword, + [Parameter(Mandatory=$True)][int]$CpuCount, + [Parameter(Mandatory=$False)][string]$VMWorkingDirectory='C:\ebpf_cicd', + [Parameter(Mandatory=$False)][string]$VMSetupScript='.\configure_vm.ps1' + ) + + try { + Log-Message "Configuring VM: $VmName" + + # Post VM creation configuration steps. + Log-Message "Setting VM processor count to $CpuCount" + Set-VMProcessor -VMName $VmName -Count $CpuCount + Log-Message "Enabling Guest Service Interface" + Enable-VMIntegrationService -VMName $VMName -Name 'Guest Service Interface' + + # Get the VM credential + $VmCredential = Create-VMCredential -VmUsername $VmUsername -VmPassword $VmPassword + + # Start the VM + Log-Message "Starting VM: $VmName" + Start-VM -Name $VmName + Wait-ForVMReady -VMName $VmName -VmCredential $VmCredential + + Log-Message "Sleeping for 1 minute to let the VM get into a steady state" + Sleep -Seconds 60 # Sleep for 1 minute to let the VM get into a steady state. + + # Fetch all updates on the VM + Log-Message "Fetching Updates on the VM" + Update-VM -VMName $VmName -VmCredential $VmCredential + Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green + + # Copy setup script to the VM and execute it. + Log-Message "Executing VM configuration script ($VMSetupScript) on VM: $VmName" + Copy-VMFile -VMName $VmName -FileSource Host -SourcePath $VMSetupScript -DestinationPath "$VMWorkingDirectory\$VMSetupScript" -CreateFullPath + Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "cd $VMWorkingDirectory; .\$VMSetupScript" + Log-Message -Message "Successfully executed VM configuration script ($VMSetupScript) on VM: $VmName" -ForegroundColor Green + + Wait-ForVMReady -VMName $VmName -VmCredential $VmCredential + + # Checkpoint the VM. + Log-Message "Checkpointing VM: $VmName" + Checkpoint-VM -Name $VMName -SnapshotName 'baseline' + Log-Message -Message "Successfully added 'baseline' checkpoint for VM: $VMName" -ForegroundColor Green + + # Export the configured VHD. + # TODO - set the path... + # Export-VM -Name $VMName -Path "$VMWorkingDirectory\$VMName.vhd" + # Log-Message -Message "Successfully exported VM: $VMName to $VMWorkingDirectory\$VMName.vhd" -ForegroundColor Green + } catch { + throw "Failed to configure VM: $VmName. Error: $_" + } +} + +########## Helpers for the host machine ########## +function Install-HyperVIfNeeded { + try { + if ((Get-WindowsFeature -Name 'Hyper-V').Installed) { + Log-Message -Message 'Hyper-V is already installed on this host' + } else { + Log-Message -Message 'Hyper-V is not installed on this host. Installing now...' + + Import-Module ServerManager + Install-WindowsFeature -Name 'Hyper-V' -IncludeManagementTools + Restart-Computer -Force + exit 1 + } + } catch { + throw "Failed to install Hyper-V: $_" + } +} + +function Create-ExternalSwitchIfNeeded { + param ( + [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch' + ) + try { + # Check to see if an external switch already exists + $ExternalSwitches = (Get-VMSwitch -SwitchType External) + if ($ExternalSwitches -ne $null) { + Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" + return + } + + # Try to create the external switch + $NetAdapterNames = (Get-NetAdapter -Name 'Ethernet*' | Where-Object { $_.Status -eq 'Up' }).Name + $index = 0 + foreach ($NetAdapterName in $NetAdapterNames) { + try { + if ([string]::IsNullOrEmpty($NetAdapterName)) { + continue + } + $switchName = $ExternalSwitchName + '-' + $index + Log-Message "Attempting to creating external switch: $switchName with NetAdapter: $NetAdapterName" + New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true + # break + } catch { + Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName $_" + } + } + } catch { + throw "Failed to create external switch: $_" + } +} diff --git a/1es/unattend.xml b/1es/unattend.xml new file mode 100644 index 0000000000..27515d26ff --- /dev/null +++ b/1es/unattend.xml @@ -0,0 +1,52 @@ + + + + + + + + true + true + true + true + true + true + true + + + + PLACEHOLDER_PASSWORD + true</PlainText> + </AdministratorPassword> + <LocalAccounts> + <LocalAccount> + <Password> + <Value>PLACEHOLDER_PASSWORD</Value> + <PlainText>true</PlainText> + </Password> + <Description>Standard User Account</Description> + <DisplayName>VMStandardUser</DisplayName> + <Name>VMStandardUser</Name> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <AutoLogon> + <Password> + <Value>PLACEHOLDER_PASSWORD</Value> + <PlainText>true</PlainText> + </Password> + <Enabled>true</Enabled> + <LogonCount>9999</LogonCount> + <Username>PLACEHOLDER_USERNAME</Username> + </AutoLogon> + </component> + </settings> + <!-- <settings pass="specialize"> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <ComputerName>%ComputerNamePlaceholder%</ComputerName> + <DoNotCleanTaskBar>true</DoNotCleanTaskBar> + </component> + </settings> --> +</unattend> From 2883f2e11786b87c7ee4263dc522e727c92616cd Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 12 Nov 2024 14:33:56 -0800 Subject: [PATCH 11/91] Try without exteranl switch --- 1es/Setup.ps1 | 4 +++ 1es/Setup_orig.ps1 | 18 ++++++------- 1es/artifacts.json | 35 +------------------------- 1es/configure_vm.ps1 | 11 ++++---- 1es/prepare_host.ps1 | 12 --------- 1es/prepare_vm_helpers.psm1 | 50 ++++++++++++++++++------------------- 6 files changed, 45 insertions(+), 85 deletions(-) delete mode 100644 1es/prepare_host.ps1 diff --git a/1es/Setup.ps1 b/1es/Setup.ps1 index 9b3994cd04..70ef1753a1 100644 --- a/1es/Setup.ps1 +++ b/1es/Setup.ps1 @@ -27,3 +27,7 @@ Log-Message -Message "Network adapters: $names" $switches = Get-VMSwitch Log-Message -Message "VM switches: $switches" + + + +# TODO - eventually, setup_orig will become setup.ps1 \ No newline at end of file diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 9ef71a2100..e83c9c7e88 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -19,15 +19,15 @@ $ErrorActionPreference = "Stop" # Import helper functions Import-Module .\prepare_vm_helpers.psm1 -Force -Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName -$ExternalSwitches = Get-VMSwitch -SwitchType External -if (-not $ExternalSwitches) { - throw "No external switches found" -} -foreach ($switch in $ExternalSwitches) { - Log-Message "External switch: $switch" - Log-Message "External switch: $($switch.Name)" -} +# Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName +# $ExternalSwitches = Get-VMSwitch -SwitchType External +# if (-not $ExternalSwitches) { +# throw "No external switches found" +# } +# foreach ($switch in $ExternalSwitches) { +# Log-Message "External switch: $switch" +# Log-Message "External switch: $($switch.Name)" +# } if (-not (Test-Path -Path $BaseUnattendPath)) { throw "Unattend file not found at $BaseUnattendPath" diff --git a/1es/artifacts.json b/1es/artifacts.json index 2eb447c1eb..0acb5a104b 100644 --- a/1es/artifacts.json +++ b/1es/artifacts.json @@ -1,41 +1,8 @@ { "license":["Copyright (c) eBPF for Windows contributors", "SPDX-License-Identifier: MIT"], "artifacts": [ - { - "name": "windows-bcdedit-testsigning", - "parameters": { - "TestSigningOption": "On" - } - }, { "name": "windows-server-install-feature-hyperv" - }, - { - "name": "windows-HyperV-NewVMSwitch", - "parameters" : { - "VMSwitchName": "VMExternalSwitch" - } - }, - { - "name": "windows-gitinstall", - "parameters": { - "SetCredHelper": "false" - } } ] -} - - - { - "name": "windows-vcredist-x64" - } - -https://dev.azure.com/devdiv/XlabImageFactory/_git/XlabImageFactory?path=%2Fartifacts -/artifacts/windows-server-install-feature-hyperv/windows-server-install-feature-hyperv.ps1 -\ - -/artifacts/windows-HyperV-NewVMSwitch/windows-HyperV-NewVMSwitch.ps1 - - - -/artifacts/Windows-NestedVirtualization/Windows-NestedVirtualization.ps1 \ No newline at end of file +} \ No newline at end of file diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 index a9d4481444..81db964d46 100644 --- a/1es/configure_vm.ps1 +++ b/1es/configure_vm.ps1 @@ -97,12 +97,13 @@ New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Na # Enable driver verifier on the eBPF platform drivers. verifier /standard /bootmode persistent /driver ebpfcore.sys netebpfext.sys sample_ebpf_ext.sys -# Install duonic and configure it. -Get-Duonic -Initialize-NetworkInterfacesOnVMs +# TODO - this will either need to be done post VM creation, or run on the host and copied into the VM +# # Install duonic and configure it. +# Get-Duonic +# Initialize-NetworkInterfacesOnVMs -# Get PSExec to run tests as SYSTEM. -Get-PSExec +# # Get PSExec to run tests as SYSTEM. +# Get-PSExec # Reboot the machine to apply the changes. Restart-Computer -Force \ No newline at end of file diff --git a/1es/prepare_host.ps1 b/1es/prepare_host.ps1 deleted file mode 100644 index 1ea39fe6e4..0000000000 --- a/1es/prepare_host.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) eBPF for Windows contributors -# SPDX-License-Identifier: MIT -param( - [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch' -) - -Import-Module .\prepare_vm_helpers.psm1 -Force - -Install-HyperVIfNeeded -Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName - -# TODO - Fetch VHDs \ No newline at end of file diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 3404f90d4d..26b97cc37d 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -121,26 +121,26 @@ function Wait-ForVMReady { throw "Failed to connect to $VMName after timeout..." } -function Update-VM { - param ( - [Parameter(Mandatory=$True)][string]$VMName, - [Parameter(Mandatory=$True)][System.Management.Automation.PSCredential]$VmCredential - ) +# function Update-VM { +# param ( +# [Parameter(Mandatory=$True)][string]$VMName, +# [Parameter(Mandatory=$True)][System.Management.Automation.PSCredential]$VmCredential +# ) -# TODO debugging output - remove later - Get-VMNetworkAdapter -All - try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "ipconfig /all" } catch { Log-Message -Message "Failed to query IP config: $_" -ForegroundColor Red } +# # TODO debugging output - remove later +# Get-VMNetworkAdapter -All +# try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "ipconfig /all" } catch { Log-Message -Message "Failed to query IP config: $_" -ForegroundColor Red } - try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Invoke-WebRequest bing.com" } catch { Log-Message -Message "Failed to connect to the internet: $_" -ForegroundColor Red } +# try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Invoke-WebRequest bing.com" } catch { Log-Message -Message "Failed to connect to the internet: $_" -ForegroundColor Red } - try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-PackageProvider -Name NuGet -Force" } catch { Log-Message -Message "Failed to install NuGet provider: $_" -ForegroundColor Red } - try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-Module -Name PSWindowsUpdate -Force" } catch { Log-Message -Message "Failed to install PSWindowsUpdate module: $_" -ForegroundColor Red } - try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Get-WindowsUpdate -Install -AcceptAll -AutoReboot" } catch { Log-Message -Message "Failed to install updates: $_" -ForegroundColor Red } +# try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-PackageProvider -Name NuGet -Force" } catch { Log-Message -Message "Failed to install NuGet provider: $_" -ForegroundColor Red } +# try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Install-Module -Name PSWindowsUpdate -Force" } catch { Log-Message -Message "Failed to install PSWindowsUpdate module: $_" -ForegroundColor Red } +# try { Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "Get-WindowsUpdate -Install -AcceptAll -AutoReboot" } catch { Log-Message -Message "Failed to install updates: $_" -ForegroundColor Red } - Sleep -Seconds 300 # Sleep for 5 minutes to let the VM start fetching updates, etc... - Wait-ForVMReady -VMName $VMName -VmCredential $VmCredential - Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green -} +# Sleep -Seconds 300 # Sleep for 5 minutes to let the VM start fetching updates, etc... +# Wait-ForVMReady -VMName $VMName -VmCredential $VmCredential +# Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green +# } function Create-VM { param( @@ -157,10 +157,10 @@ function Create-VM { try { ## Check for any pre-requisites # Check that the External Switch exists - $externalSwitches = Get-VMSwitch -SwitchType External - if ($externalSwitches -eq $null) { - throw "No external switches found" - } + # $externalSwitches = Get-VMSwitch -SwitchType External + # if ($externalSwitches -eq $null) { + # throw "No external switches found" + # } # Check that the VHD exists if (-not (Test-Path -Path $VhdPath)) { @@ -197,10 +197,10 @@ function Create-VM { # Create the VM Log-Message "Creating the VM" New-VM -Name $VmName -MemoryStartupBytes $MemoryStartupBytes -VhdPath $VmVhdPath # -SwitchName $ExternalVMSwitchName - foreach ($switch in $externalSwitches) { - Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" - Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name - } + # foreach ($switch in $externalSwitches) { + # Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" + # Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name + # } if ((Get-VM -VMName $vmName) -eq $null) { throw "Failed to create VM: $VMName" @@ -244,7 +244,7 @@ function Configure-VM { # Fetch all updates on the VM Log-Message "Fetching Updates on the VM" - Update-VM -VMName $VmName -VmCredential $VmCredential + # Update-VM -VMName $VmName -VmCredential $VmCredential Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green # Copy setup script to the VM and execute it. From 8f90e6eb2e436e85bc4224c30a15e2463941a646 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 08:30:57 -0800 Subject: [PATCH 12/91] WIP --- scripts/cleanup_ebpf_cicd_tests.ps1 | 9 ++- scripts/common.psm1 | 16 ++++- scripts/execute_ebpf_cicd_tests.ps1 | 10 ++- scripts/setup_ebpf_cicd_tests.ps1 | 19 +++--- scripts/test_execution.json | 100 +--------------------------- 5 files changed, 41 insertions(+), 113 deletions(-) diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index 148979cf1d..2dd2e42f6f 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -7,13 +7,16 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", [parameter(Mandatory=$false)][string] $WorkingDirectory = $pwd.ToString(), [parameter(Mandatory=$false)][string] $TestExecutionJsonFileName = "test_execution.json", [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60)) + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60), + [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", + [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" + ) Push-Location $WorkingDirectory Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue - -$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop +$SelfHostedRunnerName = "runner_host" +$TestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/common.psm1 b/scripts/common.psm1 index 44408f4780..eadb97b646 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -111,4 +111,18 @@ function Wait-TestJobToComplete $JobOutput | ForEach-Object { Write-Host $_ } return $JobTimedOut -} \ No newline at end of file +} + +function Create-VMCredential { + param ( + [Parameter(Mandatory=$True)][string]$VmUsername, + [Parameter(Mandatory=$True)][string]$VmPassword + ) + + try { + $secureVmPassword = ConvertTo-SecureString $VmPassword -AsPlainText -Force + return New-Object System.Management.Automation.PSCredential($VmUsername, $secureVmPassword) + } catch { + throw "Failed to create VM credential: $_" + } +} diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index 540cfd5fd0..fcca934c4a 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -11,15 +11,19 @@ param ([Parameter(Mandatory = $false)][string] $AdminTarget = "TEST_VM", [Parameter(Mandatory = $false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), [Parameter(Mandatory = $false)][int] $TestHangTimeout = (10*60), [Parameter(Mandatory = $false)][string] $UserModeDumpFolder = "C:\Dumps", - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (60*60) + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (60*60), + [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", + [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" ) Push-Location $WorkingDirectory Import-Module $WorkingDirectory\common.psm1 -Force -ArgumentList ($LogFileName) -ErrorAction Stop -$AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction Stop -$StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop +# TODO - figure out admin vs standard user +$SelfHostedRunnerName = "runner_host" +$AdminTestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword +$StandardUserTestVMCredential = Create-VMCredential -VmUsername 'VMStandardUser' -VmPassword $VMPassword # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index f2d715fc5b..2c6dc7a3c4 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -10,15 +10,18 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", [parameter(Mandatory=$false)][string] $RegressionArtifactsVersion = "", [parameter(Mandatory=$false)][string] $RegressionArtifactsConfiguration = "", [parameter(Mandatory=$false)][string] $TestExecutionJsonFileName = "test_execution.json", - [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60)) + [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = "runner_host" + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60), + [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", + [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" + ) Push-Location $WorkingDirectory -$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop - # Load other utility modules. Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue +$SelfHostedRunnerName = "runner_host" +$TestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword Import-Module .\config_test_vm.psm1 -Force -ArgumentList ($TestVMCredential.UserName, $TestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue # Read the test execution json. @@ -27,10 +30,10 @@ $VMList = $Config.VMMap.$SelfHostedRunnerName # Delete old log files if any. Remove-Item "$env:TEMP\$LogFileName" -ErrorAction SilentlyContinue -foreach($VM in $VMList) { - $VMName = $VM.Name - Remove-Item $env:TEMP\$LogFileName -ErrorAction SilentlyContinue -} +# foreach($VM in $VMList) { +# $VMName = $VM.Name +# Remove-Item $env:TEMP\$LogFileName -ErrorAction SilentlyContinue +# } Remove-Item ".\TestLogs" -Recurse -Confirm:$false -ErrorAction SilentlyContinue if ($TestMode -eq "Regression") { diff --git a/scripts/test_execution.json b/scripts/test_execution.json index 779f47e643..ffa9f24949 100644 --- a/scripts/test_execution.json +++ b/scripts/test_execution.json @@ -3,106 +3,10 @@ "VMMap": { - "TK5-3WP08R0904_WS2019_1": + "runner_host" : [ { - "Name": "vm1_ws2019" - } - ], - "TK5-3WP08R0904_WS2019_2": - [ - { - "Name": "vm2_ws2019" - } - ], - "TK5-3WP08R0907_WS2019_1": - [ - { - "Name": "vm1_ws2019" - } - ], - "TK5-3WP08R0907_WS2019_2": - [ - { - "Name": "vm2_ws2019" - } - ], - "TK5-3WP07R0703_WS2019_1": - [ - { - "Name": "vm1_ws2019" - } - ], - "TK5-3WP07R0703_WS2019_2": - [ - { - "Name": "vm2_ws2019" - } - ], - "TK5-3WP07R0703_WS2019_3": - [ - { - "Name": "vm3_ws2019" - } - ], - "TK5-3WP07R0703_WS2019_4": - [ - { - "Name": "vm4_ws2019" - } - ], - "TK5-3WP07R0703_WS2022_1": - [ - { - "Name": "vm1_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_2": - [ - { - "Name": "vm2_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_3": - [ - { - "Name": "vm3_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_4": - [ - { - "Name": "vm4_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_5": - [ - { - "Name": "vm5_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_6": - [ - { - "Name": "vm6_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_7": - [ - { - "Name": "vm7_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_8": - [ - { - "Name": "vm8_ws2022" - } - ], - "TK5-3WP07R0703_WS2022_PERF_1": - [ - { - "Name": "vm_perf_ws2022" + "Name": "runner_vm" } ] }, From 499579ad4da7b412aef7766c66126b1bf3918ecf Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 09:12:10 -0800 Subject: [PATCH 13/91] WIP --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index baac9ec77c..6f9afca8d7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -55,7 +55,7 @@ jobs: build_msi: true build_nuget: true build_options: /p:ReleaseJIT='True' - configurations: '["Release"]' + configurations: '["Debug", "Release"]' # Run the driver tests on self-hosted runners. driver_ws2019: From 751a452094447a40ea385f0eb0d800a6627ee6d0 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 09:51:50 -0800 Subject: [PATCH 14/91] fix --- scripts/setup_ebpf_cicd_tests.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index 2c6dc7a3c4..58b9e9d0b9 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -10,11 +10,11 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", [parameter(Mandatory=$false)][string] $RegressionArtifactsVersion = "", [parameter(Mandatory=$false)][string] $RegressionArtifactsConfiguration = "", [parameter(Mandatory=$false)][string] $TestExecutionJsonFileName = "test_execution.json", - [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = "runner_host" + [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60), [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" - ) + ) Push-Location $WorkingDirectory @@ -30,10 +30,6 @@ $VMList = $Config.VMMap.$SelfHostedRunnerName # Delete old log files if any. Remove-Item "$env:TEMP\$LogFileName" -ErrorAction SilentlyContinue -# foreach($VM in $VMList) { -# $VMName = $VM.Name -# Remove-Item $env:TEMP\$LogFileName -ErrorAction SilentlyContinue -# } Remove-Item ".\TestLogs" -Recurse -Confirm:$false -ErrorAction SilentlyContinue if ($TestMode -eq "Regression") { From 993f2d44ea46deb0bfb08cc1de6ad6e4af4d021a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 12:13:25 -0800 Subject: [PATCH 15/91] WIP --- 1es/Setup_orig.ps1 | 20 +---- 1es/prepare_vm_helpers.psm1 | 112 ++++++++++++++++++---------- scripts/cleanup_ebpf_cicd_tests.ps1 | 8 +- scripts/config_test_vm.psm1 | 2 + scripts/execute_ebpf_cicd_tests.ps1 | 9 +-- scripts/setup_ebpf_cicd_tests.ps1 | 10 +-- 6 files changed, 88 insertions(+), 73 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index e83c9c7e88..7dd02de306 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT param( [Parameter(Mandatory=$False)][string]$VmUsername='Administrator', + [Parameter(Mandatory=$False)][string]$VmStandardUserName='VMStandardUser', [Parameter(Mandatory=$False)][string]$VmPassword='P@ssw0rd', [Parameter(Mandatory=$False)][string]$BaseUnattendPath='.\unattend.xml', @@ -19,16 +20,6 @@ $ErrorActionPreference = "Stop" # Import helper functions Import-Module .\prepare_vm_helpers.psm1 -Force -# Create-ExternalSwitchIfNeeded -ExternalSwitchName $ExternalSwitchName -# $ExternalSwitches = Get-VMSwitch -SwitchType External -# if (-not $ExternalSwitches) { -# throw "No external switches found" -# } -# foreach ($switch in $ExternalSwitches) { -# Log-Message "External switch: $switch" -# Log-Message "External switch: $($switch.Name)" -# } - if (-not (Test-Path -Path $BaseUnattendPath)) { throw "Unattend file not found at $BaseUnattendPath" } @@ -37,14 +28,11 @@ if (-not (Test-Path -Path $BaseVhdDirPath)) { throw "VHD directory not found at $BaseVhdDirPath" } +Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType Internal +Create-VMStoredCredential -CredentialName "TEST_VM" -Username $VmUsername -Password $VmPassword +Create-VMStoredCredential -CredentialName "TEST_VM_STANDARD" -Username $VmStandardUserName -Password $VmPassword Create-DirectoryIfNotExists -Path $WorkingPath -# Create-DirectoryIfNotExists -Path $OutVhdDirPath - -# Create credential object for executing commands on the VM -# TODO - maybe this can be read from the unattend file? Or passed as an azure parameter, which replaces in the unattend file. -# $vmCredential = Create-VMCredential -VmUsername $VmUsername -VmPassword $VmPassword - # Read the input VHDs $vhds = @((Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhd)) $vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhdx diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 26b97cc37d..f01b550fb1 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -156,12 +156,6 @@ function Create-VM { try { ## Check for any pre-requisites - # Check that the External Switch exists - # $externalSwitches = Get-VMSwitch -SwitchType External - # if ($externalSwitches -eq $null) { - # throw "No external switches found" - # } - # Check that the VHD exists if (-not (Test-Path -Path $VhdPath)) { throw "VHD not found at $VhdPath" @@ -196,11 +190,12 @@ function Create-VM { # Create the VM Log-Message "Creating the VM" - New-VM -Name $VmName -MemoryStartupBytes $MemoryStartupBytes -VhdPath $VmVhdPath # -SwitchName $ExternalVMSwitchName - # foreach ($switch in $externalSwitches) { - # Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" - # Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name - # } + New-VM -Name $VmName -MemoryStartupBytes $MemoryStartupBytes -VhdPath $VmVhdPath + $vmSwitches = Get-VMSwitch + foreach ($switch in $vmSwitches) { + Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" + Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name + } if ((Get-VM -VMName $vmName) -eq $null) { throw "Failed to create VM: $VMName" @@ -255,15 +250,18 @@ function Configure-VM { Wait-ForVMReady -VMName $VmName -VmCredential $VmCredential - # Checkpoint the VM. - Log-Message "Checkpointing VM: $VmName" - Checkpoint-VM -Name $VMName -SnapshotName 'baseline' - Log-Message -Message "Successfully added 'baseline' checkpoint for VM: $VMName" -ForegroundColor Green - - # Export the configured VHD. - # TODO - set the path... - # Export-VM -Name $VMName -Path "$VMWorkingDirectory\$VMName.vhd" - # Log-Message -Message "Successfully exported VM: $VMName to $VMWorkingDirectory\$VMName.vhd" -ForegroundColor Green + # Checkpoint the VM. This can sometimes fail if other operations are in progress. + for ($i = 0; $i -lt 5; $i += 1) { + try { + Log-Message "Checkpointing VM: $VmName" + Checkpoint-VM -Name $VMName -SnapshotName 'baseline' + Log-Message -Message "Successfully added 'baseline' checkpoint for VM: $VMName" -ForegroundColor Green + } catch { + Log-Message "Failed to checkpoint VM: $VmName. Retrying..." + Start-Sleep -Seconds 5 + continue + } + } } catch { throw "Failed to configure VM: $VmName. Error: $_" } @@ -287,35 +285,67 @@ function Install-HyperVIfNeeded { } } -function Create-ExternalSwitchIfNeeded { +function Create-VMSwitchIfNeeded { param ( - [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch' + [Parameter(Mandatory=$False)][string]$SwitchName='VMInternalSwitch', + [Parameter(Mandatory=$False)][string]$SwitchType='Internal' ) try { - # Check to see if an external switch already exists - $ExternalSwitches = (Get-VMSwitch -SwitchType External) - if ($ExternalSwitches -ne $null) { - Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" - return - } + if ($SwitchType -eq 'External') { + # Check to see if an external switch already exists + $ExternalSwitches = (Get-VMSwitch -SwitchType External) + if ($ExternalSwitches -ne $null) { + Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" + return + } - # Try to create the external switch - $NetAdapterNames = (Get-NetAdapter -Name 'Ethernet*' | Where-Object { $_.Status -eq 'Up' }).Name - $index = 0 - foreach ($NetAdapterName in $NetAdapterNames) { - try { - if ([string]::IsNullOrEmpty($NetAdapterName)) { - continue + # Try to create the external switch + $NetAdapterNames = (Get-NetAdapter -Name 'Ethernet*' | Where-Object { $_.Status -eq 'Up' }).Name + $index = 0 + foreach ($NetAdapterName in $NetAdapterNames) { + try { + if ([string]::IsNullOrEmpty($NetAdapterName)) { + continue + } + $switchName = $ExternalSwitchName + '-' + $index + Log-Message "Attempting to creating external switch: $switchName with NetAdapter: $NetAdapterName" + New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true + # break + } catch { + Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName $_" } - $switchName = $ExternalSwitchName + '-' + $index - Log-Message "Attempting to creating external switch: $switchName with NetAdapter: $NetAdapterName" - New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true - # break - } catch { - Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName $_" } + } elseif ($SwitchType -eq 'Internal') { + # Check to see if an internal switch already exists + $InternalSwitches = (Get-VMSwitch -SwitchType Internal) + if ($InternalSwitches -ne $null) { + Log-Message -Message "Internal switch already exists: $($InternalSwitches[0].Name)" + return + } + + # Try to create the internal switch + Log-Message "Creating internal switch" + New-VMSwitch -Name 'VMInternalSwitch' -SwitchType Internal + } else { + throw "Invalid switch type: $SwitchType" } } catch { throw "Failed to create external switch: $_" } } + +function Create-VMStoredCredential { + param ( + [Parameter(Mandatory=$True)][string]$CredentialName, + [Parameter(Mandatory=$True)][string]$Username, + [Parameter(Mandatory=$True)][string]$Password + ) + + try { + $secureVmPassword = ConvertTo-SecureString $Password -AsPlainText -Force + $vmCredential = New-Object System.Management.Automation.PSCredential($Username, $secureVmPassword) + $vmCredential | Export-StoredCredential -Target $CredentialName + } catch { + throw "Failed to create stored credential: $_" + } +} \ No newline at end of file diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index 2dd2e42f6f..fc5e25cf69 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -7,16 +7,14 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", [parameter(Mandatory=$false)][string] $WorkingDirectory = $pwd.ToString(), [parameter(Mandatory=$false)][string] $TestExecutionJsonFileName = "test_execution.json", [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60), - [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", - [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" - ) + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60)) Push-Location $WorkingDirectory Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue $SelfHostedRunnerName = "runner_host" -$TestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword +Write-Host "SelfHostedRunnerName: $SelfHostedRunnerName, Target: $Target" +$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index 83da88cd30..f08b907b1c 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -540,6 +540,8 @@ function Initialize-NetworkInterfacesOnVMs # Disable Duonic's fake checksum offload and force TCP/IP to calculate it. Set-NetAdapterAdvancedProperty duo? -DisplayName Checksum -RegistryValue 0 + ipconfig /all + Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop } diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index fcca934c4a..c4f163d3f7 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -11,9 +11,7 @@ param ([Parameter(Mandatory = $false)][string] $AdminTarget = "TEST_VM", [Parameter(Mandatory = $false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), [Parameter(Mandatory = $false)][int] $TestHangTimeout = (10*60), [Parameter(Mandatory = $false)][string] $UserModeDumpFolder = "C:\Dumps", - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (60*60), - [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", - [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (60*60) ) Push-Location $WorkingDirectory @@ -22,8 +20,9 @@ Import-Module $WorkingDirectory\common.psm1 -Force -ArgumentList ($LogFileName) # TODO - figure out admin vs standard user $SelfHostedRunnerName = "runner_host" -$AdminTestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword -$StandardUserTestVMCredential = Create-VMCredential -VmUsername 'VMStandardUser' -VmPassword $VMPassword +Write-Host "SelfHostedRunnerName: $SelfHostedRunnerName, AdminTarget: $AdminTarget, StandardUserTarget: $StandardUserTarget" +$AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction Stop +$StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index 58b9e9d0b9..d8d2d6af26 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -11,17 +11,15 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", [parameter(Mandatory=$false)][string] $RegressionArtifactsConfiguration = "", [parameter(Mandatory=$false)][string] $TestExecutionJsonFileName = "test_execution.json", [parameter(Mandatory=$false)][string] $SelfHostedRunnerName = [System.Net.Dns]::GetHostName(), - [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60), - [Parameter(Mandatory = $false)][string] $VMUserName="Administrator", - [Parameter(Mandatory = $false)][string] $VMPassword="P@ssw0rd" - ) + [Parameter(Mandatory = $false)][int] $TestJobTimeout = (30*60)) Push-Location $WorkingDirectory +$SelfHostedRunnerName = "runner_host" +$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop + # Load other utility modules. Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue -$SelfHostedRunnerName = "runner_host" -$TestVMCredential = Create-VMCredential -VmUsername $VMUserName -VmPassword $VMPassword Import-Module .\config_test_vm.psm1 -Force -ArgumentList ($TestVMCredential.UserName, $TestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue # Read the test execution json. From ada843cda111bb2c47564d2e97d8c13a9397f922 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 14:09:54 -0800 Subject: [PATCH 16/91] import cred manager --- 1es/prepare_vm_helpers.psm1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index f01b550fb1..abe2fb7b3c 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -340,11 +340,13 @@ function Create-VMStoredCredential { [Parameter(Mandatory=$True)][string]$Username, [Parameter(Mandatory=$True)][string]$Password ) - try { + Install-Module -Name CredentialManager -Scope AllUsers -Force + Import-Module CredentialManager -Force + $secureVmPassword = ConvertTo-SecureString $Password -AsPlainText -Force $vmCredential = New-Object System.Management.Automation.PSCredential($Username, $secureVmPassword) - $vmCredential | Export-StoredCredential -Target $CredentialName + New-StoredCredential -Target $CredentialName -Credential $vmCredential -Type Generic -Persist LocalMachine } catch { throw "Failed to create stored credential: $_" } From b63804aad2eb885aee815150d76a52b333173cb5 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 14:56:56 -0800 Subject: [PATCH 17/91] fixes --- 1es/prepare_vm_helpers.psm1 | 4 +--- scripts/common.psm1 | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index abe2fb7b3c..dc261ffc04 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -344,9 +344,7 @@ function Create-VMStoredCredential { Install-Module -Name CredentialManager -Scope AllUsers -Force Import-Module CredentialManager -Force - $secureVmPassword = ConvertTo-SecureString $Password -AsPlainText -Force - $vmCredential = New-Object System.Management.Automation.PSCredential($Username, $secureVmPassword) - New-StoredCredential -Target $CredentialName -Credential $vmCredential -Type Generic -Persist LocalMachine + New-StoredCredential -Target $CredentialName -UserName $Username -Password $Password } catch { throw "Failed to create stored credential: $_" } diff --git a/scripts/common.psm1 b/scripts/common.psm1 index eadb97b646..9428f66993 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -3,6 +3,8 @@ param ([parameter(Mandatory=$True)] [string] $LogFileName) +Import-Module CredentialManager -Force + # # Common helper functions. # From 874f75bfef1b6d05e6209f9a56806c68d555bafd Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 15:40:50 -0800 Subject: [PATCH 18/91] try with stored credential, but have workaround --- 1es/prepare_vm_helpers.psm1 | 5 +++-- scripts/cleanup_ebpf_cicd_tests.ps1 | 7 ++++++- scripts/execute_ebpf_cicd_tests.ps1 | 10 ++++++++-- scripts/setup_ebpf_cicd_tests.ps1 | 7 ++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index dc261ffc04..1f393d0032 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -344,8 +344,9 @@ function Create-VMStoredCredential { Install-Module -Name CredentialManager -Scope AllUsers -Force Import-Module CredentialManager -Force - New-StoredCredential -Target $CredentialName -UserName $Username -Password $Password + New-StoredCredential -Target $CredentialName -UserName $Username -Password $Password -Type Generic -Persist LocalMachine } catch { - throw "Failed to create stored credential: $_" + Log-Message "Failed to create stored credential: $_" -ForegroundColor Red + # throw "Failed to create stored credential: $_" } } \ No newline at end of file diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index fc5e25cf69..1e74f08454 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -14,7 +14,12 @@ Push-Location $WorkingDirectory Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue $SelfHostedRunnerName = "runner_host" Write-Host "SelfHostedRunnerName: $SelfHostedRunnerName, Target: $Target" -$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop +try { + $TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop +} catch { + Write-Host "Failed to get credentials for $Target. Using default credentials." + $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' +} # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index c4f163d3f7..09d0b3e0e4 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -21,8 +21,14 @@ Import-Module $WorkingDirectory\common.psm1 -Force -ArgumentList ($LogFileName) # TODO - figure out admin vs standard user $SelfHostedRunnerName = "runner_host" Write-Host "SelfHostedRunnerName: $SelfHostedRunnerName, AdminTarget: $AdminTarget, StandardUserTarget: $StandardUserTarget" -$AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction Stop -$StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop +try { + $AdminTestVMCredential = Get-StoredCredential -Target $AdminTarget -ErrorAction Stop + $StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop +} catch { + Write-Host "Failed to get credentials for $AdminTarget or $StandardUserTarget. Using default credentials." + $AdminTestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' + $StandardUserTestVMCredential = New-Credential -UserName 'VMStandardUser' -AdminPassword 'P@ssw0rd' +} # Read the test execution json. $Config = Get-Content ("{0}\{1}" -f $PSScriptRoot, $TestExecutionJsonFileName) | ConvertFrom-Json diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index d8d2d6af26..86d0cd45be 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -16,7 +16,12 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", Push-Location $WorkingDirectory $SelfHostedRunnerName = "runner_host" -$TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop +try { + $TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop +} catch { + Write-Host "Failed to get credentials for $Target. Using default credentials." + $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' +} # Load other utility modules. Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue From 36accbfaf6c0db013ef234dc0b5771ad663d397a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 16:27:40 -0800 Subject: [PATCH 19/91] fix --- scripts/common.psm1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/common.psm1 b/scripts/common.psm1 index 9428f66993..f89d088b70 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -3,7 +3,11 @@ param ([parameter(Mandatory=$True)] [string] $LogFileName) -Import-Module CredentialManager -Force +try { + Import-Module CredentialManager -Force +} catch { + Write-Host "Failed to import CredentialManager module. Using default credentials." +} # # Common helper functions. From 4f3e04897166154a2bf16160dc7e00425f476afb Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 13 Nov 2024 17:10:43 -0800 Subject: [PATCH 20/91] fixes --- 1es/Setup_orig.ps1 | 3 --- 1es/prepare_vm_helpers.psm1 | 1 + scripts/execute_ebpf_cicd_tests.ps1 | 1 - scripts/setup_ebpf_cicd_tests.ps1 | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 7dd02de306..2abd5ea34a 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -64,7 +64,4 @@ for ($i = 0; $i -lt $vhds.Count; $i++) { -CpuCount $VMCpuCount ` -VmUsername $VmUsername ` -VmPassword $VmPassword - - Export-VM -Name $vmName -Path $OutVhdDirPath - Log-Message -Message "Successfully exported VM: $VMName to $VMWorkingDirectory\$VMName.vhd" -ForegroundColor Green } diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 1f393d0032..aac41e96f5 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -256,6 +256,7 @@ function Configure-VM { Log-Message "Checkpointing VM: $VmName" Checkpoint-VM -Name $VMName -SnapshotName 'baseline' Log-Message -Message "Successfully added 'baseline' checkpoint for VM: $VMName" -ForegroundColor Green + break } catch { Log-Message "Failed to checkpoint VM: $VmName. Retrying..." Start-Sleep -Seconds 5 diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index 09d0b3e0e4..5af0a75830 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -18,7 +18,6 @@ Push-Location $WorkingDirectory Import-Module $WorkingDirectory\common.psm1 -Force -ArgumentList ($LogFileName) -ErrorAction Stop -# TODO - figure out admin vs standard user $SelfHostedRunnerName = "runner_host" Write-Host "SelfHostedRunnerName: $SelfHostedRunnerName, AdminTarget: $AdminTarget, StandardUserTarget: $StandardUserTarget" try { diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index 86d0cd45be..9f4bbbbb63 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -15,6 +15,8 @@ param ([parameter(Mandatory=$false)][string] $Target = "TEST_VM", Push-Location $WorkingDirectory +# Load other utility modules. +Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue $SelfHostedRunnerName = "runner_host" try { $TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop @@ -23,8 +25,6 @@ try { $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' } -# Load other utility modules. -Import-Module .\common.psm1 -Force -ArgumentList ($LogFileName) -WarningAction SilentlyContinue Import-Module .\config_test_vm.psm1 -Force -ArgumentList ($TestVMCredential.UserName, $TestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue # Read the test execution json. From 8c5803c7773bd2b4bc616bb5714bab95eaf34a51 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 14 Nov 2024 08:12:39 -0800 Subject: [PATCH 21/91] fixes --- scripts/cleanup_ebpf_cicd_tests.ps1 | 3 ++- scripts/execute_ebpf_cicd_tests.ps1 | 5 +++-- scripts/setup_ebpf_cicd_tests.ps1 | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index 1e74f08454..a379dfbbc9 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -18,7 +18,8 @@ try { $TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop } catch { Write-Host "Failed to get credentials for $Target. Using default credentials." - $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' + $securePassword = ConvertTo-SecureString -String "P@ssw0rd" -AsPlainText -Force + $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword $securePassword } # Read the test execution json. diff --git a/scripts/execute_ebpf_cicd_tests.ps1 b/scripts/execute_ebpf_cicd_tests.ps1 index 5af0a75830..82468d04b1 100644 --- a/scripts/execute_ebpf_cicd_tests.ps1 +++ b/scripts/execute_ebpf_cicd_tests.ps1 @@ -25,8 +25,9 @@ try { $StandardUserTestVMCredential = Get-StoredCredential -Target $StandardUserTarget -ErrorAction Stop } catch { Write-Host "Failed to get credentials for $AdminTarget or $StandardUserTarget. Using default credentials." - $AdminTestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' - $StandardUserTestVMCredential = New-Credential -UserName 'VMStandardUser' -AdminPassword 'P@ssw0rd' + $securePassword = ConvertTo-SecureString -String "P@ssw0rd" -AsPlainText -Force + $AdminTestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword $securePassword + $StandardUserTestVMCredential = New-Credential -UserName 'VMStandardUser' -AdminPassword $securePassword } # Read the test execution json. diff --git a/scripts/setup_ebpf_cicd_tests.ps1 b/scripts/setup_ebpf_cicd_tests.ps1 index 9f4bbbbb63..f5f2fa6d9b 100644 --- a/scripts/setup_ebpf_cicd_tests.ps1 +++ b/scripts/setup_ebpf_cicd_tests.ps1 @@ -22,7 +22,8 @@ try { $TestVMCredential = Get-StoredCredential -Target $Target -ErrorAction Stop } catch { Write-Host "Failed to get credentials for $Target. Using default credentials." - $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword 'P@ssw0rd' + $securePassword = ConvertTo-SecureString -String "P@ssw0rd" -AsPlainText -Force + $TestVMCredential = New-Credential -UserName 'Administrator' -AdminPassword $securePassword } Import-Module .\config_test_vm.psm1 -Force -ArgumentList ($TestVMCredential.UserName, $TestVMCredential.Password, $WorkingDirectory, $LogFileName) -WarningAction SilentlyContinue From 91e5f704be7effeb2bbba9b31cbb8bdba2116dbf Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 14 Nov 2024 08:51:31 -0800 Subject: [PATCH 22/91] WIP --- scripts/common.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/common.psm1 b/scripts/common.psm1 index f89d088b70..ea215cff72 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -4,7 +4,7 @@ param ([parameter(Mandatory=$True)] [string] $LogFileName) try { - Import-Module CredentialManager -Force + Import-Module CredentialManager -Force -ErrorAction Ignore } catch { Write-Host "Failed to import CredentialManager module. Using default credentials." } From 7c2a20714c6e839fa89271f56def3fd978eba6fa Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 14 Nov 2024 14:06:41 -0800 Subject: [PATCH 23/91] fix --- 1es/configure_vm.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 index 81db964d46..871c21de5d 100644 --- a/1es/configure_vm.ps1 +++ b/1es/configure_vm.ps1 @@ -105,5 +105,21 @@ verifier /standard /bootmode persistent /driver ebpfcore.sys netebpfext.sys samp # # Get PSExec to run tests as SYSTEM. # Get-PSExec +# Loop through each adapter and enable IPv4 and IPv6 +$adapters = Get-NetAdapter +foreach ($adapter in $adapters) { + try { + # Enable IPv4 (usually enabled by default) + Enable-NetAdapterBinding -Name $adapter.Name -ComponentID ms_tcpip + + # Enable IPv6 + Enable-NetAdapterBinding -Name $adapter.Name -ComponentID ms_tcpip6 + + Write-Host "Enabled IPv4 and IPv6 on adapter: $($adapter.Name)" + } catch { + Write-Host "Failed to enable IPv4 and IPv6 on adapter: $($adapter.Name)" + } +} + # Reboot the machine to apply the changes. Restart-Computer -Force \ No newline at end of file From b21f8c6ab5ec461fd204624acaeb1bc79d6c9296 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 15 Nov 2024 07:36:28 -0800 Subject: [PATCH 24/91] fix --- 1es/configure_vm.ps1 | 4 ++++ scripts/config_test_vm.psm1 | 3 +++ 2 files changed, 7 insertions(+) diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 index 871c21de5d..4254673e9b 100644 --- a/1es/configure_vm.ps1 +++ b/1es/configure_vm.ps1 @@ -121,5 +121,9 @@ foreach ($adapter in $adapters) { } } +ipconfig /all + +Get-NetIPInterface + # Reboot the machine to apply the changes. Restart-Computer -Force \ No newline at end of file diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index f08b907b1c..6d98d4c043 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -540,7 +540,10 @@ function Initialize-NetworkInterfacesOnVMs # Disable Duonic's fake checksum offload and force TCP/IP to calculate it. Set-NetAdapterAdvancedProperty duo? -DisplayName Checksum -RegistryValue 0 + # TODO - remove this debugging output ipconfig /all + Get-NetIPInterface + Get-NetAdapter Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop From 94dd3876191d7dbfc93569ebf414a657864667eb Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 15 Nov 2024 09:18:53 -0800 Subject: [PATCH 25/91] fix --- 1es/Setup_orig.ps1 | 3 ++- scripts/config_test_vm.psm1 | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 2abd5ea34a..3a09dba395 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -28,7 +28,8 @@ if (-not (Test-Path -Path $BaseVhdDirPath)) { throw "VHD directory not found at $BaseVhdDirPath" } -Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType Internal +Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType 'Internal' +Create-VMSwitchIfNeeded -SwitchName 'VMExternalSwitch' -SwitchType 'External' Create-VMStoredCredential -CredentialName "TEST_VM" -Username $VmUsername -Password $VmPassword Create-VMStoredCredential -CredentialName "TEST_VM_STANDARD" -Username $VmStandardUserName -Password $VmPassword Create-DirectoryIfNotExists -Path $WorkingPath diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index 6d98d4c043..dde9c18f11 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -542,8 +542,8 @@ function Initialize-NetworkInterfacesOnVMs # TODO - remove this debugging output ipconfig /all - Get-NetIPInterface - Get-NetAdapter + Get-NetIPInterface | fl * + Get-NetAdapter | fl * Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop From 59b867ea54890a6d946276c9ab342af685436557 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 10 Dec 2024 11:25:34 -0800 Subject: [PATCH 26/91] WIP --- 1es/configure_vm.ps1 | 2 ++ scripts/config_test_vm.psm1 | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 index 4254673e9b..32a1768c8d 100644 --- a/1es/configure_vm.ps1 +++ b/1es/configure_vm.ps1 @@ -121,6 +121,8 @@ foreach ($adapter in $adapters) { } } +Get-NetAdapterBinding -AllBindings + ipconfig /all Get-NetIPInterface diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index dde9c18f11..81f6fffcc0 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -544,6 +544,24 @@ function Initialize-NetworkInterfacesOnVMs ipconfig /all Get-NetIPInterface | fl * Get-NetAdapter | fl * + Get-NetAdapterBinding -AllBindings + + # Loop through each adapter and enable IPv4 and IPv6 + $adapters = Get-NetAdapter + foreach ($adapter in $adapters) { + try { + # Enable IPv4 (usually enabled by default) + Enable-NetAdapterBinding -Name $adapter.Name -ComponentID ms_tcpip + + # Enable IPv6 + Enable-NetAdapterBinding -Name $adapter.Name -ComponentID ms_tcpip6 + + Write-Host "Enabled IPv4 and IPv6 on adapter: $($adapter.Name)" + } catch { + Write-Host "Failed to enable IPv4 and IPv6 on adapter: $($adapter.Name)" + } + } + Get-NetAdapterBinding -AllBindings Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop From 03e5e33324dafc0d0e5c82e1619c573d2486e25a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 10 Dec 2024 14:11:10 -0800 Subject: [PATCH 27/91] WIP --- scripts/config_test_vm.psm1 | 8 ++++---- tests/libs/util/socket_helper.cpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index 81f6fffcc0..476c2a5680 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -542,9 +542,9 @@ function Initialize-NetworkInterfacesOnVMs # TODO - remove this debugging output ipconfig /all - Get-NetIPInterface | fl * - Get-NetAdapter | fl * - Get-NetAdapterBinding -AllBindings + Get-NetIPInterface | fl * | Out-String + Get-NetAdapter | fl * | Out-String + Get-NetAdapterBinding -AllBindings | fl * | Out-String # Loop through each adapter and enable IPv4 and IPv6 $adapters = Get-NetAdapter @@ -561,7 +561,7 @@ function Initialize-NetworkInterfacesOnVMs Write-Host "Failed to enable IPv4 and IPv6 on adapter: $($adapter.Name)" } } - Get-NetAdapterBinding -AllBindings + Get-NetAdapterBinding -AllBindings | fl * | Out-String Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop diff --git a/tests/libs/util/socket_helper.cpp b/tests/libs/util/socket_helper.cpp index 23338fcf09..e2fd5f224a 100644 --- a/tests/libs/util/socket_helper.cpp +++ b/tests/libs/util/socket_helper.cpp @@ -86,6 +86,8 @@ _base_socket::_base_socket( socket, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&ipv6_option), sizeof(unsigned long)); if (error != 0) { FAIL("Could not enable dual family endpoint: " << WSAGetLastError()); + } else { + printf("Dual family endpoint enabled\n"); } } From e96857dece75f5c121d1b14e5d5c1bfbfe0c5dae Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 10 Dec 2024 15:31:54 -0800 Subject: [PATCH 28/91] WIP --- 1es/Setup_orig.ps1 | 7 ++++--- 1es/prepare_vm_helpers.psm1 | 2 ++ scripts/cleanup_ebpf_cicd_tests.ps1 | 6 ++++++ scripts/config_test_vm.psm1 | 8 ++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 3a09dba395..fe5d1fe858 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -28,10 +28,11 @@ if (-not (Test-Path -Path $BaseVhdDirPath)) { throw "VHD directory not found at $BaseVhdDirPath" } -Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType 'Internal' +# Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType 'Internal' Create-VMSwitchIfNeeded -SwitchName 'VMExternalSwitch' -SwitchType 'External' -Create-VMStoredCredential -CredentialName "TEST_VM" -Username $VmUsername -Password $VmPassword -Create-VMStoredCredential -CredentialName "TEST_VM_STANDARD" -Username $VmStandardUserName -Password $VmPassword +# Stored credentials doesn't seem to be working... +# Create-VMStoredCredential -CredentialName "TEST_VM" -Username $VmUsername -Password $VmPassword +# Create-VMStoredCredential -CredentialName "TEST_VM_STANDARD" -Username $VmStandardUserName -Password $VmPassword Create-DirectoryIfNotExists -Path $WorkingPath # Read the input VHDs diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index aac41e96f5..2fc87e7fd8 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -246,6 +246,8 @@ function Configure-VM { Log-Message "Executing VM configuration script ($VMSetupScript) on VM: $VmName" Copy-VMFile -VMName $VmName -FileSource Host -SourcePath $VMSetupScript -DestinationPath "$VMWorkingDirectory\$VMSetupScript" -CreateFullPath Execute-CommandOnVM -VMName $VmName -VmCredential $VmCredential -Command "cd $VMWorkingDirectory; .\$VMSetupScript" + Log-Message "Sleeping for 1 minute to let the VM get into a steady state" + Sleep -Seconds 60 # Sleep for 1 minute to let the VM get into a steady state. Log-Message -Message "Successfully executed VM configuration script ($VMSetupScript) on VM: $VmName" -ForegroundColor Green Wait-ForVMReady -VMName $VmName -VmCredential $VmCredential diff --git a/scripts/cleanup_ebpf_cicd_tests.ps1 b/scripts/cleanup_ebpf_cicd_tests.ps1 index a379dfbbc9..bc6e0698cb 100644 --- a/scripts/cleanup_ebpf_cicd_tests.ps1 +++ b/scripts/cleanup_ebpf_cicd_tests.ps1 @@ -55,6 +55,12 @@ $Job = Start-Job -ScriptBlock { -VMName $VMName ` -Credential $TestVMCredential ` -ScriptBlock { + # TODO - remove this debugging output + ipconfig /all + Get-NetIPInterface | Out-String + Get-NetAdapter | Out-String + Get-NetAdapterBinding -AllBindings | Out-String + Test-Path -Path "c:\windows\memory.dmp" -PathType leaf } diff --git a/scripts/config_test_vm.psm1 b/scripts/config_test_vm.psm1 index 476c2a5680..f265e3417d 100644 --- a/scripts/config_test_vm.psm1 +++ b/scripts/config_test_vm.psm1 @@ -542,9 +542,9 @@ function Initialize-NetworkInterfacesOnVMs # TODO - remove this debugging output ipconfig /all - Get-NetIPInterface | fl * | Out-String - Get-NetAdapter | fl * | Out-String - Get-NetAdapterBinding -AllBindings | fl * | Out-String + Get-NetIPInterface | Out-String + Get-NetAdapter | Out-String + Get-NetAdapterBinding -AllBindings | Out-String # Loop through each adapter and enable IPv4 and IPv6 $adapters = Get-NetAdapter @@ -561,7 +561,7 @@ function Initialize-NetworkInterfacesOnVMs Write-Host "Failed to enable IPv4 and IPv6 on adapter: $($adapter.Name)" } } - Get-NetAdapterBinding -AllBindings | fl * | Out-String + Get-NetAdapterBinding -AllBindings | Out-String Pop-Location } -ArgumentList ("eBPF", $LogFileName) -ErrorAction Stop From 3575a62d785745fedf770d037203e7fe83d712cc Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 11 Dec 2024 09:39:44 -0800 Subject: [PATCH 29/91] remove debug trace --- tests/libs/util/socket_helper.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/libs/util/socket_helper.cpp b/tests/libs/util/socket_helper.cpp index e2fd5f224a..23338fcf09 100644 --- a/tests/libs/util/socket_helper.cpp +++ b/tests/libs/util/socket_helper.cpp @@ -86,8 +86,6 @@ _base_socket::_base_socket( socket, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&ipv6_option), sizeof(unsigned long)); if (error != 0) { FAIL("Could not enable dual family endpoint: " << WSAGetLastError()); - } else { - printf("Dual family endpoint enabled\n"); } } From e77ccfe513bc46151967ffbd4825c49952d7c253 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 11 Dec 2024 11:42:46 -0800 Subject: [PATCH 30/91] add extra debug logs --- scripts/common.psm1 | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/scripts/common.psm1 b/scripts/common.psm1 index ea215cff72..2842653d74 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -61,23 +61,42 @@ function Compress-File # Retry 3 times to ensure compression operation succeeds. # To mitigate error message: "The process cannot access the file <filename> because it is being used by another process." $retryCount = 1 - while ($retryCount -lt 4) { - $error.clear() - Compress-Archive ` - -Path $SourcePath ` - -DestinationPath $DestinationPath ` - -CompressionLevel Fastest ` - -Force - if ($error[0] -ne $null) { - $ErrorMessage = "*** ERROR *** Failed to compress kernel mode dump files: $error. Retrying $retryCount" + while ($retryCount -lt 6) { + try { + $error.clear() + Compress-Archive ` + -Path $SourcePath ` + -DestinationPath $DestinationPath ` + -CompressionLevel Fastest ` + -Force + if ($error[0] -ne $null) { + $ErrorMessage = "*** ERROR *** Failed to compress kernel mode dump files: $error. Retrying $retryCount" + Write-Output $ErrorMessage + Start-Sleep -seconds (5 * $retryCount) + $retryCount++ + } else { + # Compression succeeded. + if (Test-Path $DestinationPath) { + Write-Log "Successfully compressed $SourcePath -> $DestinationPath" + break; + } else { + $ErrorMessage = "*** ERROR *** Failed to compress kernel mode dump files: $error. Retrying $retryCount" + Write-Output $ErrorMessage + Start-Sleep -seconds (5 * $retryCount) + $retryCount++ + } + } + } catch { + $ErrorMessage = "*** ERROR *** Failed to compress kernel mode dump files: $_. Retrying $retryCount" Write-Output $ErrorMessage Start-Sleep -seconds (5 * $retryCount) $retryCount++ - } else { - # Compression succeeded. - break; } } + + if (!(Test-Path $DestinationPath)) { + Write-Log "Failed to compress kernel mode dump files after retries" + } } function Wait-TestJobToComplete From 112d69efb4471e2826a6cd5734a307b970725bdc Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 11 Dec 2024 16:13:41 -0800 Subject: [PATCH 31/91] WIP --- 1es/Setup_orig.ps1 | 6 +++--- 1es/prepare_vm_helpers.psm1 | 5 +++-- scripts/vm_run_tests.psm1 | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index fe5d1fe858..77e2cb5841 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -11,8 +11,8 @@ param( [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch', - [Parameter(Mandatory=$False)][string]$VMCpuCount=2, - [Parameter(Mandatory=$False)][string]$VMMemoryStartupBytes=512MB + [Parameter(Mandatory=$False)][string]$VMCpuCount=4, + [Parameter(Mandatory=$False)][string]$VMMemory=4096MB ) $ErrorActionPreference = "Stop" @@ -56,7 +56,7 @@ for ($i = 0; $i -lt $vhds.Count; $i++) { -VhdPath $vhd.FullName ` -VmStoragePath $outVMPath ` -ExternalVMSwitchName $ExternalSwitchName ` - -MemoryStartupBytes $VMMemoryStartupBytes ` + -VMMemory $VMMemory ` -UnattendPath $BaseUnattendPath ` -VmUsername $VmUsername ` -VmPassword $VmPassword diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 2fc87e7fd8..dc16039bdf 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -150,7 +150,7 @@ function Create-VM { [Parameter(Mandatory=$True)][string]$VhdPath, [Parameter(Mandatory=$True)][string]$VmStoragePath, [Parameter(Mandatory=$True)][string]$ExternalVMSwitchName, - [Parameter(Mandatory=$True)][Int64]$MemoryStartupBytes, + [Parameter(Mandatory=$True)][Int64]$VMMemory, [Parameter(Mandatory=$True)][string]$UnattendPath ) @@ -190,12 +190,13 @@ function Create-VM { # Create the VM Log-Message "Creating the VM" - New-VM -Name $VmName -MemoryStartupBytes $MemoryStartupBytes -VhdPath $VmVhdPath + New-VM -Name $VmName -VhdPath $VmVhdPath $vmSwitches = Get-VMSwitch foreach ($switch in $vmSwitches) { Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name } + Set-VMMemory -VMName $VmName -DynamicMemoryEnabled $false -MinimumBytes $VMMemory -StartupBytes $VMMemory -MaximumBytes $VMMemory if ((Get-VM -VMName $vmName) -eq $null) { throw "Failed to create VM: $VMName" diff --git a/scripts/vm_run_tests.psm1 b/scripts/vm_run_tests.psm1 index d6f92e7a44..28fa650df1 100644 --- a/scripts/vm_run_tests.psm1 +++ b/scripts/vm_run_tests.psm1 @@ -67,6 +67,7 @@ function Invoke-CICDTestsOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue + GetDriveFreeSpaceGB $TestMode = $TestMode.ToLower() switch ($TestMode) { @@ -287,6 +288,7 @@ function Invoke-XDPTestOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue + GetDriveFreeSpaceGB Write-Log "Invoking $XDPTestName on $VM" Invoke-XDPTest ` -RemoteIPV4Address $RemoteIPV4Address ` @@ -622,6 +624,7 @@ function Invoke-ConnectRedirectTestsOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue + GetDriveFreeSpaceGB Write-Log "Invoking connect redirect tests [Mode=$UserType] on $VM" Invoke-ConnectRedirectTest ` -LocalIPv4Address $LocalIPv4Address ` From 0c443c4e38ef67da7859c45539f31c2c8bce9231 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 09:23:53 -0800 Subject: [PATCH 32/91] WIP --- 1es/prepare_vm_helpers.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index dc16039bdf..d6b6f4554f 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -196,7 +196,7 @@ function Create-VM { Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name } - Set-VMMemory -VMName $VmName -DynamicMemoryEnabled $false -MinimumBytes $VMMemory -StartupBytes $VMMemory -MaximumBytes $VMMemory + Set-VMMemory -VMName $VmName -DynamicMemoryEnabled $false -StartupBytes $VMMemory if ((Get-VM -VMName $vmName) -eq $null) { throw "Failed to create VM: $VMName" From 9f73f64361b59f9e98b01378f13081dc731b6af5 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 10:04:15 -0800 Subject: [PATCH 33/91] wip --- scripts/vm_run_tests.psm1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/vm_run_tests.psm1 b/scripts/vm_run_tests.psm1 index 28fa650df1..d6f92e7a44 100644 --- a/scripts/vm_run_tests.psm1 +++ b/scripts/vm_run_tests.psm1 @@ -67,7 +67,6 @@ function Invoke-CICDTestsOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue - GetDriveFreeSpaceGB $TestMode = $TestMode.ToLower() switch ($TestMode) { @@ -288,7 +287,6 @@ function Invoke-XDPTestOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue - GetDriveFreeSpaceGB Write-Log "Invoking $XDPTestName on $VM" Invoke-XDPTest ` -RemoteIPV4Address $RemoteIPV4Address ` @@ -624,7 +622,6 @@ function Invoke-ConnectRedirectTestsOnVM Import-Module $WorkingDirectory\common.psm1 -ArgumentList ($LogFileName) -Force -WarningAction SilentlyContinue Import-Module $WorkingDirectory\run_driver_tests.psm1 -ArgumentList ($WorkingDirectory, $LogFileName, $TestHangTimeout, $UserModeDumpFolder) -Force -WarningAction SilentlyContinue - GetDriveFreeSpaceGB Write-Log "Invoking connect redirect tests [Mode=$UserType] on $VM" Invoke-ConnectRedirectTest ` -LocalIPv4Address $LocalIPv4Address ` From 25810d170563baa25219ef06f68befc12f78020d Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 13:39:06 -0800 Subject: [PATCH 34/91] WIP --- scripts/run_driver_tests.psm1 | 208 ++++++++++++++++++---------------- 1 file changed, 111 insertions(+), 97 deletions(-) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 01720f4ba5..5665315ed7 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -260,33 +260,38 @@ function Invoke-Test [Parameter(Mandatory = $True)][bool] $VerboseLogs, [Parameter(Mandatory = $True)][int] $TestHangTimeout) - # Initialize arguments. - if ($TestArgs -ne "") { - $ArgumentsList = @($TestArgs) - } + try { + # Initialize arguments. + if ($TestArgs -ne "") { + $ArgumentsList = @($TestArgs) + } - if ($VerboseLogs -eq $true) { - $ArgumentsList += '-s' - } + if ($VerboseLogs -eq $true) { + $ArgumentsList += '-s' + } - # Execute Test. - Write-Log "Executing $TestName $TestArgs" - $TestFilePath = "$pwd\$TestName" - $TempOutputFile = "$env:TEMP\app_output.log" # Log for standard output - $TempErrorFile = "$env:TEMP\app_error.log" # Log for standard error - if ($ArgumentsList) { - $TestProcess = Start-Process -FilePath $TestFilePath -ArgumentList $ArgumentsList -PassThru -NoNewWindow -RedirectStandardOutput $TempOutputFile -RedirectStandardError $TempErrorFile -ErrorAction Stop - } else { - $TestProcess = Start-Process -FilePath $TestFilePath -PassThru -NoNewWindow -RedirectStandardOutput $TempOutputFile -RedirectStandardError $TempErrorFile -ErrorAction Stop - } - if ($InnerTestName -ne "") { - Process-TestCompletion -TestProcess $TestProcess -TestCommand $InnerTestName -NestedProcess $True -TestHangTimeout $TestHangTimeout - } else { - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestName -TestHangTimeout $TestHangTimeout - } + # Execute Test. + Write-Log "Executing $TestName $TestArgs" + $TestFilePath = "$pwd\$TestName" + $TempOutputFile = "$env:TEMP\app_output.log" # Log for standard output + $TempErrorFile = "$env:TEMP\app_error.log" # Log for standard error + if ($ArgumentsList) { + $TestProcess = Start-Process -FilePath $TestFilePath -ArgumentList $ArgumentsList -PassThru -NoNewWindow -RedirectStandardOutput $TempOutputFile -RedirectStandardError $TempErrorFile -ErrorAction Stop + } else { + $TestProcess = Start-Process -FilePath $TestFilePath -PassThru -NoNewWindow -RedirectStandardOutput $TempOutputFile -RedirectStandardError $TempErrorFile -ErrorAction Stop + } + if ($InnerTestName -ne "") { + Process-TestCompletion -TestProcess $TestProcess -TestCommand $InnerTestName -NestedProcess $True -TestHangTimeout $TestHangTimeout + } else { + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestName -TestHangTimeout $TestHangTimeout + } - Write-Log "Test `"$TestName $TestArgs`" Passed" -ForegroundColor Green - Write-Log "`n==============================`n" + Write-Log "Test `"$TestName $TestArgs`" Passed" -ForegroundColor Green + Write-Log "`n==============================`n" + } catch { + $ErrorMessage = $_.Exception.Message + ThrowWithErrorMessage -ErrorMessage "Test `"$TestName $TestArgs`" Failed with $ErrorMessage" + } } # Function to create a tuple with default values for Arguments and Timeout @@ -358,22 +363,27 @@ function Invoke-XDPTest Push-Location $WorkingDirectory - Write-Log "Executing $XDPTestName with remote address: $RemoteIPV4Address" - $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" - $TestCommand = ".\xdp_tests.exe" - $TestArguments = "$XDPTestName --remote-ip $RemoteIPV4Address" - $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand - - Write-Log "Executing $XDPTestName with remote address: $RemoteIPV6Address" - $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" - $TestCommand = ".\xdp_tests.exe" - $TestArguments = "$XDPTestName --remote-ip $RemoteIPV6Address" - $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand - - Write-Log "$XDPTestName Test Passed" -ForegroundColor Green - Write-Log "`n`n" + try { + Write-Log "Executing $XDPTestName with remote address: $RemoteIPV4Address" + $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" + $TestCommand = ".\xdp_tests.exe" + $TestArguments = "$XDPTestName --remote-ip $RemoteIPV4Address" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand + + Write-Log "Executing $XDPTestName with remote address: $RemoteIPV6Address" + $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" + $TestCommand = ".\xdp_tests.exe" + $TestArguments = "$XDPTestName --remote-ip $RemoteIPV6Address" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand + + Write-Log "$XDPTestName Test Passed" -ForegroundColor Green + Write-Log "`n`n" + } catch { + $ErrorMessage = $_.Exception.Message + ThrowWithErrorMessage -ErrorMessage "XDP test Failed with $ErrorMessage" + } Pop-Location } @@ -395,63 +405,67 @@ function Invoke-ConnectRedirectTest Push-Location $WorkingDirectory - $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" - $TestCommand = ".\connect_redirect_tests.exe" - - ## First run the test with both v4 and v6 programs attached. - $TestArguments = - " --virtual-ip-v4 $VirtualIPv4Address" + - " --virtual-ip-v6 $VirtualIPv6Address" + - " --local-ip-v4 $LocalIPv4Address" + - " --local-ip-v6 $LocalIPv6Address" + - " --remote-ip-v4 $RemoteIPv4Address" + - " --remote-ip-v6 $RemoteIPv6Address" + - " --destination-port $DestinationPort" + - " --proxy-port $ProxyPort" + - " --user-name $StandardUserName" + - " --password $StandardUserPassword" + - " --user-type $UserType" - - Write-Log "Executing connect redirect tests with v4 and v6 programs. Arguments: $TestArguments" - $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand - - - ## Run test with only v4 program attached. - $TestArguments = - " --virtual-ip-v4 $VirtualIPv4Address" + - " --local-ip-v4 $LocalIPv4Address" + - " --remote-ip-v4 $RemoteIPv4Address" + - " --destination-port $DestinationPort" + - " --proxy-port $ProxyPort" + - " --user-name $StandardUserName" + - " --password $StandardUserPassword" + - " --user-type $UserType" + - " [connect_authorize_redirect_tests_v4]" - - Write-Log "Executing connect redirect tests with v4 programs. Arguments: $TestArguments" - $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand - - - ## Run tests with only v6 program attached. - $TestArguments = - " --virtual-ip-v6 $VirtualIPv6Address" + - " --local-ip-v6 $LocalIPv6Address" + - " --remote-ip-v6 $RemoteIPv6Address" + - " --destination-port $DestinationPort" + - " --proxy-port $ProxyPort" + - " --user-name $StandardUserName" + - " --password $StandardUserPassword" + - " --user-type $UserType" + - " [connect_authorize_redirect_tests_v6]" - - Write-Log "Executing connect redirect tests with v6 programs. Arguments: $TestArguments" - $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow - Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand - - - Write-Log "Connect-Redirect Test Passed" -ForegroundColor Green + try { + $TestRunScript = ".\Run-Self-Hosted-Runner-Test.ps1" + $TestCommand = ".\connect_redirect_tests.exe" + + ## First run the test with both v4 and v6 programs attached. + $TestArguments = + " --virtual-ip-v4 $VirtualIPv4Address" + + " --virtual-ip-v6 $VirtualIPv6Address" + + " --local-ip-v4 $LocalIPv4Address" + + " --local-ip-v6 $LocalIPv6Address" + + " --remote-ip-v4 $RemoteIPv4Address" + + " --remote-ip-v6 $RemoteIPv6Address" + + " --destination-port $DestinationPort" + + " --proxy-port $ProxyPort" + + " --user-name $StandardUserName" + + " --password $StandardUserPassword" + + " --user-type $UserType" + + Write-Log "Executing connect redirect tests with v4 and v6 programs. Arguments: $TestArguments" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand + + + ## Run test with only v4 program attached. + $TestArguments = + " --virtual-ip-v4 $VirtualIPv4Address" + + " --local-ip-v4 $LocalIPv4Address" + + " --remote-ip-v4 $RemoteIPv4Address" + + " --destination-port $DestinationPort" + + " --proxy-port $ProxyPort" + + " --user-name $StandardUserName" + + " --password $StandardUserPassword" + + " --user-type $UserType" + + " [connect_authorize_redirect_tests_v4]" + + Write-Log "Executing connect redirect tests with v4 programs. Arguments: $TestArguments" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand + + + ## Run tests with only v6 program attached. + $TestArguments = + " --virtual-ip-v6 $VirtualIPv6Address" + + " --local-ip-v6 $LocalIPv6Address" + + " --remote-ip-v6 $RemoteIPv6Address" + + " --destination-port $DestinationPort" + + " --proxy-port $ProxyPort" + + " --user-name $StandardUserName" + + " --password $StandardUserPassword" + + " --user-type $UserType" + + " [connect_authorize_redirect_tests_v6]" + + Write-Log "Executing connect redirect tests with v6 programs. Arguments: $TestArguments" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand + + Write-Log "Connect-Redirect Test Passed" -ForegroundColor Green + } catch { + $ErrorMessage = $_.Exception.Message + ThrowWithErrorMessage -ErrorMessage "Connect-Redirect Test Failed with $ErrorMessage" + } Pop-Location } From 949aeb2d1c037e658ce6e34b53517102f2ddf0cb Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 14:15:23 -0800 Subject: [PATCH 35/91] WIP - try to separate out which jobs run on 1es vs which run on github: --- .github/workflows/cicd.yml | 20 ++++++++- .github/workflows/reusable-test.yml | 70 ++++++++++++++++++++--------- 2 files changed, 69 insertions(+), 21 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 6f9afca8d7..ecd359dbe7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -57,6 +57,24 @@ jobs: build_options: /p:ReleaseJIT='True' configurations: '["Debug", "Release"]' + # Run the unit tests in GitHub. + unit_tests: + # Always run this job. + needs: regular + if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' + uses: ./.github/workflows/reusable-test.yml + with: + name: unit_tests + pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe + # Exclude [processes] test that CodeCoverage can't work with. + test_command: .\unit_tests.exe -d yes ~[processes] + build_artifact: Build-x64 + environment: windows-2022 + code_coverage: true + gather_dumps: true + capture_etw: true + leak_detection: true + # Run the driver tests on self-hosted runners. driver_ws2019: # Always run this job. @@ -70,7 +88,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: ebpf_cicd_tests_ws2019 + environment: 1es-server-2019 # ebpf_cicd_tests_ws2019 # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index d40f7fa76e..1c0ac05742 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -62,6 +62,47 @@ permissions: issues: write # Required to create issues. jobs: + set-job-environment: + # The following environments are supported: + # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) + # - Any of the github environments. + runs-on: ${{ inputs.environment }} + steps: + - name: Set runner type + id: set_runner + run: | + if [[ "${{ inputs.environment }}" == *"1es"* ]]; then + pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') + echo "::set-output name=runs_on::self-hosted" + echo "::set-output name=runs_on_pool::1ES.Pool=ebpf-cicd-runner-pool-$pool_name" + else + echo "::set-output name=runs_on::${{ inputs.environment }}" + fi +# Alternative solution: +# jobs: +# example-job: +# runs-on: ${{ inputs.environment }} +# steps: +# - name: Check condition +# id: condition +# run: echo "Condition check" +# # Set an output based on your condition +# # For example, set the output to 'true' if you want to use the self-hosted runner +# # You can replace this with your actual condition +# echo "::set-output name=use_self_hosted::true" + +# - name: Set runs-on +# if: steps.condition.outputs.use_self_hosted == 'true' +# run: | +# echo "::set-output name=runs_on::self-hosted" +# echo "::set-output name=runs_on_pool::1ES.Pool=ebpf-cicd-runner-pool-server-2019" + +# - name: Set runs-on +# if: steps.condition.outputs.use_self_hosted != 'true' +# run: echo "::set-output name=runs_on::${{ inputs.environment }}" + +# runs-on: ${{ steps.set_runs_on.outputs.runs_on }} +# runs-on: ${{ steps.set_runs_on.outputs.runs_on_pool }} run_test: # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. timeout-minutes: 90 @@ -69,9 +110,8 @@ jobs: strategy: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: - - self-hosted - - "1ES.Pool=ebpf-cicd-runner-pool-server-2019" + runs-on: ${{ steps.set_runner.outputs.runs_on }} + runs-on: ${{ steps.set_runner.outputs.runs_on_pool }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} @@ -91,15 +131,15 @@ jobs: with: egress-policy: audit - - name: maige_test - id: maige-test + - name: Provision Mock (Move to setup script directly later) + id: provision-mock run: | - powershell.exe "Get-NetAdapter" - powershell.exe "Get-VMSwitch" powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" - powershell.exe "Get-NetAdapter" - powershell.exe "Get-VMSwitch" - powershell.exe "Get-VM" + # powershell.exe "Get-NetAdapter" + # powershell.exe "Get-VMSwitch" + # powershell.exe "Get-NetAdapter" + # powershell.exe "Get-VMSwitch" + # powershell.exe "Get-VM" - name: Print CPU information run: @@ -244,16 +284,6 @@ jobs: .\export_program_info_sample.exe --clear .\export_program_info_sample.exe - - name: 1ES TEST - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') - id: test_1es - working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} - run: | - hostname - whoami - powershell.exe Get-VM - dir /s - - name: Run pre test command if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') id: run_pre_test_command From cac10f2a2eeed415b2c0688334a71f48d0132d5a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 14:22:58 -0800 Subject: [PATCH 36/91] WIP --- .github/workflows/cicd.yml | 2 +- .github/workflows/reusable-test.yml | 29 ++--------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ecd359dbe7..d26fea180c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -88,7 +88,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: 1es-server-2019 # ebpf_cicd_tests_ws2019 + environment: 1es-server-2019 # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 1c0ac05742..23262daf49 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -64,9 +64,9 @@ permissions: jobs: set-job-environment: # The following environments are supported: - # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) # - Any of the github environments. - runs-on: ${{ inputs.environment }} + # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) + runs-on: ubuntu-latest steps: - name: Set runner type id: set_runner @@ -78,31 +78,6 @@ jobs: else echo "::set-output name=runs_on::${{ inputs.environment }}" fi -# Alternative solution: -# jobs: -# example-job: -# runs-on: ${{ inputs.environment }} -# steps: -# - name: Check condition -# id: condition -# run: echo "Condition check" -# # Set an output based on your condition -# # For example, set the output to 'true' if you want to use the self-hosted runner -# # You can replace this with your actual condition -# echo "::set-output name=use_self_hosted::true" - -# - name: Set runs-on -# if: steps.condition.outputs.use_self_hosted == 'true' -# run: | -# echo "::set-output name=runs_on::self-hosted" -# echo "::set-output name=runs_on_pool::1ES.Pool=ebpf-cicd-runner-pool-server-2019" - -# - name: Set runs-on -# if: steps.condition.outputs.use_self_hosted != 'true' -# run: echo "::set-output name=runs_on::${{ inputs.environment }}" - -# runs-on: ${{ steps.set_runs_on.outputs.runs_on }} -# runs-on: ${{ steps.set_runs_on.outputs.runs_on_pool }} run_test: # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. timeout-minutes: 90 From 30658da92ac40064b2aeb31347d7e7ee10a3d66a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 14:31:00 -0800 Subject: [PATCH 37/91] WIP --- .github/workflows/reusable-test.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 23262daf49..2477fb6091 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -85,8 +85,9 @@ jobs: strategy: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ steps.set_runner.outputs.runs_on }} - runs-on: ${{ steps.set_runner.outputs.runs_on_pool }} + runs-on: + - ${{ steps.set_runner.outputs.runs_on }} + - ${{ steps.set_runner.outputs.runs_on_pool }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} @@ -106,8 +107,9 @@ jobs: with: egress-policy: audit - - name: Provision Mock (Move to setup script directly later) - id: provision-mock + - name: Configure runner (Move to setup script directly later) + id: configure-runner + if: contains(inputs.environment, '1es') run: | powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" # powershell.exe "Get-NetAdapter" @@ -136,7 +138,7 @@ jobs: # Perform shallow checkout for self-hosted runner. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + if: contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') with: ref: ${{ github.event.workflow_run.head_branch }} @@ -186,7 +188,7 @@ jobs: - name: Set up OpenCppCoverage and add to PATH id: set_up_opencppcoverage - if: (inputs.code_coverage == true) && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.code_coverage == true) && !contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') run: | choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append @@ -203,7 +205,7 @@ jobs: New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - name: Remove existing artifacts - if: (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (steps.skip_check.outputs.should_skip != 'true') + if: contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') run: | Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue @@ -260,14 +262,14 @@ jobs: .\export_program_info_sample.exe - name: Run pre test command - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + if: steps.skip_check.outputs.should_skip != 'true' && !contains(inputs.environment, '1es') id: run_pre_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.PRE_COMMAND}} - name: Run pre test command on self-hosted runner - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + if: steps.skip_check.outputs.should_skip != 'true' && contains(inputs.environment, '1es') id: run_pre_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -309,14 +311,14 @@ jobs: OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - name: Run test on self-hosted runner - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') && (inputs.fault_injection != true) id: run_test_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') && (inputs.fault_injection != true) id: run_test_without_code_coverage working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} shell: cmd @@ -326,7 +328,7 @@ jobs: - name: Run post test command # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment != 'ebpf_cicd_tests_ws2019' && inputs.environment != 'ebpf_cicd_tests_ws2022' && inputs.environment != 'ebpf_cicd_perf_ws2022') + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') id: run_post_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -334,7 +336,7 @@ jobs: - name: Run post test command on self-hosted runner # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.environment == 'ebpf_cicd_tests_ws2019' || inputs.environment == 'ebpf_cicd_tests_ws2022' || inputs.environment == 'ebpf_cicd_perf_ws2022') + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') id: run_post_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | From a79f74ebe581c1d68bc2895bd4f6c1933453993b Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 14:35:03 -0800 Subject: [PATCH 38/91] WIP --- .github/workflows/reusable-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 2477fb6091..21cd8660bc 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -86,8 +86,8 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} runs-on: - - ${{ steps.set_runner.outputs.runs_on }} - - ${{ steps.set_runner.outputs.runs_on_pool }} + - ${{ set-job-environment.steps.set_runner.outputs.runs_on }} + - ${{ set-job-environment.steps.set_runner.outputs.runs_on_pool }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From 9e2ca3de37a95296a802fb68a3b5e8e5f894b5ac Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 14:38:01 -0800 Subject: [PATCH 39/91] WIP --- .github/workflows/reusable-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 21cd8660bc..087f3b0b26 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -79,6 +79,7 @@ jobs: echo "::set-output name=runs_on::${{ inputs.environment }}" fi run_test: + needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. timeout-minutes: 90 @@ -86,8 +87,8 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} runs-on: - - ${{ set-job-environment.steps.set_runner.outputs.runs_on }} - - ${{ set-job-environment.steps.set_runner.outputs.runs_on_pool }} + - ${{ needs.set-job-environment.steps.outputs.runs_on }} + - ${{ needs.set-job-environment.steps.outputs.runs_on_pool }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From 53f62b27099b266b7044a9db9a613a4c1513420c Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 15:06:06 -0800 Subject: [PATCH 40/91] WIP --- .github/workflows/reusable-test.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 087f3b0b26..d9d45ba61f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -67,17 +67,19 @@ jobs: # - Any of the github environments. # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) runs-on: ubuntu-latest + outputs: + runs_on: ${{ steps.set_runner.outputs.runs_on }} + runs_on_pool: ${{ steps.set_runner.outputs.runs_on_pool }} steps: - name: Set runner type id: set_runner run: | if [[ "${{ inputs.environment }}" == *"1es"* ]]; then pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "::set-output name=runs_on::self-hosted" - echo "::set-output name=runs_on_pool::1ES.Pool=ebpf-cicd-runner-pool-$pool_name" + echo "runs_on=self-hosted" >> $GITHUB_OUTPUT + echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT else - echo "::set-output name=runs_on::${{ inputs.environment }}" - fi + echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. @@ -87,8 +89,8 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} runs-on: - - ${{ needs.set-job-environment.steps.outputs.runs_on }} - - ${{ needs.set-job-environment.steps.outputs.runs_on_pool }} + - ${{ needs.set-job-environment.outputs.runs_on }} + - ${{ needs.set-job-environment.outputs.runs_on_pool }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From fde019ba28933386637c95f2f3ccd01f32cc4ba1 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 15:27:34 -0800 Subject: [PATCH 41/91] WIP --- .github/workflows/reusable-test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index d9d45ba61f..c3db9edacd 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -76,10 +76,10 @@ jobs: run: | if [[ "${{ inputs.environment }}" == *"1es"* ]]; then pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "runs_on=self-hosted" >> $GITHUB_OUTPUT - echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT + echo "runs_on=self-hosted" >> $GITHUB_STATE + echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_STATE else - echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT + echo "runs_on=${{ inputs.environment }}" >> $GITHUB_STATE run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. @@ -162,7 +162,6 @@ jobs: .github/workflows/reusable-test.yml sparse-checkout-cone-mode: false - - name: Set up choco cache folder # Set the choco cache to a local folder so that it can be cached. if: (inputs.gather_dumps == true) && (steps.skip_check.outputs.should_skip != 'true') From 0bae199d191f9a8f4ffa1f533197b938eec313f2 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 16:46:51 -0800 Subject: [PATCH 42/91] WIP --- .github/workflows/reusable-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index c3db9edacd..dd88c53c41 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -76,10 +76,10 @@ jobs: run: | if [[ "${{ inputs.environment }}" == *"1es"* ]]; then pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "runs_on=self-hosted" >> $GITHUB_STATE - echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_STATE + echo "runs_on=self-hosted" >> "$GITHUB_OUTPUT" + echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> "$GITHUB_OUTPUT" else - echo "runs_on=${{ inputs.environment }}" >> $GITHUB_STATE + echo "runs_on=${{ inputs.environment }}" >> "$GITHUB_OUTPUT" run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. From 874c6467c48f48761dbbcc016131a5f33849e314 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 17:06:57 -0800 Subject: [PATCH 43/91] WIP --- .github/workflows/reusable-test.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index dd88c53c41..60dc3cacad 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -68,18 +68,21 @@ jobs: # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) runs-on: ubuntu-latest outputs: - runs_on: ${{ steps.set_runner.outputs.runs_on }} - runs_on_pool: ${{ steps.set_runner.outputs.runs_on_pool }} + runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} + runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} steps: - - name: Set runner type - id: set_runner + - name: Set runner type (1es) + id: set_runner_1es + if: contains(inputs.environment, '1es') run: | - if [[ "${{ inputs.environment }}" == *"1es"* ]]; then - pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "runs_on=self-hosted" >> "$GITHUB_OUTPUT" - echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> "$GITHUB_OUTPUT" - else - echo "runs_on=${{ inputs.environment }}" >> "$GITHUB_OUTPUT" + pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') + echo "runs_on=self-hosted" >> "$GITHUB_OUTPUT" + echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> "$GITHUB_OUTPUT" + - name: Set runner type (github hosted) + id: set_runner_github + if: !contains(inputs.environment, '1es') + run: | + echo "runs_on=${{ inputs.environment }}" >> "$GITHUB_OUTPUT" run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. From b45a65e8c041e9994bdc19a37ace600b893f2ad4 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 17:11:19 -0800 Subject: [PATCH 44/91] WIP --- .github/workflows/reusable-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 60dc3cacad..eed3ed794a 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -78,6 +78,7 @@ jobs: pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') echo "runs_on=self-hosted" >> "$GITHUB_OUTPUT" echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> "$GITHUB_OUTPUT" + - name: Set runner type (github hosted) id: set_runner_github if: !contains(inputs.environment, '1es') From 4e07b18ab33197a8e203fd2756e13b2a33c4e657 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Thu, 12 Dec 2024 17:15:52 -0800 Subject: [PATCH 45/91] WIP --- .github/workflows/reusable-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index eed3ed794a..a5561de828 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -76,14 +76,14 @@ jobs: if: contains(inputs.environment, '1es') run: | pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "runs_on=self-hosted" >> "$GITHUB_OUTPUT" - echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> "$GITHUB_OUTPUT" - + echo "pool_name=$pool_name" + echo "runs_on=self-hosted" >> $GITHUB_OUTPUT + echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT - name: Set runner type (github hosted) id: set_runner_github if: !contains(inputs.environment, '1es') run: | - echo "runs_on=${{ inputs.environment }}" >> "$GITHUB_OUTPUT" + echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. From 36900a9c1f7a9809fc1702749d21c4f7beddb363 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 09:52:08 -0800 Subject: [PATCH 46/91] WIP --- .github/workflows/cicd.yml | 6 ++- .github/workflows/reusable-test.yml | 71 ++++++++++++++++++----------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d26fea180c..01719217f0 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -69,7 +69,7 @@ jobs: # Exclude [processes] test that CodeCoverage can't work with. test_command: .\unit_tests.exe -d yes ~[processes] build_artifact: Build-x64 - environment: windows-2022 + environment: [windows-2022] code_coverage: true gather_dumps: true capture_etw: true @@ -88,7 +88,9 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: 1es-server-2019 + environment: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] + # - self-hosted + # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index a5561de828..c63c91a156 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -22,7 +22,7 @@ on: # The environment to run this test on. environment: description: 'Environment to run tests on' - type: string + type: array required: true # Set to true to gather code coverage when this test runs. code_coverage: @@ -62,28 +62,41 @@ permissions: issues: write # Required to create issues. jobs: - set-job-environment: - # The following environments are supported: - # - Any of the github environments. - # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) - runs-on: ubuntu-latest - outputs: - runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} - runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} - steps: - - name: Set runner type (1es) - id: set_runner_1es - if: contains(inputs.environment, '1es') - run: | - pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - echo "pool_name=$pool_name" - echo "runs_on=self-hosted" >> $GITHUB_OUTPUT - echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT - - name: Set runner type (github hosted) - id: set_runner_github - if: !contains(inputs.environment, '1es') - run: | - echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT + # set-job-environment: + # # The following environments are supported: + # # - Any of the github environments. + # # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) + # runs-on: ubuntu-latest + # outputs: + # runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} + # runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} + # steps: + # - name: Set 1es runner type + # id: set_runner_1es + # if: contains(inputs.environment, '1es') + # run: | + # pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') + # echo "pool_name=$pool_name" + # echo "runs_on=self-hosted" >> $GITHUB_OUTPUT + # echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT + # - name: Set github runner type + # id: set_runner_github + # if: !contains(inputs.environment, '1es') + # run: | + # echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT + +# jobs: +# build: +# runs-on: ${{ matrix.runner }} +# strategy: +# matrix: +# runner: [] +# include: +# - env: self-hosted +# runner: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] +# - env: windows +# runner: [windows-2022] + run_test: needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. @@ -92,9 +105,15 @@ jobs: strategy: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: - - ${{ needs.set-job-environment.outputs.runs_on }} - - ${{ needs.set-job-environment.outputs.runs_on_pool }} + + runs-on: ${{ inputs.environment }} + # - ${{ needs.set-job-environment.outputs.runs_on }} + # - ${{ needs.set-job-environment.outputs.runs_on_pool }} + # runs-on: + # - self-hosted + # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + # runs-on: + # - windows-2022 env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From 085aa1215870a46f64854cb58ceb05e5ad308e3f Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 10:10:25 -0800 Subject: [PATCH 47/91] WIP --- .github/workflows/cicd.yml | 7 +- .github/workflows/reusable-test.yml | 100 +++++++++++++++------------- 2 files changed, 58 insertions(+), 49 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 01719217f0..dcdbef10df 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -69,7 +69,7 @@ jobs: # Exclude [processes] test that CodeCoverage can't work with. test_command: .\unit_tests.exe -d yes ~[processes] build_artifact: Build-x64 - environment: [windows-2022] + environment: windows-2022 code_coverage: true gather_dumps: true capture_etw: true @@ -88,9 +88,8 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] - # - self-hosted - # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + environment: server-2019 + self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index c63c91a156..8487bcb799 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -22,8 +22,11 @@ on: # The environment to run this test on. environment: description: 'Environment to run tests on' - type: array + type: string required: true + self-hosted-runner: + type: boolean + required: false # Set to true to gather code coverage when this test runs. code_coverage: required: false @@ -62,43 +65,7 @@ permissions: issues: write # Required to create issues. jobs: - # set-job-environment: - # # The following environments are supported: - # # - Any of the github environments. - # # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) - # runs-on: ubuntu-latest - # outputs: - # runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} - # runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} - # steps: - # - name: Set 1es runner type - # id: set_runner_1es - # if: contains(inputs.environment, '1es') - # run: | - # pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - # echo "pool_name=$pool_name" - # echo "runs_on=self-hosted" >> $GITHUB_OUTPUT - # echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT - # - name: Set github runner type - # id: set_runner_github - # if: !contains(inputs.environment, '1es') - # run: | - # echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT - -# jobs: -# build: -# runs-on: ${{ matrix.runner }} -# strategy: -# matrix: -# runner: [] -# include: -# - env: self-hosted -# runner: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] -# - env: windows -# runner: [windows-2022] - run_test: - needs: set-job-environment # Due to app-verifier, unit tests take a lot longer to execute. Increase the timeout to 90 minutes. timeout-minutes: 90 @@ -106,14 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ inputs.environment }} - # - ${{ needs.set-job-environment.outputs.runs_on }} - # - ${{ needs.set-job-environment.outputs.runs_on_pool }} - # runs-on: - # - self-hosted - # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 - # runs-on: - # - windows-2022 + runs-on: ${{ (inputs.self-hosted-runner) && fromJSON('[ "self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-${{ inputs.environment }}"]') || ${{ inputs.environment }} }} env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} @@ -579,3 +539,53 @@ jobs: body: body, labels: label_array, }); + + + + + + + # set-job-environment: + # # The following environments are supported: + # # - Any of the github environments. + # # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) + # runs-on: ubuntu-latest + # outputs: + # runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} + # runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} + # steps: + # - name: Set 1es runner type + # id: set_runner_1es + # if: contains(inputs.environment, '1es') + # run: | + # pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') + # echo "pool_name=$pool_name" + # echo "runs_on=self-hosted" >> $GITHUB_OUTPUT + # echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT + # - name: Set github runner type + # id: set_runner_github + # if: !contains(inputs.environment, '1es') + # run: | + # echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT + +# jobs: +# build: +# runs-on: ${{ matrix.runner }} +# strategy: +# matrix: +# runner: [] +# include: +# - env: self-hosted +# runner: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] +# - env: windows +# runner: [windows-2022] + + + # - ${{ needs.set-job-environment.outputs.runs_on }} + # - ${{ needs.set-job-environment.outputs.runs_on_pool }} + + # runs-on: + # - self-hosted + # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + # runs-on: + # - windows-2022 \ No newline at end of file From 0e630a9f536d99ac8f712f5170aec7834f7ad305 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 10:17:24 -0800 Subject: [PATCH 48/91] WIP --- .github/workflows/reusable-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 8487bcb799..f6213c44f5 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,8 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner) && fromJSON('[ "self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-${{ inputs.environment }}"]') || ${{ inputs.environment }} }} + runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-' + inputs.environment + '"]') || inputs.environment }} + env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} From 3fbde1fac0485a8e580d484d2647229cbac9f06f Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 10:18:57 -0800 Subject: [PATCH 49/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index f6213c44f5..f468b2b2c2 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-' + inputs.environment + '"]') || inputs.environment }} + runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-(inputs.environment)"]') || inputs.environment }} env: # Configuration type to build. From 666a268a6acc1091974ef744fd91dff751f044f7 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 10:49:19 -0800 Subject: [PATCH 50/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index f468b2b2c2..623e0aace2 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-(inputs.environment)"]') || inputs.environment }} + runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool' + inputs.environment + '"]') || inputs.environment }} env: # Configuration type to build. From 128187848f84dd5f0742a25fdea185479f903553 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 10:58:08 -0800 Subject: [PATCH 51/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 623e0aace2..a755f804e9 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool' + inputs.environment + '"]') || inputs.environment }} + runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool" + inputs.environment]') || inputs.environment }} env: # Configuration type to build. From 5901583d39cb9d9220187c74d58f2969e1fdb1da Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 11:23:02 -0800 Subject: [PATCH 52/91] WIP --- .github/workflows/reusable-test.yml | 72 +++++------------------------ 1 file changed, 11 insertions(+), 61 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index a755f804e9..5b97b46a0f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -96,7 +96,7 @@ jobs: - name: Configure runner (Move to setup script directly later) id: configure-runner - if: contains(inputs.environment, '1es') + if: (inputs.self-hosted-runner) run: | powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" # powershell.exe "Get-NetAdapter" @@ -125,7 +125,7 @@ jobs: # Perform shallow checkout for self-hosted runner. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - if: contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') with: ref: ${{ github.event.workflow_run.head_branch }} @@ -174,7 +174,7 @@ jobs: - name: Set up OpenCppCoverage and add to PATH id: set_up_opencppcoverage - if: (inputs.code_coverage == true) && !contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.code_coverage == true) && !(inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') run: | choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append @@ -191,7 +191,7 @@ jobs: New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - name: Remove existing artifacts - if: contains(inputs.environment, '1es') && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') run: | Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue @@ -248,14 +248,14 @@ jobs: .\export_program_info_sample.exe - name: Run pre test command - if: steps.skip_check.outputs.should_skip != 'true' && !contains(inputs.environment, '1es') + if: steps.skip_check.outputs.should_skip != 'true' && !(inputs.self-hosted-runner) id: run_pre_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.PRE_COMMAND}} - name: Run pre test command on self-hosted runner - if: steps.skip_check.outputs.should_skip != 'true' && contains(inputs.environment, '1es') + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner) id: run_pre_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -297,14 +297,14 @@ jobs: OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - name: Run test on self-hosted runner - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) && (inputs.fault_injection != true) id: run_test_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) && (inputs.fault_injection != true) id: run_test_without_code_coverage working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} shell: cmd @@ -314,7 +314,7 @@ jobs: - name: Run post test command # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) id: run_post_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -322,7 +322,7 @@ jobs: - name: Run post test command on self-hosted runner # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, '1es') + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) id: run_post_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -539,54 +539,4 @@ jobs: title: title, body: body, labels: label_array, - }); - - - - - - - # set-job-environment: - # # The following environments are supported: - # # - Any of the github environments. - # # - 1es-<RUNNER_POOL_NAME> (which matches ebpf-cicd-runner-pool-<RUNNER_POOL_NAME> in the 1es pool) - # runs-on: ubuntu-latest - # outputs: - # runs_on: ${{ steps.set_runner_1es.outputs.runs_on || steps.set_runner_github.outputs.runs_on }} - # runs_on_pool: ${{ steps.set_runner_1es.outputs.runs_on_pool || '' }} - # steps: - # - name: Set 1es runner type - # id: set_runner_1es - # if: contains(inputs.environment, '1es') - # run: | - # pool_name=$(echo "${{ inputs.environment }}" | sed 's/.*1es-//') - # echo "pool_name=$pool_name" - # echo "runs_on=self-hosted" >> $GITHUB_OUTPUT - # echo "runs_on_pool=1ES.Pool=ebpf-cicd-runner-pool-$pool_name" >> $GITHUB_OUTPUT - # - name: Set github runner type - # id: set_runner_github - # if: !contains(inputs.environment, '1es') - # run: | - # echo "runs_on=${{ inputs.environment }}" >> $GITHUB_OUTPUT - -# jobs: -# build: -# runs-on: ${{ matrix.runner }} -# strategy: -# matrix: -# runner: [] -# include: -# - env: self-hosted -# runner: [self-hosted, 1ES.Pool=ebpf-cicd-runner-pool-server-2019] -# - env: windows -# runner: [windows-2022] - - - # - ${{ needs.set-job-environment.outputs.runs_on }} - # - ${{ needs.set-job-environment.outputs.runs_on_pool }} - - # runs-on: - # - self-hosted - # - 1ES.Pool=ebpf-cicd-runner-pool-server-2019 - # runs-on: - # - windows-2022 \ No newline at end of file + }); \ No newline at end of file From e4674876144d28ae306c30346ab7e0f0f807ef3d Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 13:27:12 -0800 Subject: [PATCH 53/91] WIP --- .github/workflows/reusable-test.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 5b97b46a0f..399316a41f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -89,6 +89,11 @@ jobs: TEST_TIMEOUT: 3600 # 1 hour timeout for tests. steps: + - name: Log runson + run: | + echo "Running on ${{input.environment}} + echo "" + - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: @@ -96,7 +101,7 @@ jobs: - name: Configure runner (Move to setup script directly later) id: configure-runner - if: (inputs.self-hosted-runner) + if: (inputs.self-hosted-runner == true) run: | powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" # powershell.exe "Get-NetAdapter" @@ -125,7 +130,7 @@ jobs: # Perform shallow checkout for self-hosted runner. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - if: (inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.self-hosted-runner == true) && (steps.skip_check.outputs.should_skip != 'true') with: ref: ${{ github.event.workflow_run.head_branch }} @@ -174,7 +179,7 @@ jobs: - name: Set up OpenCppCoverage and add to PATH id: set_up_opencppcoverage - if: (inputs.code_coverage == true) && !(inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.code_coverage == true) && (inputs.self-hosted-runner != true) && (steps.skip_check.outputs.should_skip != 'true') run: | choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append @@ -191,7 +196,7 @@ jobs: New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - name: Remove existing artifacts - if: (inputs.self-hosted-runner) && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.self-hosted-runner == true) && (steps.skip_check.outputs.should_skip != 'true') run: | Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue @@ -248,14 +253,14 @@ jobs: .\export_program_info_sample.exe - name: Run pre test command - if: steps.skip_check.outputs.should_skip != 'true' && !(inputs.self-hosted-runner) + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner != true) id: run_pre_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.PRE_COMMAND}} - name: Run pre test command on self-hosted runner - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner) + if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner == true) id: run_pre_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -297,14 +302,14 @@ jobs: OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - name: Run test on self-hosted runner - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) && (inputs.fault_injection != true) id: run_test_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) && (inputs.fault_injection != true) id: run_test_without_code_coverage working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} shell: cmd @@ -314,7 +319,7 @@ jobs: - name: Run post test command # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) id: run_post_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -322,7 +327,7 @@ jobs: - name: Run post test command on self-hosted runner # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner) + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) id: run_post_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | From 051c178bfee9548806a6efa82c265c45d44235dc Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 13:28:45 -0800 Subject: [PATCH 54/91] WIP --- .github/workflows/reusable-test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 399316a41f..cf61225711 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -89,11 +89,6 @@ jobs: TEST_TIMEOUT: 3600 # 1 hour timeout for tests. steps: - - name: Log runson - run: | - echo "Running on ${{input.environment}} - echo "" - - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: From 7501226bbbc54b882be3525e9e9cad84d783a537 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 13:29:40 -0800 Subject: [PATCH 55/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index cf61225711..725d7fbb67 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ inputs.self-hosted-runner && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool" + inputs.environment]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool" + inputs.environment]') || inputs.environment }} env: # Configuration type to build. From 6adcb6471cdb31cbab526381bc06af091b87caec Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 14:46:18 -0800 Subject: [PATCH 56/91] WIP --- .github/workflows/cicd.yml | 2 +- .github/workflows/reusable-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index dcdbef10df..647444ac92 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -88,7 +88,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: server-2019 + environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 725d7fbb67..43cc86eb4d 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool" + inputs.environment]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]') || inputs.environment }} env: # Configuration type to build. From 7038eb801848ab5106471e27b181adce5aa46a01 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:21:42 -0800 Subject: [PATCH 57/91] WIP --- .github/workflows/cicd.yml | 30 ++++++++++++++--------------- .github/workflows/reusable-test.yml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 647444ac92..7a727178e8 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -43,24 +43,24 @@ jobs: # --------------------------------------------------------------------------- # Perform the regular build. - regular: - # Always run this job. - if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/reusable-build.yml - with: - ref: ${{ github.ref }} - repository: ${{ github.repository }} - build_artifact: Build-x64 - generate_release_package: true - build_msi: true - build_nuget: true - build_options: /p:ReleaseJIT='True' - configurations: '["Debug", "Release"]' + # regular: + # # Always run this job. + # if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + # uses: ./.github/workflows/reusable-build.yml + # with: + # ref: ${{ github.ref }} + # repository: ${{ github.repository }} + # build_artifact: Build-x64 + # generate_release_package: true + # build_msi: true + # build_nuget: true + # build_options: /p:ReleaseJIT='True' + # configurations: '["Debug", "Release"]' # Run the unit tests in GitHub. unit_tests: # Always run this job. - needs: regular + # needs: regular if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' uses: ./.github/workflows/reusable-test.yml with: @@ -79,7 +79,7 @@ jobs: driver_ws2019: # Always run this job. # Only run this on repos that have self-host runners. - needs: regular + # needs: regular if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') uses: ./.github/workflows/reusable-test.yml with: diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 43cc86eb4d..13f638699b 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]') || inputs.environment }} + runs-on: ${{ ((inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]')) || inputs.environment }} env: # Configuration type to build. From dbaad888e64bfc51d13a2523e9f00e6e0f506e3f Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:25:41 -0800 Subject: [PATCH 58/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 13f638699b..2593db1ce3 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ ((inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]')) || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]') || inputs.environment }} env: # Configuration type to build. From af0066f6ef5a3d9b1c47286c124da1dc7a7453a0 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:26:57 -0800 Subject: [PATCH 59/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 2593db1ce3..15f3d6e387 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "inputs.environment"]') || inputs.environment }} env: # Configuration type to build. From 7c30abcfa46ce9026564ccbf52ed66135885ab71 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:28:23 -0800 Subject: [PATCH 60/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 15f3d6e387..43cc86eb4d 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "inputs.environment"]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]') || inputs.environment }} env: # Configuration type to build. From e239ec8208a9b4657589e7f927c4113fce4c592d Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:29:29 -0800 Subject: [PATCH 61/91] WIP --- .github/workflows/cicd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 7a727178e8..19f5641472 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -88,7 +88,8 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + # environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + environment: '1ES.Pool=ebpf-cicd-runner-pool-server-2019' self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false From f8146f13d373d068c99b56fa238baee3469f56b9 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:30:52 -0800 Subject: [PATCH 62/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 43cc86eb4d..9deb2d0c2f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", inputs.environment]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", ${{ inputs.environment }} ]') || inputs.environment }} env: # Configuration type to build. From 7a7cb83ca14fa1318d9cda2dc7f45e20b6227028 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:32:07 -0800 Subject: [PATCH 63/91] WIP --- .github/workflows/cicd.yml | 2 +- .github/workflows/reusable-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 19f5641472..3dbcaf8722 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -89,7 +89,7 @@ jobs: name: driver_ws2019 build_artifact: Build-x64 # environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 - environment: '1ES.Pool=ebpf-cicd-runner-pool-server-2019' + environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 9deb2d0c2f..c09b639d6f 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", ${{ inputs.environment }} ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "${{ inputs.environment }}" ]') || inputs.environment }} env: # Configuration type to build. From 4926ab73142a9e16e6188bde43c02d5d452a5461 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:33:42 -0800 Subject: [PATCH 64/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index c09b639d6f..7d4ef187ce 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "${{ inputs.environment }}" ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-" + ${{ inputs.environment }} ]') || inputs.environment }} env: # Configuration type to build. From 179fcfd88761629f22bc7f0c6c5c89b20b1753c6 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:34:40 -0800 Subject: [PATCH 65/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 7d4ef187ce..2c71368403 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-" + ${{ inputs.environment }} ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-" + ${ inputs.environment } ]') || inputs.environment }} env: # Configuration type to build. From 070f0c26c84c787abed1cc5ae66ce06142884063 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:35:25 -0800 Subject: [PATCH 66/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 2c71368403..345b153e41 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-" + ${ inputs.environment } ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-"${{ inputs.environment }} ]') || inputs.environment }} env: # Configuration type to build. From f498cdde797208feaccd229f62addfd10adec553 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:37:15 -0800 Subject: [PATCH 67/91] WIP --- .github/workflows/reusable-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 345b153e41..7f9ceb6977 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,7 +73,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", " 1ES.Pool=ebpf-cicd-runner-pool-"${{ inputs.environment }} ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-"inputs.environment ]') || inputs.environment }} env: # Configuration type to build. From 29fd7eef4f2e222f568fcac1fe1bbc213065d85e Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:42:11 -0800 Subject: [PATCH 68/91] WIP --- .github/workflows/reusable-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 7f9ceb6977..62f4d85ecb 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -73,8 +73,6 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-"inputs.environment ]') || inputs.environment }} - env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} @@ -87,6 +85,10 @@ jobs: CXPLAT_MEMORY_LEAK_DETECTION: ${{inputs.leak_detection}} DUMP_PATH: c:/dumps/x64/${{matrix.configurations}} TEST_TIMEOUT: 3600 # 1 hour timeout for tests. + 1ES_POOL: fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-" + ${{inputs.environment}} ]') + + # runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-"inputs.environment ]') || inputs.environment }} + runs-on: ${{ (inputs.self-hosted-runner == true) && env.1ES_POOL || inputs.environment }} steps: - name: Harden Runner From caaebc5004a98af8d264d2cebdc2309f845d8f6a Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:45:55 -0800 Subject: [PATCH 69/91] WIP --- .github/workflows/cicd.yml | 6 ++++++ .github/workflows/reusable-test.yml | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 3dbcaf8722..25834c9ac3 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -70,6 +70,8 @@ jobs: test_command: .\unit_tests.exe -d yes ~[processes] build_artifact: Build-x64 environment: windows-2022 + # environment2: windows-2022 + environment2: '["windows-2022"]' code_coverage: true gather_dumps: true capture_etw: true @@ -90,6 +92,10 @@ jobs: build_artifact: Build-x64 # environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 + environment2: '["self-host", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + + # configurations: '["Debug", "Release"]' + self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 62f4d85ecb..009cbfcd99 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -24,6 +24,10 @@ on: description: 'Environment to run tests on' type: string required: true + environment2: + description: 'Environment to run tests on' + type: string + required: true self-hosted-runner: type: boolean required: false @@ -73,6 +77,8 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} + runs-on: ${{ fromJSON(inputs.environment2) }} + env: # Configuration type to build. SOURCE_ROOT: ${{github.workspace}} @@ -88,7 +94,7 @@ jobs: 1ES_POOL: fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-" + ${{inputs.environment}} ]') # runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-"inputs.environment ]') || inputs.environment }} - runs-on: ${{ (inputs.self-hosted-runner == true) && env.1ES_POOL || inputs.environment }} + # runs-on: ${{ (inputs.self-hosted-runner == true) && env.1ES_POOL || inputs.environment }} steps: - name: Harden Runner From 9eec83ed91b341f52a255bef46ea80f40c4344e9 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:47:24 -0800 Subject: [PATCH 70/91] WIP --- .github/workflows/cicd.yml | 41 ++++++++++++----------------- .github/workflows/reusable-test.yml | 6 +---- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 25834c9ac3..75c66743d8 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -43,24 +43,24 @@ jobs: # --------------------------------------------------------------------------- # Perform the regular build. - # regular: - # # Always run this job. - # if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' - # uses: ./.github/workflows/reusable-build.yml - # with: - # ref: ${{ github.ref }} - # repository: ${{ github.repository }} - # build_artifact: Build-x64 - # generate_release_package: true - # build_msi: true - # build_nuget: true - # build_options: /p:ReleaseJIT='True' - # configurations: '["Debug", "Release"]' + regular: + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64 + generate_release_package: true + build_msi: true + build_nuget: true + build_options: /p:ReleaseJIT='True' + configurations: '["Debug", "Release"]' # Run the unit tests in GitHub. unit_tests: # Always run this job. - # needs: regular + needs: regular if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' uses: ./.github/workflows/reusable-test.yml with: @@ -69,9 +69,7 @@ jobs: # Exclude [processes] test that CodeCoverage can't work with. test_command: .\unit_tests.exe -d yes ~[processes] build_artifact: Build-x64 - environment: windows-2022 - # environment2: windows-2022 - environment2: '["windows-2022"]' + environment: '["windows-2022"]' code_coverage: true gather_dumps: true capture_etw: true @@ -81,7 +79,7 @@ jobs: driver_ws2019: # Always run this job. # Only run this on repos that have self-host runners. - # needs: regular + needs: regular if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') uses: ./.github/workflows/reusable-test.yml with: @@ -90,12 +88,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - # environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 - environment: 1ES.Pool=ebpf-cicd-runner-pool-server-2019 - environment2: '["self-host", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' - - # configurations: '["Debug", "Release"]' - + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 009cbfcd99..b9b724022b 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -77,7 +77,7 @@ jobs: matrix: configurations: ${{ fromJSON(inputs.configurations) }} - runs-on: ${{ fromJSON(inputs.environment2) }} + runs-on: ${{ fromJSON(inputs.environment) }} env: # Configuration type to build. @@ -91,10 +91,6 @@ jobs: CXPLAT_MEMORY_LEAK_DETECTION: ${{inputs.leak_detection}} DUMP_PATH: c:/dumps/x64/${{matrix.configurations}} TEST_TIMEOUT: 3600 # 1 hour timeout for tests. - 1ES_POOL: fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-" + ${{inputs.environment}} ]') - - # runs-on: ${{ (inputs.self-hosted-runner == true) && fromJSON('["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-"inputs.environment ]') || inputs.environment }} - # runs-on: ${{ (inputs.self-hosted-runner == true) && env.1ES_POOL || inputs.environment }} steps: - name: Harden Runner From 061bcab563d5ffe1175400ed406b8c6f90abfa4e Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 15:50:06 -0800 Subject: [PATCH 71/91] WIP --- .github/workflows/reusable-test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index b9b724022b..38a459d56e 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -24,10 +24,6 @@ on: description: 'Environment to run tests on' type: string required: true - environment2: - description: 'Environment to run tests on' - type: string - required: true self-hosted-runner: type: boolean required: false From 6f7db553e440b60e2c3529838f5fd8526dfa7a7b Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 16:43:41 -0800 Subject: [PATCH 72/91] add back in all tests to see what breaks --- .github/workflows/cicd.yml | 564 +++++++++++++++++++++++++++- .github/workflows/reusable-test.yml | 23 +- 2 files changed, 571 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 75c66743d8..ec1c808786 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -55,7 +55,58 @@ jobs: build_msi: true build_nuget: true build_options: /p:ReleaseJIT='True' - configurations: '["Debug", "Release"]' + configurations: '["Debug", "FuzzerDebug", "Release"]' + + onebranch: + strategy: + matrix: + Architecture: ['x64', 'ARM64'] + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-${{ matrix.Architecture }}-onebranch + generate_release_package: true + build_msi: true + build_nuget: true + configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + build_options: /p:BuildOneBranch='True' /t:tools\onebranch /t:installer\ebpf-for-windows + solution_file: "ebpf-for-windows.sln" + architecture: ${{ matrix.Architecture }} + download_demo_repository: false + + # Perform the native-only build. + regular_native-only: + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64-native-only + build_msi: true + build_nuget: true + configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + + # Run the unit tests in GitHub. + unit_tests_appverif: + # Always run this job. + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: unit_tests + pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe + # Exclude [processes] test that CodeCoverage can't work with. + test_command: .\unit_tests.exe -d yes ~[processes] + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: true + gather_dumps: true + capture_etw: true + leak_detection: true # Run the unit tests in GitHub. unit_tests: @@ -75,6 +126,74 @@ jobs: capture_etw: true leak_detection: true + # Run the unit tests for NativeOnly build in GitHub. + unit_tests_native_only: + # Always run this job. + needs: regular_native-only + uses: ./.github/workflows/reusable-test.yml + with: + name: unit_tests + pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe + # Exclude [processes] test that CodeCoverage can't work with. + test_command: .\unit_tests.exe -d yes ~[processes] + build_artifact: Build-x64-native-only + environment: '["windows-2022"]' + code_coverage: true + gather_dumps: true + capture_etw: true + leak_detection: true + configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + + # Run the netebpfext unit tests in GitHub. + netebpf_ext_unit_tests: + # Always run this job. + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: netebpf_ext_unit_tests + pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe + test_command: .\netebpfext_unit.exe -d yes + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: true + gather_dumps: true + capture_etw: true + leak_detection: true + + # Run the bpf2c tests in GitHub. + bpf2c: + # Always run this job. + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + test_command: .\bpf2c_tests.exe -d yes + name: bpf2c + build_artifact: Build-x64 + environment: '["windows-2022"]' + vs_dev: true + code_coverage: true + gather_dumps: true + capture_etw: true + + # Run the bpf2c conformance tests in GitHub. + bpf2c_conformance: + # Always run this job. + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.6/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe + test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include" + name: bpf2c_conformance + build_artifact: Build-x64 + environment: '["windows-2022"]' + vs_dev: true + code_coverage: true + gather_dumps: true + capture_etw: true + # Run the driver tests on self-hosted runners. driver_ws2019: # Always run this job. @@ -89,8 +208,447 @@ jobs: name: driver_ws2019 build_artifact: Build-x64 environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' - self-hosted-runner: true # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage - code_coverage: false \ No newline at end of file + code_coverage: false + + # Run the driver tests on self-hosted runners. + driver_ws2022: + # Always run this job. + # Only run this on repos that have self-host runners. + needs: regular + if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + name: driver_ws2022 + build_artifact: Build-x64 + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + # driver test copies dumps to testlog folder. + gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false + + # Run the native-only driver tests on self-hosted runners. + driver_native_only_ws2019: + # Always run this job. + # Only run this on repos that have self-host runners. + needs: regular_native-only + if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + name: driver_native_only_ws2019 + build_artifact: Build-x64-native-only + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + # driver test copies dumps to testlog folder. + gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false + configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + + driver_native_only_ws2022: + # Always run this job. + # Only run this on repos that have self-host runners. + needs: regular_native-only + if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + name: driver_native_only_ws2022 + build_artifact: Build-x64-native-only + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + # driver test copies dumps to testlog folder. + gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false + configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + + # Run the regression driver tests on self-hosted runners (only for 2022). + regression_driver_ws2022: + # Always run this job. + # Only run this on repos that have self-host runners. + needs: regular + if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" -TestMode "Regression" -RegressionArtifactsVersion "0.17.0" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Regression" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + name: regression_driver_ws2022 + build_artifact: Build-x64 + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + # driver test copies dumps to testlog folder. + gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false + + ossar: + # Always run this job. + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/ossar-scan.yml + with: + build_artifact: Build-x64 + + # Additional jobs to run on pull and schedule only (skip push). + # --------------------------------------------------------------------------- + # Build with C++ static analyzer. + analyze: + # Only run on schedule and pull request. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64-Analyze + # Analysis on external projects is conditional, as on small CI/CD VMs the compiler can run OOM + build_options: /p:Analysis='True' /p:AnalysisOnExternal='False' + + # Build with C++ address sanitizer. + sanitize: + # Only run on schedule and pull request. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64-Sanitize + build_options: /p:AddressSanitizer='True' + + bpf2c_fuzzer: + needs: regular + if: github.event_name == 'pull_request' || github.event_name == 'merge_group' + uses: ./.github/workflows/reusable-test.yml + with: + name: bpf2c_fuzzer + test_command: .\bpf2c_fuzzer.exe bpf2c_fuzzer_corpus -use_value_profile=1 -max_total_time=300 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + bpf2c_fuzzer_scheduled: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: bpf2c_fuzzer + test_command: .\bpf2c_fuzzer.exe bpf2c_fuzzer_corpus -use_value_profile=1 -max_total_time=900 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + execution_context_fuzzer: + needs: regular + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: execution_context_fuzzer + test_command: .\execution_context_fuzzer.exe execution_context_fuzzer_corpus -use_value_profile=1 -runs=3000 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + # Run the verifier fuzzer. + verifier_fuzzer: + needs: regular + # Always run this job. + if: github.event_name == 'pull_request' || github.event_name == 'merge_group' + uses: ./.github/workflows/reusable-test.yml + with: + name: verifier_fuzzer + test_command: .\verifier_fuzzer.exe verifier_corpus -use_value_profile=1 -max_total_time=300 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + verifier_fuzzer_scheduled: + needs: regular + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: verifier_fuzzer + test_command: .\verifier_fuzzer.exe verifier_corpus -use_value_profile=1 -max_total_time=900 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + core_helper_fuzzer: + needs: regular + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: core_helper_fuzzer + test_command: .\core_helper_fuzzer core_helper_corpus -max_len=139 -runs=1000 -use_value_profile=1 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + netebpfext_fuzzer: + needs: regular + # Always run this job. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: netebpfext_fuzzer + test_command: .\netebpfext_fuzzer netebpfext_corpus -max_len=12 -runs=1000 -use_value_profile=1 -artifact_prefix=Artifacts\ + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + configurations: '["FuzzerDebug"]' + + # Run Cilium regression tests in GitHub. + cilium_tests: + needs: regular + # Only run on schedule and pull request. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: cilium_tests + test_command: .\cilium_tests.exe -d yes + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + + # Run the quick stress tests in GitHub. + stress: + needs: regular + # Only run on schedule and pull request. + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: stress + # Until there is a dedicated stress test, re-use the perf test. + test_command: .\ebpf_performance.exe -d yes + build_artifact: Build-x64 + environment: '["windows-2022"]' + # No code coverage on stress. + code_coverage: false + gather_dumps: true + + # Run the unit tests in GitHub with address sanitizer. + sanitize_unit_tests: + needs: sanitize + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: unit_tests + # Exclude [processes] test that ASAN can't work with. + test_command: .\unit_tests.exe -d yes ~[processes] + build_artifact: Build-x64-Sanitize + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + capture_etw: true + + # Run the fault injection simulator in GitHub. + fault_injection: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: fault_injection + test_command: .\unit_tests.exe + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: true + gather_dumps: true + fault_injection: true + leak_detection: true + + # Run the low memory simulator for netebpfext_unit tests. + fault_injection_netebpfext_unit: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: netebpfext_fault_injection + test_command: .\netebpfext_unit.exe + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: true + gather_dumps: true + fault_injection: true + leak_detection: true + + # Run a fast multi-threaded stress test pass against the usersim user-mode 'mock' framework. + # Added as a 'per-PR' test to catch usersim regressions and/or run-time usage issues. + quick_user_mode_multi_threaded_stress_test: + needs: regular + if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' + uses: ./.github/workflows/reusable-test.yml + with: + name: quick_user_mode_multi_threaded_stress + test_command: .\ebpf_stress_tests_um -tt=8 -td=2 + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + leak_detection: false + gather_dumps: true + capture_etw: true + + # Additional jobs to run on a schedule only (skip push and pull request). + # --------------------------------------------------------------------------- + codeql: + # Only run during daily scheduled run + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-build.yml + with: + ref: ${{ github.ref }} + repository: ${{ github.repository }} + build_artifact: Build-x64-CodeQl + build_codeql: true + + + # Run the complete fault injection simulator in GitHub. + # Runs on a schedule as this takes a long time to run. + fault_injection_full: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: fault_injection_full + test_command: .\unit_tests.exe + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + fault_injection: true + leak_detection: true + + # Run the complete fault injection simulator for netebpfext in GitHub. + # Runs on a schedule as this takes a long time to run. + netebpfext_fault_injection_full: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: netebpfext_fault_injection_full + test_command: .\netebpfext_unit.exe + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + gather_dumps: true + fault_injection: true + + # Run multi-threaded stress tests against the user mode 'mock' framework. + user_mode_multi_threaded_stress_test: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: user_mode_multi_threaded_stress + test_command: .\ebpf_stress_tests_um -tt=8 -td=10 + build_artifact: Build-x64 + environment: '["windows-2022"]' + code_coverage: false + leak_detection: false + gather_dumps: true + capture_etw: true + + # Run multi-threaded stress tests with 'restart extension' disabled (default behavior) + # against the kernel mode eBPF sub-system. + km_mt_stress_tests: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: km_mt_stress_tests + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "memory" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + build_artifact: Build-x64 + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + code_coverage: false + # For this test, we only want kernel mode dumps and not user mode dumps. + gather_dumps: false + + # Run multi-threaded stress tests with 'restart extension' enabled + # against the kernel mode eBPF sub-system. + km_mt_stress_tests_restart_extension: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: km_mt_stress_tests_restart_extension + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "memory" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" -Options @("RestartExtension") + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + build_artifact: Build-x64 + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + code_coverage: false + # For this test, we only want kernel mode dumps and not user mode dumps. + gather_dumps: false + + # Not sure what perf is - probably selfhosted runner, but do we need to support this now? + # performance: + # needs: regular + # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + # uses: ./.github/workflows/reusable-test.yml + # with: + # name: km_performance + # pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" + # test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Performance" + # post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + # build_artifact: Build-x64 + # environment: ebpf_cicd_perf_ws2022 + # configurations: '["Release"]' + + netperf: + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/netperf.yml + with: + sha: ${{ github.sha }} + ref: ${{ github.ref }} + pull_request: ${{ github.event.pull_request.number }} + secrets: + NET_PERF_TRIGGER: ${{ secrets.NET_PERF_TRIGGER }} + + upload_perf_results: + needs: performance + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/upload-perf-results.yml + with: + name: upload_perf_results + result_artifact: km_performance-x64-Release + secrets: + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + upload_netperf_results_lab_2022: + needs: netperf + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/upload-perf-results.yml + with: + name: upload_netperf_results_lab_2022 + result_artifact: netperf_lab_2022_x64 + platform: Lab Windows 2022 + secrets: + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 38a459d56e..3832623452 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -24,9 +24,6 @@ on: description: 'Environment to run tests on' type: string required: true - self-hosted-runner: - type: boolean - required: false # Set to true to gather code coverage when this test runs. code_coverage: required: false @@ -96,7 +93,7 @@ jobs: - name: Configure runner (Move to setup script directly later) id: configure-runner - if: (inputs.self-hosted-runner == true) + if: contains(inputs.environment, 'self-hosted') run: | powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" # powershell.exe "Get-NetAdapter" @@ -125,7 +122,7 @@ jobs: # Perform shallow checkout for self-hosted runner. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - if: (inputs.self-hosted-runner == true) && (steps.skip_check.outputs.should_skip != 'true') + if: contains(inputs.environment, 'self-hosted') && (steps.skip_check.outputs.should_skip != 'true') with: ref: ${{ github.event.workflow_run.head_branch }} @@ -174,7 +171,7 @@ jobs: - name: Set up OpenCppCoverage and add to PATH id: set_up_opencppcoverage - if: (inputs.code_coverage == true) && (inputs.self-hosted-runner != true) && (steps.skip_check.outputs.should_skip != 'true') + if: (inputs.code_coverage == true) && !contains(inputs.environment, 'self-hosted') && (steps.skip_check.outputs.should_skip != 'true') run: | choco install -y --requirechecksum=true --checksum=2295A733DA39412C61E4F478677519DD0BB1893D88313CE56B468C9E50517888 --checksum-type=sha256 OpenCppCoverage echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append @@ -191,7 +188,7 @@ jobs: New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "$dump_path" -PropertyType ExpandString -ErrorAction SilentlyContinue - name: Remove existing artifacts - if: (inputs.self-hosted-runner == true) && (steps.skip_check.outputs.should_skip != 'true') + if: contains(inputs.environment, 'self-hosted') && (steps.skip_check.outputs.should_skip != 'true') run: | Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue @@ -248,14 +245,14 @@ jobs: .\export_program_info_sample.exe - name: Run pre test command - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner != true) + if: steps.skip_check.outputs.should_skip != 'true' && !contains(inputs.environment, 'self-hosted') id: run_pre_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.PRE_COMMAND}} - name: Run pre test command on self-hosted runner - if: steps.skip_check.outputs.should_skip != 'true' && (inputs.self-hosted-runner == true) + if: steps.skip_check.outputs.should_skip != 'true' && contains(inputs.environment, 'self-hosted') id: run_pre_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -297,14 +294,14 @@ jobs: OpenCppCoverage.exe -q --sources %CD% --excluded_sources %CD%\external\Catch2 --export_type cobertura:ebpf_for_windows.xml --working_dir ${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -- powershell .\Run-Test.ps1 ${{env.DUMP_PATH}} ${{env.TEST_TIMEOUT}} ${{env.TEST_COMMAND}} - name: Run test on self-hosted runner - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') && (inputs.fault_injection != true) id: run_test_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') && (inputs.fault_injection != true) id: run_test_without_code_coverage working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} shell: cmd @@ -314,7 +311,7 @@ jobs: - name: Run post test command # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') id: run_post_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | @@ -322,7 +319,7 @@ jobs: - name: Run post test command on self-hosted runner # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && (inputs.self-hosted-runner == true) + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') id: run_post_test_command_self_hosted working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | From 57c36eb7d015b61f44cb95de9f46c2af780c3fe7 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 16:46:41 -0800 Subject: [PATCH 73/91] WIP --- .github/workflows/cicd.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ec1c808786..76c28b53ac 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -271,6 +271,26 @@ jobs: code_coverage: false configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' + # TODO - this is only for initial testing - revert this later + # Run the regression driver tests on self-hosted runners (only for 2019). + regression_driver_ws2019: + # Always run this job. + # Only run this on repos that have self-host runners. + needs: regular + if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') + uses: ./.github/workflows/reusable-test.yml + with: + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" -TestMode "Regression" -RegressionArtifactsVersion "0.17.0" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Regression" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + name: regression_driver_ws2019 + build_artifact: Build-x64 + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + # driver test copies dumps to testlog folder. + gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false + # Run the regression driver tests on self-hosted runners (only for 2022). regression_driver_ws2022: # Always run this job. @@ -574,7 +594,9 @@ jobs: # against the kernel mode eBPF sub-system. km_mt_stress_tests: needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + # TODO - revert this back + # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' uses: ./.github/workflows/reusable-test.yml with: name: km_mt_stress_tests @@ -591,7 +613,9 @@ jobs: # against the kernel mode eBPF sub-system. km_mt_stress_tests_restart_extension: needs: regular - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + # TODO - revert this back + # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' uses: ./.github/workflows/reusable-test.yml with: name: km_mt_stress_tests_restart_extension From 2f269a6dc2ed2366ed2d401699d7d1aa015ed348 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 13 Dec 2024 16:47:08 -0800 Subject: [PATCH 74/91] WIP --- .github/workflows/cicd.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 76c28b53ac..e6ceb2134e 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -628,19 +628,20 @@ jobs: # For this test, we only want kernel mode dumps and not user mode dumps. gather_dumps: false + # TODO - figure this out... # Not sure what perf is - probably selfhosted runner, but do we need to support this now? - # performance: - # needs: regular - # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - # uses: ./.github/workflows/reusable-test.yml - # with: - # name: km_performance - # pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" - # test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Performance" - # post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - # build_artifact: Build-x64 - # environment: ebpf_cicd_perf_ws2022 - # configurations: '["Release"]' + performance: + needs: regular + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/reusable-test.yml + with: + name: km_performance + pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" + test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Performance" + post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true + build_artifact: Build-x64 + environment: ebpf_cicd_perf_ws2022 + configurations: '["Release"]' netperf: if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' From 0ae97f4dc008a356e6bbca15515cab42a68d81ae Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Mon, 16 Dec 2024 12:29:50 -0800 Subject: [PATCH 75/91] WIP --- .github/workflows/cicd.yml | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e6ceb2134e..de54f7fc0b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -207,7 +207,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2019 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -226,7 +226,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -245,7 +245,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2019 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -264,33 +264,13 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage code_coverage: false configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]' - # TODO - this is only for initial testing - revert this later - # Run the regression driver tests on self-hosted runners (only for 2019). - regression_driver_ws2019: - # Always run this job. - # Only run this on repos that have self-host runners. - needs: regular - if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') - uses: ./.github/workflows/reusable-test.yml - with: - pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file" -TestMode "Regression" -RegressionArtifactsVersion "0.17.0" - test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Regression" - post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true - name: regression_driver_ws2019 - build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' - # driver test copies dumps to testlog folder. - gather_dumps: false - # driver tests manually gather code coverage - code_coverage: false - # Run the regression driver tests on self-hosted runners (only for 2022). regression_driver_ws2022: # Always run this job. @@ -304,7 +284,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: regression_driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -604,7 +584,7 @@ jobs: test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' code_coverage: false # For this test, we only want kernel mode dumps and not user mode dumps. gather_dumps: false @@ -623,7 +603,7 @@ jobs: test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" -Options @("RestartExtension") post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' code_coverage: false # For this test, we only want kernel mode dumps and not user mode dumps. gather_dumps: false From 91f3a84d4f42155b66580f7b1353cf836ac9fdbb Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Mon, 16 Dec 2024 16:03:02 -0800 Subject: [PATCH 76/91] WIP --- .github/workflows/cicd.yml | 4 +- .github/workflows/reusable-test.yml | 5 --- 1es/Setup_orig.ps1 | 68 +++++++++++++++++++---------- 1es/configure_vm.ps1 | 4 +- 1es/prepare_vm_helpers.psm1 | 19 ++++---- 5 files changed, 59 insertions(+), 41 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index de54f7fc0b..e0124388e5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -264,7 +264,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -284,7 +284,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: regression_driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2022", "1ES.ImageOverride=ebpf-cicd-image-server-2019"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 3832623452..b1259278f7 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -96,11 +96,6 @@ jobs: if: contains(inputs.environment, 'self-hosted') run: | powershell.exe "cd C:\bin\CloudTestWorker\ProvisioningScript; dir; .\Setup_orig.ps1" - # powershell.exe "Get-NetAdapter" - # powershell.exe "Get-VMSwitch" - # powershell.exe "Get-NetAdapter" - # powershell.exe "Get-VMSwitch" - # powershell.exe "Get-VM" - name: Print CPU information run: diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 77e2cb5841..a7edab1932 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -9,7 +9,6 @@ param( [Parameter(Mandatory=$False)][string]$BaseVhdDirPath='.\', [Parameter(Mandatory=$False)][string]$WorkingPath='.\working', [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', - [Parameter(Mandatory=$False)][string]$ExternalSwitchName='VMExternalSwitch', [Parameter(Mandatory=$False)][string]$VMCpuCount=4, [Parameter(Mandatory=$False)][string]$VMMemory=4096MB @@ -28,13 +27,29 @@ if (-not (Test-Path -Path $BaseVhdDirPath)) { throw "VHD directory not found at $BaseVhdDirPath" } -# Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType 'Internal' +Create-VMSwitchIfNeeded -SwitchName 'VMInternalSwitch' -SwitchType 'Internal' Create-VMSwitchIfNeeded -SwitchName 'VMExternalSwitch' -SwitchType 'External' # Stored credentials doesn't seem to be working... # Create-VMStoredCredential -CredentialName "TEST_VM" -Username $VmUsername -Password $VmPassword # Create-VMStoredCredential -CredentialName "TEST_VM_STANDARD" -Username $VmStandardUserName -Password $VmPassword Create-DirectoryIfNotExists -Path $WorkingPath +# Unzip any VHDs +$zipFiles = Get-ChildItem -Path $BaseVhdDirPath -Filter *.zip +foreach ($zipFile in $zipFiles) { + $outDir = Join-Path -Path $BaseVhdDirPath -ChildPath $zipFile.BaseName + if (-not (Test-Path -Path $outDir)) { + Expand-Archive -Path $zipFile.FullName -DestinationPath $outDir + + # Move the VHDs to the base directory + $vhdFiles = Get-ChildItem -Path $outDir -Filter *.vhd -ErrorAction Ignore + $vhdFiles += Get-ChildItem -Path $outDir -Filter *.vhdx -ErrorAction Ignore + foreach ($vhdFile in $vhdFiles) { + Move-Item -Path $vhdFile.FullName -Destination $BaseVhdDirPath + } + } +} + # Read the input VHDs $vhds = @((Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhd)) $vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhdx @@ -43,27 +58,34 @@ if ($vhds.Count -eq 0) { } for ($i = 0; $i -lt $vhds.Count; $i++) { - $vhd = $vhds[$i] - Log-Message -Message "Processing VHD: $($vhd.FullName)" - $vmName = "runner_vm" - if ($i -gt 0) { - $vmName += "_$i" - } - $outVMPath = Join-Path -Path $WorkingPath -ChildPath $VMName + try { + $vhd = $vhds[$i] + Log-Message -Message "Processing VHD: $($vhd.FullName)" + $vmName = "runner_vm" + if ($i -gt 0) { + $vmName += "_$i" + } + $outVMPath = Join-Path -Path $WorkingPath -ChildPath $VMName + + Create-VM ` + -VmName $vmName ` + -VhdPath $vhd.FullName ` + -VmStoragePath $outVMPath ` + -VMMemory $VMMemory ` + -UnattendPath $BaseUnattendPath ` + -VmUsername $VmUsername ` + -VmPassword $VmPassword - Create-VM ` - -VmName $vmName ` - -VhdPath $vhd.FullName ` - -VmStoragePath $outVMPath ` - -ExternalVMSwitchName $ExternalSwitchName ` - -VMMemory $VMMemory ` - -UnattendPath $BaseUnattendPath ` - -VmUsername $VmUsername ` - -VmPassword $VmPassword + Configure-VM ` + -VmName $vmName ` + -VmUsername $VmUsername ` + -VmPassword $VmPassword ` + -CpuCount $CpuCount - Configure-VM ` - -VmName $vmName ` - -CpuCount $VMCpuCount ` - -VmUsername $VmUsername ` - -VmPassword $VmPassword + Log-Message "VM $vmName created successfully" + } catch { + Log-Message "Failed to create VM $vmName: $_" + } } + +Log-Message "Setup.ps1 complete!" \ No newline at end of file diff --git a/1es/configure_vm.ps1 b/1es/configure_vm.ps1 index 32a1768c8d..43e5f3ce05 100644 --- a/1es/configure_vm.ps1 +++ b/1es/configure_vm.ps1 @@ -121,11 +121,11 @@ foreach ($adapter in $adapters) { } } -Get-NetAdapterBinding -AllBindings +Get-NetAdapterBinding -AllBindings | Out-String ipconfig /all -Get-NetIPInterface +Get-NetIPInterface | Out-String # Reboot the machine to apply the changes. Restart-Computer -Force \ No newline at end of file diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index d6b6f4554f..2404764252 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -149,7 +149,6 @@ function Create-VM { [Parameter(Mandatory=$True)][string]$VmPassword, [Parameter(Mandatory=$True)][string]$VhdPath, [Parameter(Mandatory=$True)][string]$VmStoragePath, - [Parameter(Mandatory=$True)][string]$ExternalVMSwitchName, [Parameter(Mandatory=$True)][Int64]$VMMemory, [Parameter(Mandatory=$True)][string]$UnattendPath ) @@ -191,7 +190,7 @@ function Create-VM { # Create the VM Log-Message "Creating the VM" New-VM -Name $VmName -VhdPath $VmVhdPath - $vmSwitches = Get-VMSwitch + $vmSwitches = Get-VMSwitch -ErrorAction Ignore foreach ($switch in $vmSwitches) { Log-Message "Adding network adapter to VM: $VmName with switch: $($switch.Name)" Add-VMNetworkAdapter -VMName $VmName -SwitchName $switch.Name @@ -238,10 +237,10 @@ function Configure-VM { Log-Message "Sleeping for 1 minute to let the VM get into a steady state" Sleep -Seconds 60 # Sleep for 1 minute to let the VM get into a steady state. - # Fetch all updates on the VM - Log-Message "Fetching Updates on the VM" - # Update-VM -VMName $VmName -VmCredential $VmCredential - Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green + # # Fetch all updates on the VM + # Log-Message "Fetching Updates on the VM" + # # Update-VM -VMName $VmName -VmCredential $VmCredential + # Log-Message -Message "Successfully updated VM: $VMName" -ForegroundColor Green # Copy setup script to the VM and execute it. Log-Message "Executing VM configuration script ($VMSetupScript) on VM: $VmName" @@ -266,6 +265,8 @@ function Configure-VM { continue } } + + Log-Message "Successfully configured VM: $VmName" -ForegroundColor Green } catch { throw "Failed to configure VM: $VmName. Error: $_" } @@ -297,7 +298,7 @@ function Create-VMSwitchIfNeeded { try { if ($SwitchType -eq 'External') { # Check to see if an external switch already exists - $ExternalSwitches = (Get-VMSwitch -SwitchType External) + $ExternalSwitches = (Get-VMSwitch -SwitchType External -ErrorAction Ignore) if ($ExternalSwitches -ne $null) { Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" return @@ -311,7 +312,7 @@ function Create-VMSwitchIfNeeded { if ([string]::IsNullOrEmpty($NetAdapterName)) { continue } - $switchName = $ExternalSwitchName + '-' + $index + $switchName = $SwitchName + '-' + $index Log-Message "Attempting to creating external switch: $switchName with NetAdapter: $NetAdapterName" New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true # break @@ -321,7 +322,7 @@ function Create-VMSwitchIfNeeded { } } elseif ($SwitchType -eq 'Internal') { # Check to see if an internal switch already exists - $InternalSwitches = (Get-VMSwitch -SwitchType Internal) + $InternalSwitches = (Get-VMSwitch -SwitchType Internal -ErrorAction Ignore) if ($InternalSwitches -ne $null) { Log-Message -Message "Internal switch already exists: $($InternalSwitches[0].Name)" return From dfedb27b7ea270d0c477905d1c6770b24b83499b Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Mon, 16 Dec 2024 16:44:10 -0800 Subject: [PATCH 77/91] WIP --- 1es/Setup_orig.ps1 | 2 +- 1es/prepare_vm_helpers.psm1 | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index a7edab1932..7c651a0ea4 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -84,7 +84,7 @@ for ($i = 0; $i -lt $vhds.Count; $i++) { Log-Message "VM $vmName created successfully" } catch { - Log-Message "Failed to create VM $vmName: $_" + Log-Message "Failed to create VM $vmName with error $_" } } diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 2404764252..17c4c34ca3 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -28,7 +28,7 @@ function Create-DirectoryIfNotExists { throw "Failed to create directory: $Path" } } catch { - throw "Failed to create directory: $Path. $_" + throw "Failed to create directory: $Path with error $_" } } @@ -77,7 +77,7 @@ function Execute-CommandOnVM { Log-Message -Message "Executed command on VM: $VMName. Command: $Command. Result: $result" } catch { - throw "Failed to execute command on VM: $VMName. Error: $_" + throw "Failed to execute command on VM: $VMName with error: $_" } } @@ -203,7 +203,7 @@ function Create-VM { Log-Message -Message "Successfully created VM: $VMName" -ForegroundColor Green } catch { - throw "Failed to create VM: $VmName. Error: $_" + throw "Failed to create VM: $VmName with error: $_" } } @@ -268,7 +268,7 @@ function Configure-VM { Log-Message "Successfully configured VM: $VmName" -ForegroundColor Green } catch { - throw "Failed to configure VM: $VmName. Error: $_" + throw "Failed to configure VM: $VmName with error: $_" } } @@ -286,7 +286,7 @@ function Install-HyperVIfNeeded { exit 1 } } catch { - throw "Failed to install Hyper-V: $_" + throw "Failed to install Hyper-V with error: $_" } } @@ -317,7 +317,7 @@ function Create-VMSwitchIfNeeded { New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true # break } catch { - Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName $_" + Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName with error: $_" } } } elseif ($SwitchType -eq 'Internal') { @@ -335,7 +335,7 @@ function Create-VMSwitchIfNeeded { throw "Invalid switch type: $SwitchType" } } catch { - throw "Failed to create external switch: $_" + throw "Failed to create external switch with error: $_" } } @@ -351,7 +351,6 @@ function Create-VMStoredCredential { New-StoredCredential -Target $CredentialName -UserName $Username -Password $Password -Type Generic -Persist LocalMachine } catch { - Log-Message "Failed to create stored credential: $_" -ForegroundColor Red - # throw "Failed to create stored credential: $_" + Log-Message "Failed to create stored credential with error $_" -ForegroundColor Red } } \ No newline at end of file From 5456831c6c5d0537f0cfe2a7e21766b609862cd5 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Mon, 16 Dec 2024 17:13:22 -0800 Subject: [PATCH 78/91] WIP --- 1es/prepare_vm_helpers.psm1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 17c4c34ca3..9e1d0a9426 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -312,9 +312,10 @@ function Create-VMSwitchIfNeeded { if ([string]::IsNullOrEmpty($NetAdapterName)) { continue } - $switchName = $SwitchName + '-' + $index - Log-Message "Attempting to creating external switch: $switchName with NetAdapter: $NetAdapterName" - New-VMSwitch -Name $switchName -NetAdapterName $NetAdapterName -AllowManagementOS $true + $currSwitchName = $SwitchName + '-' + $index + Log-Message "Attempting to creating external switch: $currSwitchName with NetAdapter: $NetAdapterName" + New-VMSwitch -Name $currSwitchName -NetAdapterName $NetAdapterName -AllowManagementOS $true + $index += 1 # break } catch { Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName with error: $_" From 93255f3632ea7011401fb59ef4d59bc9bd772035 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 09:28:03 -0800 Subject: [PATCH 79/91] WIP --- 1es/Setup_orig.ps1 | 19 +++++++--- 1es/prepare_vm_helpers.psm1 | 76 +++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 7c651a0ea4..3d54330690 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -7,8 +7,9 @@ param( [Parameter(Mandatory=$False)][string]$BaseUnattendPath='.\unattend.xml', [Parameter(Mandatory=$False)][string]$BaseVhdDirPath='.\', - [Parameter(Mandatory=$False)][string]$WorkingPath='.\working', - [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', + # [Parameter(Mandatory=$False)][string]$WorkingPath='.\working', + [Parameter(Mandatory=$False)][string]$WorkingPath='C:\vms', + # [Parameter(Mandatory=$False)][string]$OutVhdDirPath='.\exported_vhds', [Parameter(Mandatory=$False)][string]$VMCpuCount=4, [Parameter(Mandatory=$False)][string]$VMMemory=4096MB @@ -35,32 +36,38 @@ Create-VMSwitchIfNeeded -SwitchName 'VMExternalSwitch' -SwitchType 'External' Create-DirectoryIfNotExists -Path $WorkingPath # Unzip any VHDs +Log-Message "Processing VHDs in $BaseVhdDirPath" $zipFiles = Get-ChildItem -Path $BaseVhdDirPath -Filter *.zip foreach ($zipFile in $zipFiles) { + Log-Message "Extracting VHDs from $($zipFile.FullName)" $outDir = Join-Path -Path $BaseVhdDirPath -ChildPath $zipFile.BaseName if (-not (Test-Path -Path $outDir)) { Expand-Archive -Path $zipFile.FullName -DestinationPath $outDir # Move the VHDs to the base directory - $vhdFiles = Get-ChildItem -Path $outDir -Filter *.vhd -ErrorAction Ignore + $vhdFiles = @() + $vhdFiles += Get-ChildItem -Path $outDir -Filter *.vhd -ErrorAction Ignore $vhdFiles += Get-ChildItem -Path $outDir -Filter *.vhdx -ErrorAction Ignore foreach ($vhdFile in $vhdFiles) { Move-Item -Path $vhdFile.FullName -Destination $BaseVhdDirPath } } + Log-Message "Successfully processed $($zipFile.FullName)" } # Read the input VHDs -$vhds = @((Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhd)) -$vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhdx +$vhds = @() +$vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhd -ErrorAction Ignore +$vhds += Get-ChildItem -Path $BaseVhdDirPath -Filter *.vhdx -ErrorAction Ignore if ($vhds.Count -eq 0) { throw "No VHDs found in $BaseVhdDirPath" } +Log-Message "Successfully processed VHDs" for ($i = 0; $i -lt $vhds.Count; $i++) { try { $vhd = $vhds[$i] - Log-Message -Message "Processing VHD: $($vhd.FullName)" + Log-Message -Message "Creating VM from VHD: $($vhd.FullName)" $vmName = "runner_vm" if ($i -gt 0) { $vmName += "_$i" diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 9e1d0a9426..47fee26719 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -292,52 +292,54 @@ function Install-HyperVIfNeeded { function Create-VMSwitchIfNeeded { param ( - [Parameter(Mandatory=$False)][string]$SwitchName='VMInternalSwitch', - [Parameter(Mandatory=$False)][string]$SwitchType='Internal' + [Parameter(Mandatory=$true)][string]$SwitchName, + [Parameter(Mandatory=$true)][string]$SwitchType ) - try { - if ($SwitchType -eq 'External') { - # Check to see if an external switch already exists - $ExternalSwitches = (Get-VMSwitch -SwitchType External -ErrorAction Ignore) - if ($ExternalSwitches -ne $null) { - Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" - return - } + if ($SwitchType -eq 'External') { + # Check to see if an external switch already exists + $ExternalSwitches = (Get-VMSwitch -SwitchType External -ErrorAction Ignore) + if ($ExternalSwitches -ne $null) { + Log-Message -Message "External switch already exists: $($ExternalSwitches[0].Name)" + return + } - # Try to create the external switch - $NetAdapterNames = (Get-NetAdapter -Name 'Ethernet*' | Where-Object { $_.Status -eq 'Up' }).Name - $index = 0 - foreach ($NetAdapterName in $NetAdapterNames) { - try { - if ([string]::IsNullOrEmpty($NetAdapterName)) { - continue - } - $currSwitchName = $SwitchName + '-' + $index - Log-Message "Attempting to creating external switch: $currSwitchName with NetAdapter: $NetAdapterName" - New-VMSwitch -Name $currSwitchName -NetAdapterName $NetAdapterName -AllowManagementOS $true - $index += 1 - # break - } catch { - Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName with error: $_" + # Try to create the external switch + $NetAdapterNames = (Get-NetAdapter -Name 'Ethernet*' | Where-Object { $_.Status -eq 'Up' }).Name + $index = 0 + foreach ($NetAdapterName in $NetAdapterNames) { + try { + if ([string]::IsNullOrEmpty($NetAdapterName)) { + continue } + $currSwitchName = $SwitchName + '-' + $index + Log-Message "Attempting to creating external switch: $currSwitchName with NetAdapter: $NetAdapterName" + New-VMSwitch -Name $currSwitchName -NetAdapterName $NetAdapterName -AllowManagementOS $true + $index += 1 + # break + } catch { + Log-Message "Failed to create external switch for NetAdapter: $NetAdapterName with error: $_" } - } elseif ($SwitchType -eq 'Internal') { - # Check to see if an internal switch already exists - $InternalSwitches = (Get-VMSwitch -SwitchType Internal -ErrorAction Ignore) - if ($InternalSwitches -ne $null) { - Log-Message -Message "Internal switch already exists: $($InternalSwitches[0].Name)" - return - } + } + } elseif ($SwitchType -eq 'Internal') { + # Check to see if an internal switch already exists + $InternalSwitches = (Get-VMSwitch -SwitchType Internal -ErrorAction Ignore) + if ($InternalSwitches -ne $null) { + Log-Message -Message "Internal switch already exists: $($InternalSwitches[0].Name)" + return + } - # Try to create the internal switch + # Try to create the internal switch + try { Log-Message "Creating internal switch" New-VMSwitch -Name 'VMInternalSwitch' -SwitchType Internal - } else { - throw "Invalid switch type: $SwitchType" + } catch { + throw "Failed to create internal switch with error: $_" } - } catch { - throw "Failed to create external switch with error: $_" + } else { + throw "Invalid switch type: $SwitchType" } + + Log-Message "Successfully created $SwitchType switch with name: $SwitchName" -ForegroundColor Green } function Create-VMStoredCredential { From 86237f29a333e7adb872e3b1612fffe2bbbcebc8 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 10:15:46 -0800 Subject: [PATCH 80/91] WIP --- 1es/Setup_orig.ps1 | 2 +- 1es/prepare_vm_helpers.psm1 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/1es/Setup_orig.ps1 b/1es/Setup_orig.ps1 index 3d54330690..b256d7a48d 100644 --- a/1es/Setup_orig.ps1 +++ b/1es/Setup_orig.ps1 @@ -87,7 +87,7 @@ for ($i = 0; $i -lt $vhds.Count; $i++) { -VmName $vmName ` -VmUsername $VmUsername ` -VmPassword $VmPassword ` - -CpuCount $CpuCount + -VMCpuCount $VMCpuCount Log-Message "VM $vmName created successfully" } catch { diff --git a/1es/prepare_vm_helpers.psm1 b/1es/prepare_vm_helpers.psm1 index 47fee26719..3bbf64d565 100644 --- a/1es/prepare_vm_helpers.psm1 +++ b/1es/prepare_vm_helpers.psm1 @@ -212,7 +212,7 @@ function Configure-VM { [Parameter(Mandatory=$True)][string]$VmName, [Parameter(Mandatory=$True)][string]$VmUsername, [Parameter(Mandatory=$True)][string]$VmPassword, - [Parameter(Mandatory=$True)][int]$CpuCount, + [Parameter(Mandatory=$True)][int]$VMCpuCount, [Parameter(Mandatory=$False)][string]$VMWorkingDirectory='C:\ebpf_cicd', [Parameter(Mandatory=$False)][string]$VMSetupScript='.\configure_vm.ps1' ) @@ -221,8 +221,8 @@ function Configure-VM { Log-Message "Configuring VM: $VmName" # Post VM creation configuration steps. - Log-Message "Setting VM processor count to $CpuCount" - Set-VMProcessor -VMName $VmName -Count $CpuCount + Log-Message "Setting VM processor count to $VMCpuCount" + Set-VMProcessor -VMName $VmName -Count $VMCpuCount Log-Message "Enabling Guest Service Interface" Enable-VMIntegrationService -VMName $VMName -Name 'Guest Service Interface' From 7143241740971e502ede4ca52ef9544ab3e90c03 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 13:21:50 -0800 Subject: [PATCH 81/91] WIP --- .github/workflows/reusable-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index b1259278f7..2133224b5b 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -296,7 +296,7 @@ jobs: ${{env.TEST_COMMAND}} -LogFileName ${{ runner.name }}.log -SelfHostedRunnerName ${{ runner.name }} - name: Run test without Code Coverage - if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') && (inputs.fault_injection != true) + if: (inputs.code_coverage == false) && (steps.skip_check.outputs.should_skip != 'true') && !contains(inputs.environment, 'self-hosted') && (inputs.fault_injection != true) id: run_test_without_code_coverage working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} shell: cmd @@ -306,7 +306,7 @@ jobs: - name: Run post test command # Run the post test command even if the workflow has failed. - if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && contains(inputs.environment, 'self-hosted') + if: (success() || failure()) && (steps.skip_check.outputs.should_skip != 'true') && !contains(inputs.environment, 'self-hosted') id: run_post_test_command working-directory: ./${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}} run: | From e3c4d808c4e053423c5fd2753e3ad7705dd7d0a0 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 14:21:27 -0800 Subject: [PATCH 82/91] WIP --- .github/workflows/cicd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e0124388e5..677bb4f6af 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -226,7 +226,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride="ebpf-cicd-image-server-2022""]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -264,7 +264,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=TestDoesnotExist"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -284,7 +284,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: regression_driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride='ebpf-cicd-image-server-2022'"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage From d891edee3c6983e8b0efd820ecc0d801363cfe78 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 14:28:27 -0800 Subject: [PATCH 83/91] WIP --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 677bb4f6af..ac16845bf4 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -284,7 +284,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: regression_driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride='ebpf-cicd-image-server-2022'"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=\"ebpf-cicd-image-server-2022\""]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage From 1ffaec3820d120c5e98d3101ccab98b5cb81cd32 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 15:44:47 -0800 Subject: [PATCH 84/91] WIP --- .github/workflows/cicd.yml | 6 +++--- scripts/run_driver_tests.psm1 | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index ac16845bf4..e0124388e5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -226,7 +226,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride="ebpf-cicd-image-server-2022""]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -264,7 +264,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=TestDoesnotExist"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -284,7 +284,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: regression_driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=\"ebpf-cicd-image-server-2022\""]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 5665315ed7..aafab1a601 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -492,6 +492,14 @@ function Invoke-CICDStressTests } else { $TestArguments = "-tt=8 -td=5 -erd=1000 -er=1" } + + # TODO - remove debugging output + Write-Log "Items from .\" + Get-ChildItem '.\' + Write-Lost "Itesm from $WorkingDirectory" + Get-ChildItem $WorkingDirectory + Write-Log "Starting $TestCommand with arguments: $TestArguments" + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand From e9ed4c170325aafa23c954c807c8b2f3934e9a61 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Tue, 17 Dec 2024 16:46:40 -0800 Subject: [PATCH 85/91] WIP --- .github/workflows/cicd.yml | 4 ++-- scripts/run_driver_tests.psm1 | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e0124388e5..e92355996a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -226,7 +226,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=server2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -264,7 +264,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=server2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index aafab1a601..8a91105678 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -189,6 +189,10 @@ function Process-TestCompletion } else { # Ensure the process has completely exited. Wait-Process -InputObject $TestProcess + $currExitCode = $TestProcess.ExitCode + $temp = $TestProcess | Out-String + Write-Log "Maige - test output: $temp" + Write-Log "MAIGE - $TestCommand exited with code $currExitCode" # Read and display the output (if any) from the temporary output file. $TempOutputFile = "$env:TEMP\app_output.log" # Log for standard output @@ -485,7 +489,7 @@ function Invoke-CICDStressTests $LASTEXITCODE = 0 - $TestCommand = "ebpf_stress_tests_km" + $TestCommand = "ebpf_stress_tests_km.exe" $TestArguments = " " if ($RestartExtension -eq $false) { $TestArguments = "-tt=8 -td=5" @@ -496,11 +500,19 @@ function Invoke-CICDStressTests # TODO - remove debugging output Write-Log "Items from .\" Get-ChildItem '.\' - Write-Lost "Itesm from $WorkingDirectory" + Write-Log "Items from $WorkingDirectory" Get-ChildItem $WorkingDirectory Write-Log "Starting $TestCommand with arguments: $TestArguments" + # Valid that the test command exists. + if (-not (Test-Path $TestCommand)) { + ThrowWithErrorMessage -ErrorMessage "*** ERROR *** $TestCommand not found under $WorkingDirectory." + } + $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + if ($TestProcess -eq $null) { + ThrowWithErrorMessage -ErrorMessage "*** ERROR *** Failed to start $TestCommand." + } Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand From 4910da3f25c342be8073da3fc13f8b990f97d8d2 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 18 Dec 2024 09:41:34 -0800 Subject: [PATCH 86/91] WIP --- scripts/run_driver_tests.psm1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 8a91105678..98f1f3cc18 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -157,6 +157,11 @@ function Process-TestCompletion [Parameter(Mandatory = $false)] [int] $TestHangTimeout = (10*60), # 10 minutes default timeout. [Parameter(Mandatory = $false)] [bool] $NeedKernelDump = $true) + if ($TestProcess -eq $null) { + Write-Log "Process-TestCompletion: Failed to start $TestCommand" + throw "Failed to start $TestCommand" + } + # Use Wait-Process for the process to terminate or timeout. # See https://stackoverflow.com/a/23797762 Wait-Process -InputObject $TestProcess -Timeout $TestHangTimeout -ErrorAction SilentlyContinue @@ -206,6 +211,8 @@ function Process-TestCompletion } $TestExitCode = $TestProcess.ExitCode + Write-Log "Maige - Test exit code: $TestExitCode" + # if ($TestExitCode -ne $null -and $TestExitCode -ne 0) { if ($TestExitCode -ne 0) { $TempErrorFile = "$env:TEMP\app_error.log" # Log for standard error if ((Test-Path $TempErrorFile) -and (Get-Item $TempErrorFile).Length -gt 0) { @@ -373,6 +380,10 @@ function Invoke-XDPTest $TestCommand = ".\xdp_tests.exe" $TestArguments = "$XDPTestName --remote-ip $RemoteIPV4Address" $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + if ($TestProcess -eq $null) { + Write-Log "Failed to start $TestCommand with arguments $TestArguments" + throw "Failed to start $TestCommand with arguments $TestArguments" + } Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand Write-Log "Executing $XDPTestName with remote address: $RemoteIPV6Address" @@ -380,6 +391,10 @@ function Invoke-XDPTest $TestCommand = ".\xdp_tests.exe" $TestArguments = "$XDPTestName --remote-ip $RemoteIPV6Address" $TestProcess = Start-Process -FilePath $TestCommand -ArgumentList $TestArguments -PassThru -NoNewWindow + if ($TestProcess -eq $null) { + Write-Log "Failed to start $TestCommand with arguments $TestArguments" + throw "Failed to start $TestCommand with arguments $TestArguments" + } Process-TestCompletion -TestProcess $TestProcess -TestCommand $TestCommand Write-Log "$XDPTestName Test Passed" -ForegroundColor Green From 5483105ee7e9963b722795ecded2651296575cce Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 18 Dec 2024 13:07:11 -0800 Subject: [PATCH 87/91] WIP --- scripts/run_driver_tests.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 98f1f3cc18..26e9a81d8b 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -212,8 +212,8 @@ function Process-TestCompletion $TestExitCode = $TestProcess.ExitCode Write-Log "Maige - Test exit code: $TestExitCode" - # if ($TestExitCode -ne $null -and $TestExitCode -ne 0) { - if ($TestExitCode -ne 0) { + if ($TestExitCode -ne $null -and $TestExitCode -ne 0) { + # if ($TestExitCode -ne 0) { $TempErrorFile = "$env:TEMP\app_error.log" # Log for standard error if ((Test-Path $TempErrorFile) -and (Get-Item $TempErrorFile).Length -gt 0) { Write-Log "$TestCommand Error Output:`n" -ForegroundColor Red From 5a1730bc152957f1f321d5ff76c078a53be3d7d6 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 18 Dec 2024 14:31:44 -0800 Subject: [PATCH 88/91] WIP --- .github/workflows/cicd.yml | 4 ++-- scripts/run_driver_tests.psm1 | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e92355996a..e0124388e5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -226,7 +226,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_ws2022 build_artifact: Build-x64 - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=server2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage @@ -264,7 +264,7 @@ jobs: post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true name: driver_native_only_ws2022 build_artifact: Build-x64-native-only - environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=server2022"]' + environment: '["self-hosted", "1ES.Pool=ebpf-cicd-runner-pool-server-2019", "1ES.ImageOverride=ebpf-cicd-image-server-2022"]' # driver test copies dumps to testlog folder. gather_dumps: false # driver tests manually gather code coverage diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 26e9a81d8b..38a8f60641 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -162,6 +162,8 @@ function Process-TestCompletion throw "Failed to start $TestCommand" } + Write-Log "Process-TestCompletion invoked for $TestProcess and $TestCommand" + # Use Wait-Process for the process to terminate or timeout. # See https://stackoverflow.com/a/23797762 Wait-Process -InputObject $TestProcess -Timeout $TestHangTimeout -ErrorAction SilentlyContinue @@ -192,6 +194,7 @@ function Process-TestCompletion Write-Log "Throwing TestHungException for $TestCommand" -ForegroundColor Red throw [System.TimeoutException]::new("Test $TestCommand execution hang timeout ($TestHangTimeout seconds) expired.") } else { + Write-Log "Process-TestCompletion: command should have completed" # Ensure the process has completely exited. Wait-Process -InputObject $TestProcess $currExitCode = $TestProcess.ExitCode From 9aa514281df0cda30be00f0c21448a69a14e63db Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Wed, 18 Dec 2024 16:21:38 -0800 Subject: [PATCH 89/91] WIP --- scripts/run_driver_tests.psm1 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 38a8f60641..ab691bbb35 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -195,12 +195,21 @@ function Process-TestCompletion throw [System.TimeoutException]::new("Test $TestCommand execution hang timeout ($TestHangTimeout seconds) expired.") } else { Write-Log "Process-TestCompletion: command should have completed" - # Ensure the process has completely exited. - Wait-Process -InputObject $TestProcess - $currExitCode = $TestProcess.ExitCode - $temp = $TestProcess | Out-String - Write-Log "Maige - test output: $temp" - Write-Log "MAIGE - $TestCommand exited with code $currExitCode" + try { + $currExitCode = $TestProcess.ExitCode + $temp = $TestProcess | Out-String + Write-Log "Maige - test output: $temp" + Write-Log "MAIGE - $TestCommand exited with code $currExitCode" + } catch { + Write-Log "maige - failed" + } + + # # Ensure the process has completely exited. + # Wait-Process -InputObject $TestProcess + # $currExitCode = $TestProcess.ExitCode + # $temp = $TestProcess | Out-String + # Write-Log "Maige - test output: $temp" + # Write-Log "MAIGE - $TestCommand exited with code $currExitCode" # Read and display the output (if any) from the temporary output file. $TempOutputFile = "$env:TEMP\app_output.log" # Log for standard output From ac1416b487eaa12ebc205a5f27afb42d1f6d357f Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 20 Dec 2024 12:22:09 -0500 Subject: [PATCH 90/91] WIP --- scripts/run_driver_tests.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index ab691bbb35..e070ef71f5 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -162,7 +162,7 @@ function Process-TestCompletion throw "Failed to start $TestCommand" } - Write-Log "Process-TestCompletion invoked for $TestProcess and $TestCommand" + Write-Log "Process-TestCompletion (maige) invoked for $TestProcess and $TestCommand" # Use Wait-Process for the process to terminate or timeout. # See https://stackoverflow.com/a/23797762 From 400c1dd9649de06a87cbb144166b6d0335a53d80 Mon Sep 17 00:00:00 2001 From: "Matt Ige (from Dev Box)" <maige@microsoft.com> Date: Fri, 20 Dec 2024 15:26:31 -0500 Subject: [PATCH 91/91] WIP --- scripts/run_driver_tests.psm1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index e070ef71f5..f11538cab1 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -157,12 +157,13 @@ function Process-TestCompletion [Parameter(Mandatory = $false)] [int] $TestHangTimeout = (10*60), # 10 minutes default timeout. [Parameter(Mandatory = $false)] [bool] $NeedKernelDump = $true) + Write-Log "(maige) Process-TestCompletion (maige)" + Write-Log "Process-TestCompletion (maige) invoked for $TestCommand" if ($TestProcess -eq $null) { Write-Log "Process-TestCompletion: Failed to start $TestCommand" throw "Failed to start $TestCommand" } - Write-Log "Process-TestCompletion (maige) invoked for $TestProcess and $TestCommand" # Use Wait-Process for the process to terminate or timeout. # See https://stackoverflow.com/a/23797762 @@ -413,7 +414,7 @@ function Invoke-XDPTest Write-Log "`n`n" } catch { $ErrorMessage = $_.Exception.Message - ThrowWithErrorMessage -ErrorMessage "XDP test Failed with $ErrorMessage" + ThrowWithErrorMessage -ErrorMessage "(maige) XDP test Failed with $ErrorMessage" } Pop-Location