All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensearch.test.ParameterizedDynamicSettingsOpenSearchIntegTestCase Maven / Gradle / Ivy

There is a newer version: 2.18.0
Show newest version
/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * The OpenSearch Contributors require contributions made to
 * this file be licensed under the Apache-2.0 license or a
 * compatible open source license.
 */

package org.opensearch.test;

import org.opensearch.common.settings.Settings;
import org.opensearch.common.settings.SettingsModule;
import org.junit.After;
import org.junit.Before;

/**
 * Base class for running the tests with parameterization using dynamic settings: the cluster will be created once before the test suite and the
 * settings will be applied dynamically, please notice that not all settings could be changed dynamically (consider using {@link ParameterizedStaticSettingsOpenSearchIntegTestCase}
 * instead).
 * 

* Here is the simple illustration on of the execution flow per parameters combination: *

    *
  • suite scope: create cluster -> for each test method { apply settings -> run test method -> unapply settings } -> shutdown cluster
  • *
  • test scope: for each test method { create cluster -> apply settings -> run test method -> unapply settings -> shutdown cluster }
  • *
*/ public abstract class ParameterizedDynamicSettingsOpenSearchIntegTestCase extends ParameterizedOpenSearchIntegTestCase { public ParameterizedDynamicSettingsOpenSearchIntegTestCase(Settings dynamicSettings) { super(dynamicSettings); } @Before public void beforeTests() { SettingsModule settingsModule = new SettingsModule(settings); for (String key : settings.keySet()) { assertTrue( settingsModule.getClusterSettings().isDynamicSetting(key) || settingsModule.getIndexScopedSettings().isDynamicSetting(key) ); } client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settings).get(); } @After public void afterTests() { final Settings.Builder settingsToUnset = Settings.builder(); settings.keySet().forEach(settingsToUnset::putNull); client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settingsToUnset).get(); } @Override boolean hasSameParametersAs(ParameterizedOpenSearchIntegTestCase obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } return true; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy