-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/#2266_CleanupPackages
- Loading branch information
Showing
27 changed files
with
133 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Diagnostics; | ||
using Elastic.Apm.Api.Constraints; | ||
using Elastic.Apm.Helpers; | ||
|
||
namespace Elastic.Apm.Api; | ||
|
||
internal class ProcessInformation | ||
{ | ||
public int Pid { get; set; } | ||
|
||
[MaxLength] | ||
public string Title { get; set; } | ||
|
||
public static ProcessInformation Create() | ||
{ | ||
var p = Process.GetCurrentProcess(); | ||
return new ProcessInformation { Pid = p.Id, Title = p.ProcessName }; | ||
} | ||
|
||
public override string ToString() => new ToStringBuilder(nameof(Service)) | ||
{ | ||
{ nameof(Pid), Pid }, | ||
{ nameof(Title), Title } | ||
}.ToString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
test/Elastic.Apm.Tests.Utilities/Docker/DockerFactAttribute.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
test/Elastic.Apm.Tests.Utilities/Docker/DockerTheoryAttribute.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
test/Elastic.Apm.Tests.Utilities/XUnit/DockerAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
using System.IO; | ||
using ProcNet; | ||
using Xunit; | ||
|
||
namespace Elastic.Apm.Tests.Utilities.XUnit; | ||
|
||
|
||
/// <inheritdoc cref="DockerTheory"/> | ||
public sealed class DockerFact : FactAttribute | ||
{ | ||
public DockerFact() => Skip = DockerTheory.ShouldSkip(); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Locally we always run TestContainers through docker.</para> | ||
/// <para>On Github Actions windows hosts we use TC cloud to launch linux docker containers</para> | ||
/// <para> | ||
/// When forks run the tests on pull request TestContainers Cloud won't be configured and available. | ||
/// So we opt to skip instead. | ||
/// </para> | ||
/// </summary> | ||
public sealed class DockerTheory : TheoryAttribute | ||
{ | ||
public DockerTheory() => Skip = ShouldSkip(); | ||
|
||
public static string ShouldSkip() | ||
{ | ||
var tcCloudConfigured = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TC_CLOUD_TOKEN")); | ||
if (TestEnvironment.IsGitHubActions | ||
&& TestEnvironment.IsWindows | ||
&& !tcCloudConfigured) | ||
return "Running on Github Action Windows host with no active TC_CLOUD_TOKEN configuration, skipping."; | ||
// if running locally skip the test because it needs docker installed. | ||
else if (!DockerUtils.HasDockerInstalled) | ||
return "This test requires docker to be installed"; | ||
|
||
return null; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Marks a test that has to be running inside of a docker container | ||
/// </summary> | ||
public class RunningInDockerFactAttribute : FactAttribute | ||
{ | ||
public RunningInDockerFactAttribute() | ||
{ | ||
if (!DockerUtils.IsRunningInDocker()) | ||
Skip = "Not running in a docker container"; | ||
} | ||
} | ||
|
||
internal static class DockerUtils | ||
{ | ||
public static bool IsRunningInDocker() => | ||
File.Exists("/proc/1/cgroup") && File.ReadAllText("/proc/1/cgroup").Contains("docker"); | ||
|
||
public static bool HasDockerInstalled { get; } | ||
|
||
static DockerUtils() | ||
{ | ||
try | ||
{ | ||
var result = Proc.Start(new StartArguments("docker", "--version")); | ||
HasDockerInstalled = result.ExitCode == 0; | ||
} | ||
catch (Exception) | ||
{ | ||
HasDockerInstalled = false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.