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

Skip running Elasticsearch docker test when docker not available #1312

Merged
merged 1 commit into from
May 27, 2021
Merged
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: 2 additions & 0 deletions test/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ private void FullFwAssertValid(Api.System system)
system.Should().NotBeNull();

system.DetectedHostName.Should().Be(new SystemInfoHelper(LoggerBase).GetHostName());
#pragma warning disable 618
system.HostName.Should().Be(AgentConfig.HostName ?? system.DetectedHostName);
#pragma warning restore 618
}

private void FullFwAssertValid(ErrorDto error)
Expand Down
3 changes: 2 additions & 1 deletion test/Elastic.Apm.Elasticsearch.Tests/ElasticsearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Elastic.Apm.Api;
using Elastic.Apm.DiagnosticSource;
using Elastic.Apm.Tests.Utilities;
using Elastic.Apm.Tests.Utilities.Docker;
using Elasticsearch.Net;
using Elasticsearch.Net.VirtualizedCluster;
using FluentAssertions;
Expand All @@ -25,7 +26,7 @@ public ElasticsearchTests(ElasticsearchFixture fixture)
_client = new ElasticLowLevelClient(settings);
}

[Fact]
[DockerFact]
public async Task Elasticsearch_Span_Does_Not_Have_Http_Child_Span()
{
var payloadSender = new MockPayloadSender();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using DotNet.Testcontainers.Containers.Modules.Databases;
using Elastic.Apm.Api;
using Elastic.Apm.Tests.Utilities;
using Elastic.Apm.Tests.Utilities.Docker;
using StackExchange.Redis;
using FluentAssertions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@
using ProcNet;
using Xunit;

namespace Elastic.Apm.StackExchange.Redis.Tests
namespace Elastic.Apm.Tests.Utilities.Docker
{
/// <summary>
/// Test method that should be run only if docker exists on the host
/// </summary>
public class DockerFactAttribute : FactAttribute
{
public DockerFactAttribute()
private static readonly string _skip;

static DockerFactAttribute()
{
try
{
var result = Proc.Start(new StartArguments("docker", "--version"));
if (result.ExitCode != 0)
Skip = "docker not installed";
_skip = "docker not installed";
}
catch (Exception)
{
Skip = "could not get version of docker";
_skip = "could not get version of docker";
}
}

public DockerFactAttribute() => Skip = _skip;
}
}