@@ -590,44 +590,34 @@ private static void clearClusters() throws Exception {
590
590
}
591
591
592
592
private void afterInternal (boolean afterClass ) throws Exception {
593
- boolean success = false ;
593
+ final Scope currentClusterScope = getCurrentClusterScope ();
594
+ if (isInternalCluster ()) {
595
+ internalCluster ().clearDisruptionScheme ();
596
+ }
594
597
try {
595
- final Scope currentClusterScope = getCurrentClusterScope ();
596
- if (isInternalCluster ()) {
597
- internalCluster ().clearDisruptionScheme ();
598
- }
599
- try {
600
- if (cluster () != null ) {
601
- if (currentClusterScope != Scope .TEST ) {
602
- Metadata metadata = client ().admin ().cluster ().prepareState ().execute ().actionGet ().getState ().getMetadata ();
598
+ if (cluster () != null ) {
599
+ if (currentClusterScope != Scope .TEST ) {
600
+ Metadata metadata = client ().admin ().cluster ().prepareState ().execute ().actionGet ().getState ().getMetadata ();
603
601
604
- final Set <String > persistentKeys = new HashSet <>(metadata .persistentSettings ().keySet ());
605
- assertThat ("test leaves persistent cluster metadata behind" , persistentKeys , empty ());
602
+ final Set <String > persistentKeys = new HashSet <>(metadata .persistentSettings ().keySet ());
603
+ assertThat ("test leaves persistent cluster metadata behind" , persistentKeys , empty ());
606
604
607
- final Set <String > transientKeys = new HashSet <>(metadata .transientSettings ().keySet ());
608
- assertThat ("test leaves transient cluster metadata behind" , transientKeys , empty ());
609
- }
610
- ensureClusterSizeConsistency ();
611
- ensureClusterStateConsistency ();
612
- ensureClusterStateCanBeReadByNodeTool ();
613
- beforeIndexDeletion ();
614
- cluster ().wipe (excludeTemplates ()); // wipe after to make sure we fail in the test that didn't ack the delete
615
- if (afterClass || currentClusterScope == Scope .TEST ) {
616
- cluster ().close ();
617
- }
618
- cluster ().assertAfterTest ();
605
+ final Set <String > transientKeys = new HashSet <>(metadata .transientSettings ().keySet ());
606
+ assertThat ("test leaves transient cluster metadata behind" , transientKeys , empty ());
619
607
}
620
- } finally {
621
- if (currentClusterScope == Scope .TEST ) {
622
- clearClusters (); // it is ok to leave persistent / transient cluster state behind if scope is TEST
608
+ ensureClusterSizeConsistency ();
609
+ ensureClusterStateConsistency ();
610
+ ensureClusterStateCanBeReadByNodeTool ();
611
+ beforeIndexDeletion ();
612
+ cluster ().wipe (excludeTemplates ()); // wipe after to make sure we fail in the test that didn't ack the delete
613
+ if (afterClass || currentClusterScope == Scope .TEST ) {
614
+ cluster ().close ();
623
615
}
616
+ cluster ().assertAfterTest ();
624
617
}
625
- success = true ;
626
618
} finally {
627
- if (!success ) {
628
- // if we failed here that means that something broke horribly so we should clear all clusters
629
- // TODO: just let the exception happen, WTF is all this horseshit
630
- // afterTestRule.forceFailure();
619
+ if (currentClusterScope == Scope .TEST ) {
620
+ clearClusters (); // it is ok to leave persistent / transient cluster state behind if scope is TEST
631
621
}
632
622
}
633
623
}
0 commit comments