Skip to content

Integration tests: wait for green at startup #4365

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

Merged
merged 1 commit into from
Feb 5, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Elastic.Managed.Ephemeral.Plugins;
using Elastic.Stack.Artifacts.Products;
using Elastic.Xunit;
using Elasticsearch.Net;
using Nest;
using Tests.Configuration;
using Tests.Core.Client;
Expand All @@ -23,6 +24,15 @@ protected ClientTestClusterBase(ClientTestClusterConfiguration configuration) :
public IElasticClient Client => this.GetOrAddClient(s => ConnectionSettings(s.ApplyDomainSettings()));

protected virtual ConnectionSettings ConnectionSettings(ConnectionSettings s) => s;

protected sealed override void SeedCluster()
{
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
SeedNode();
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
}

protected virtual void SeedNode() { }
}

public class ClientTestClusterConfiguration : XunitClusterConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Tests.Core.ManagedElasticsearch.Clusters
{
public class CrossCluster : ClientTestClusterBase
{
protected override void SeedCluster()
protected override void SeedNode()
{
new DefaultSeeder(Client).SeedNode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class ReadOnlyCluster : ClientTestClusterBase
{
public ReadOnlyCluster() : base(MapperMurmur3) { }

protected override void SeedCluster() => new DefaultSeeder(Client).SeedNode();
protected override void SeedNode() => new DefaultSeeder(Client).SeedNode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ namespace Tests.Core.ManagedElasticsearch.Clusters
{
public class TimeSeriesCluster : XPackCluster
{
protected override void SeedCluster() =>
new TimeSeriesSeeder(Client).SeedNode();
protected override void SeedNode() => new TimeSeriesSeeder(Client).SeedNode();
}

public class TimeSeriesSeeder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Tests.Core.ManagedElasticsearch.Clusters
//TODO does this need a whole separate cluster?
public class UnbalancedCluster : ClientTestClusterBase
{
protected override void SeedCluster() =>
protected override void SeedNode() =>
new DefaultSeeder(Client, new IndexSettings { NumberOfShards = 3, NumberOfReplicas = 2 })
.SeedNode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static ClientTestClusterConfiguration CreateConfiguration()
};
}

protected override void SeedCluster()
protected override void SeedNode()
{
var seeder = new DefaultSeeder(Client);
seeder.SeedNode();
Expand Down
11 changes: 9 additions & 2 deletions tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public XPackClusterConfiguration(ClusterFeatures features) : base(ClusterFeature
TrialMode = XPackTrialMode.Trial;
AdditionalBeforeNodeStartedTasks.Add(new EnsureWatcherActionConfigurationInElasticsearchYaml());
AdditionalBeforeNodeStartedTasks.Add(new EnsureWatcherActionConfigurationSecretsInKeystore());
AdditionalBeforeNodeStartedTasks.Add(new EnsureNativeSecurityRealmEnabledInElasticsearchYaml());
AdditionalBeforeNodeStartedTasks.Add(new EnsureNativeSecurityRealmEnabledInElasticsearchYaml());
ShowElasticsearchOutputAfterStarted = true; //this.TestConfiguration.ShowElasticsearchOutputAfterStarted;
}
}
Expand All @@ -46,6 +46,13 @@ protected virtual ConnectionSettings Authenticate(ConnectionSettings s) => s
protected virtual ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
.ServerCertificateValidationCallback(CertificateValidations.AllowAll);

protected override void SeedCluster() => new DefaultSeeder(Client).SeedNode();
protected sealed override void SeedCluster()
{
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
SeedNode();
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
}

protected virtual void SeedNode() => new DefaultSeeder(Client).SeedNode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public SslAndKpiXPackCluster() : this(new SslAndKpiClusterConfiguration()) { }

public SslAndKpiXPackCluster(SslAndKpiClusterConfiguration configuration) : base(configuration) { }

protected override void SeedCluster() { }
protected override void SeedNode() { }
}
}
4 changes: 2 additions & 2 deletions tests/Tests/Document/Multiple/Reindex/ReindexApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace Tests.Document.Multiple.Reindex
{
public class ReindexCluster : ClientTestClusterBase
{
protected override void SeedCluster() => new DefaultSeeder(Client).SeedNodeNoData();
protected override void SeedNode() => new DefaultSeeder(Client).SeedNodeNoData();
}

public class ManualReindexCluster : ClientTestClusterBase
{
protected override void SeedCluster() => new DefaultSeeder(Client).SeedNodeNoData();
protected override void SeedNode() => new DefaultSeeder(Client).SeedNodeNoData();
}

public class ReindexApiTests : IClusterFixture<ManualReindexCluster>
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/QueryDsl/BoolDsl/BoolApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum E
Option2
}

protected override void SeedCluster()
protected override void SeedNode()
{
var client = Client;
var index = client.Indices.Create(Index<A>(), i => i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MachineLearningCluster() : base(new XPackClusterConfiguration
Timeout = TimeSpan.FromMinutes(10),
}) { }

protected override void SeedCluster() => new MachineLearningSeeder(Client, ClusterConfiguration.FileSystem).SeedNode();
protected override void SeedNode() => new MachineLearningSeeder(Client, ClusterConfiguration.FileSystem).SeedNode();
}

public class DownloadMachineLearningSampleDataDistribution : ClusterComposeTask
Expand Down