@@ -21,18 +21,18 @@ namespace Tests.Framework.Integration
2121 public class ElasticsearchNode : IDisposable
2222 {
2323 private static readonly object _lock = new object ( ) ;
24- // <installpath> <> <plugin folder prefix>
25- private readonly Dictionary < string , Func < string , string > > SupportedPlugins = new Dictionary < string , Func < string , string > >
26- {
27- { "delete-by-query" , _ => "delete-by-query" } ,
28- { "cloud-azure" , _ => "cloud-azure" } ,
29- { "mapper-attachments" , MapperAttachmentPlugin . GetVersion } ,
30- { "mapper-murmur3" , _ => "mapper-murmur3" } ,
31- { "license" , _ => "license" } ,
32- { "graph" , _ => "graph" } ,
33- { "shield" , _ => "shield" } ,
34- { "watcher" , _ => "watcher" } ,
24+
25+ private readonly ElasticsearchPlugin [ ] SupportedPlugins = {
26+ new ElasticsearchPlugin ( "delete-by-query" ) ,
27+ new ElasticsearchPlugin ( "cloud-azure" ) ,
28+ new ElasticsearchPlugin ( "mapper-attachments" , _ => true , MapperAttachmentPlugin . GetDirectory , MapperAttachmentPlugin . GetVersion ) ,
29+ new ElasticsearchPlugin ( "mapper-murmur3" ) ,
30+ new ElasticsearchPlugin ( "license" ) ,
31+ new ElasticsearchPlugin ( "graph" , v => v >= new ElasticsearchVersionInfo ( "2.3.0" ) ) ,
32+ new ElasticsearchPlugin ( "shield" ) ,
33+ new ElasticsearchPlugin ( "watcher" )
3534 } ;
35+
3636 private string [ ] DefaultNodeSettings { get ; }
3737
3838 private readonly bool _testAgainstAlreadyRunningElasticsearch ;
@@ -50,10 +50,10 @@ public class ElasticsearchNode : IDisposable
5050
5151 public string TypeOfCluster { get ; }
5252 public bool Started { get ; private set ; }
53- public bool RunningIntegrations { get ; private set ; }
53+ public bool RunningIntegrations { get ; }
5454 public string ClusterName { get ; }
5555 public string NodeName { get ; }
56- public string RepositoryPath { get ; private set ; }
56+ public string RepositoryPath { get ; }
5757 public ElasticsearchNodeInfo Info { get ; private set ; }
5858 public int Port { get ; private set ; }
5959
@@ -155,15 +155,14 @@ public ElasticsearchNode(
155155
156156 }
157157
158- private object _lockGetClient = new object { } ;
158+ private readonly object _lockGetClient = new object ( ) ;
159159 private IElasticClient _client ;
160160 public IElasticClient Client
161161 {
162162 get
163163 {
164164 if ( ! this . Started && TestClient . Configuration . RunIntegrationTests )
165165 {
166-
167166 throw new Exception ( "can not request a client from an ElasticsearchNode if that node hasn't started yet" ) ;
168167 }
169168
@@ -174,6 +173,7 @@ public IElasticClient Client
174173 if ( this . _client != null ) return this . _client ;
175174
176175 var port = this . Started ? this . Port : 9200 ;
176+ // ReSharper disable once PossibleMultipleWriteAccessInDoubleCheckLocking
177177 this . _client = TestClient . GetClient ( ComposeSettings , port ) ;
178178 return this . Client ;
179179 }
@@ -247,9 +247,14 @@ private IObservable<ElasticsearchMessage> UseAlreadyRunningInstance(ManualResetE
247247
248248 var checkPlugins = client . CatPlugins ( ) ;
249249
250- var missingPlugins = SupportedPlugins . Keys . Except ( checkPlugins . Records . Select ( r => r . Component ) ) . ToList ( ) ;
250+ var missingPlugins = SupportedPlugins
251+ . Where ( p => p . IsValid ( this . VersionInfo ) )
252+ . Select ( p => p . Name )
253+ . Except ( checkPlugins . Records . Select ( r => r . Component ) )
254+ . ToList ( ) ;
255+
251256 if ( missingPlugins . Any ( ) )
252- throw new Exception ( $ "Already running elasticsearch missed the following plugin(s): { string . Join ( ", " , missingPlugins ) } .") ;
257+ throw new Exception ( $ "Already running elasticsearch missing the following plugin(s): { string . Join ( ", " , missingPlugins ) } .") ;
253258
254259 this . Started = true ;
255260 this . Port = 9200 ;
@@ -397,10 +402,10 @@ private void InstallPlugins()
397402 if ( this . VersionInfo . ParsedVersion . Major >= 5 ) pluginCommand = "elasticsearch-plugin" ;
398403
399404 var pluginBat = Path . Combine ( this . RoamingClusterFolder , "bin" , pluginCommand ) + ".bat" ;
400- foreach ( var plugin in SupportedPlugins )
405+ foreach ( var plugin in SupportedPlugins . Where ( p => p . IsValid ( this . VersionInfo ) ) )
401406 {
402- var installPath = plugin . Key ;
403- var command = plugin . Value ( this . VersionInfo . Version ) ;
407+ var installPath = plugin . PluginDirectory ( this . VersionInfo ) ;
408+ var command = plugin . PluginVersion ( this . VersionInfo ) ;
404409 var pluginFolder = Path . Combine ( this . RoamingClusterFolder , "plugins" , installPath ) ;
405410
406411 if ( ! Directory . Exists ( this . RoamingClusterFolder ) ) continue ;
0 commit comments