Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user_event test cases #2368

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Component.BuildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
- name: dotnet test ${{ steps.resolve-project.outputs.title }}
if: ${{ inputs.run-tests }}
run: >
${{ inputs.test-require-elevated && matrix.os != 'windows-latest' && 'sudo -E' || '' }}
${{ inputs.test-require-elevated && matrix.os != 'windows-latest' && 'dotnet --info && echo $PATH && sudo echo $PATH && sudo -E echo $PATH && export PATH=/usr/share/dotnet:$PATH && echo $PATH && sudo -E' || '' }}
dotnet test ${{ steps.resolve-project.outputs.project }}
--collect:"Code Coverage"
--results-directory:TestResults
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ jobs:
with:
project-name: Component[OpenTelemetry.Exporter.Geneva]
code-cov-name: Exporter.Geneva
os-list: '[ "ubuntu-24.04" ]' # Note: This may be switched to latest once ubuntu-latest has a kernel version >= 6.8.0-1014-azure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiang17 Just some context for you. From what I could tell, user_events were added to the kernel. But early versions seemed to have an issue where user space couldn't register the tracepoint as was intended. That was later fixed. So you need a kernel with user_events enabled AND the permissions fix for it all to work correctly.

How it should work is the reader process (think agent/collector) needs sudo/admin. But the writer process (app emitting telemetry) shouldn't need anything special.

Copy link
Contributor Author

@xiang17 xiang17 Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context. I simply restored your code back which worked in your PR.

I removed your code because I read it wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, simply adding back didn't work. The failure symptom is that the SDK is missing even though a correct SDK (9.0.101) is installed during setup dotnet step and dotnet restore & build steps were working:

  sudo -E dotnet test ./build/Projects/Component.proj --collect:"Code Coverage" --results-directory:TestResults --framework net9.0 --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" --filter "CategoryName=Geneva:user_events:metrics" -- RunConfiguration.DisableAppDomain=true && sudo chmod a+rw ./TestResults
  shell: /usr/bin/bash -e {0}
  env:
    BUILD_COMPONENT: OpenTelemetry.Exporter.Geneva
    DOTNET_ROOT: /usr/share/dotnet
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'test' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 9.0.100
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

Install the [9.0.100] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.110 [/usr/lib/dotnet/sdk]
Error: Process completed with exit code 145.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I even changed the global.json version to 9.0.101 in case the installed 9.0.101 does not satisfy the global.json's request for 9.0.100, however it still couldn't find the SDK:

  sudo -E dotnet test ./build/Projects/Component.proj --collect:"Code Coverage" --results-directory:TestResults --framework net9.0 --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" --filter "CategoryName=Geneva:user_events:metrics" -- RunConfiguration.DisableAppDomain=true && sudo chmod a+rw ./TestResults
  shell: /usr/bin/bash -e {0}
  env:
    BUILD_COMPONENT: OpenTelemetry.Exporter.Geneva
    DOTNET_ROOT: /usr/share/dotnet
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'test' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 9.0.101
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

8.0.110 [/usr/lib/dotnet/sdk]
Install the [9.0.101] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Error: Process completed with exit code 145.

tfm-list: '[ "net8.0", "net9.0" ]' # Note: Should be able to remove this once the above is using ubuntu-latest
test-case-filter: CategoryName=Geneva:user_events:metrics
test-require-elevated: true
pack: false
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"rollForward": "latestFeature",
"version": "9.0.100"
"version": "9.0.101"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.LinuxTracepoints.Provider;
using OpenTelemetry.Tests;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -49,7 +50,7 @@ public UnixUserEventsDataTransportTests(ITestOutputHelper testOutputHelper)
this.testOutputHelper = testOutputHelper;
}

[Fact(Skip = "This would fail on Ubuntu. Skipping for now.")]
[SkipUnlessPlatformMatchesFact(TestPlatform.Linux, requireElevatedProcess: true)]
public void UserEvents_Enabled_Success_Linux()
{
EnsureUserEventsEnabled();
Expand Down Expand Up @@ -113,7 +114,7 @@ public void UserEvents_Enabled_Success_Linux()
}
}

[Fact(Skip = "This would fail on Ubuntu. Skipping for now.")]
[SkipUnlessPlatformMatchesFact(TestPlatform.Linux, requireElevatedProcess: true)]
public void UserEvents_Disabled_Success_Linux()
{
EnsureUserEventsEnabled();
Expand Down
Loading