|
47 | 47 | import org.opensearch.common.settings.Settings; |
48 | 48 | import org.opensearch.common.settings.SettingsException; |
49 | 49 | import org.opensearch.common.unit.TimeValue; |
| 50 | +import org.opensearch.common.util.FeatureFlags; |
50 | 51 | import org.opensearch.common.util.concurrent.ThreadContext; |
51 | 52 | import org.opensearch.common.xcontent.LoggingDeprecationHandler; |
52 | 53 | import org.opensearch.common.xcontent.XContentFactory; |
@@ -797,42 +798,45 @@ public void onFailure(Exception e) { |
797 | 798 | } |
798 | 799 |
|
799 | 800 | public void testPutGlobalV2TemplateWhichProvidesContextWithContextDisabled() throws Exception { |
800 | | - MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService(); |
801 | | - ComposableIndexTemplate globalIndexTemplate = new ComposableIndexTemplate( |
802 | | - List.of("*"), |
803 | | - null, |
804 | | - List.of(), |
805 | | - null, |
806 | | - null, |
807 | | - null, |
808 | | - null, |
809 | | - new Context("any") |
810 | | - ); |
811 | | - InvalidIndexTemplateException ex = expectThrows( |
812 | | - InvalidIndexTemplateException.class, |
813 | | - () -> metadataIndexTemplateService.putIndexTemplateV2( |
814 | | - "testing", |
815 | | - true, |
816 | | - "template-referencing-context-as-ct", |
817 | | - TimeValue.timeValueSeconds(30L), |
818 | | - globalIndexTemplate, |
819 | | - new ActionListener<AcknowledgedResponse>() { |
820 | | - @Override |
821 | | - public void onResponse(AcknowledgedResponse response) { |
822 | | - fail("the listener should not be invoked as validation should fail"); |
823 | | - } |
824 | | - |
825 | | - @Override |
826 | | - public void onFailure(Exception e) { |
827 | | - fail("the listener should not be invoked as validation should fail"); |
| 801 | + // Explicitly disable the FF |
| 802 | + FeatureFlags.TestUtils.with(APPLICATION_BASED_CONFIGURATION_TEMPLATES, false, () -> { |
| 803 | + MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService(); |
| 804 | + ComposableIndexTemplate globalIndexTemplate = new ComposableIndexTemplate( |
| 805 | + List.of("*"), |
| 806 | + null, |
| 807 | + List.of(), |
| 808 | + null, |
| 809 | + null, |
| 810 | + null, |
| 811 | + null, |
| 812 | + new Context("any") |
| 813 | + ); |
| 814 | + InvalidIndexTemplateException ex = expectThrows( |
| 815 | + InvalidIndexTemplateException.class, |
| 816 | + () -> metadataIndexTemplateService.putIndexTemplateV2( |
| 817 | + "testing", |
| 818 | + true, |
| 819 | + "template-referencing-context-as-ct", |
| 820 | + TimeValue.timeValueSeconds(30L), |
| 821 | + globalIndexTemplate, |
| 822 | + new ActionListener<AcknowledgedResponse>() { |
| 823 | + @Override |
| 824 | + public void onResponse(AcknowledgedResponse response) { |
| 825 | + fail("the listener should not be invoked as validation should fail"); |
| 826 | + } |
| 827 | + |
| 828 | + @Override |
| 829 | + public void onFailure(Exception e) { |
| 830 | + fail("the listener should not be invoked as validation should fail"); |
| 831 | + } |
828 | 832 | } |
829 | | - } |
830 | | - ) |
831 | | - ); |
832 | | - assertTrue( |
833 | | - "Invalid exception message." + ex.getMessage(), |
834 | | - ex.getMessage().contains("specifies a context which cannot be used without enabling") |
835 | | - ); |
| 833 | + ) |
| 834 | + ); |
| 835 | + assertTrue( |
| 836 | + "Invalid exception message." + ex.getMessage(), |
| 837 | + ex.getMessage().contains("specifies a context which cannot be used without enabling") |
| 838 | + ); |
| 839 | + }); |
836 | 840 | } |
837 | 841 |
|
838 | 842 | @LockFeatureFlag(APPLICATION_BASED_CONFIGURATION_TEMPLATES) |
|
0 commit comments