diff --git a/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/compatibility/PdsCompatiblityApplication.java b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/compatibility/PdsCompatiblityApplication.java deleted file mode 100644 index b2d111653d362..0000000000000 --- a/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/compatibility/PdsCompatiblityApplication.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.ducktest.tests.compatibility; - -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -import com.fasterxml.jackson.databind.JsonNode; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication; - -/** - * Simple application that have 2 options. - * "load" - load some predefined data to cache. - * "check" - check if we have that predifined data in that cache. - */ -public class PdsCompatiblityApplication extends IgniteAwareApplication { - /** Predefined test data. */ - private static List users = Arrays.asList( - new User(0, "John Connor"), - new User(1, "Sarah Connor"), - new User(2, "Kyle Reese")); - - /** {@inheritDoc} */ - @Override protected void run(JsonNode jsonNode) throws IgniteCheckedException { - String operation = jsonNode.get("operation").asText(); - - markInitialized(); - - IgniteCache cache = ignite.getOrCreateCache("users"); - - switch (operation) { - case "load": - for (int i = 0; i < users.size(); i++) - cache.put(i, users.get(i)); - - break; - - case "check": - for (int i = 0; i < users.size(); i++) - assert cache.get(i).equals(users.get(i)); - - break; - - default: - throw new IgniteCheckedException("Unknown operation: " + operation + "."); - } - - markFinished(); - } - - /** - * Data model class, which instances used as cache entry values. - */ - private static class User { - /** */ - private Integer id; - - /** */ - private String fullName; - - /** - * @param id user id. - * @param fullName user full name. - */ - public User(Integer id, String fullName) { - this.id = id; - this.fullName = fullName; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - User person = (User)o; - - return Objects.equals(id, person.id) && - Objects.equals(fullName, person.fullName); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return Objects.hash(id, fullName); - } - } -} diff --git a/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/persistence_upgrade_test/DataLoaderAndCheckerApplication.java b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/persistence_upgrade_test/DataLoaderAndCheckerApplication.java new file mode 100644 index 0000000000000..11d8e707a8228 --- /dev/null +++ b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/persistence_upgrade_test/DataLoaderAndCheckerApplication.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.ducktest.tests.persistence_upgrade_test; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Loads/checks the data. + */ +public class DataLoaderAndCheckerApplication extends IgniteAwareApplication { + /** {@inheritDoc} */ + @Override public void run(JsonNode jNode) throws IgniteInterruptedCheckedException { + boolean check = jNode.get("check").asBoolean(); + + markInitialized(); + waitForActivation(); + + CacheConfiguration cacheCfg = new CacheConfiguration<>("cache"); + + IgniteCache cache = ignite.getOrCreateCache(cacheCfg); + + log.info(check ? "Checking..." : " Preparing..."); + + for (int i = 0; i < 10_000; i++) { + CustomObject obj = new CustomObject(i); + + if (!check) + cache.put(i, obj); + else + assert cache.get(i).equals(obj); + } + + log.info(check ? "Checked." : " Prepared."); + + while (!terminated()) + U.sleep(100); // Keeping node alive. + + markFinished(); + } + + /** + * + */ + private static class CustomObject { + /** String value. */ + private final String sVal; + + /** Integer value. */ + private final Integer iVal; + + /** Boolean value. */ + private final Boolean bVal; + + /** char value. */ + private final char cVal; + + /** Integer array value. */ + private final Integer[] iArVal; + + /** Integer List. */ + private final List iLiVal; + + /** + * @param idx Index. + */ + public CustomObject(int idx) { + sVal = String.valueOf(idx); + iVal = idx; + bVal = idx % 2 == 0; + cVal = sVal.charAt(0); + iArVal = new Integer[] {idx, idx * 2, idx * idx}; + iLiVal = Arrays.asList(iArVal); + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CustomObject obj = (CustomObject)o; + return cVal == obj.cVal + && Objects.equals(sVal, obj.sVal) + && Objects.equals(iVal, obj.iVal) + && Objects.equals(bVal, obj.bVal) + && Arrays.equals(iArVal, obj.iArVal) + && Objects.equals(iLiVal, obj.iLiVal); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int result = Objects.hash(sVal, iVal, bVal, cVal, iLiVal); + result = 31 * result + Arrays.hashCode(iArVal); + return result; + } + } + +} diff --git a/modules/ducktests/tests/ignitetest/tests/compatibility/__init__.py b/modules/ducktests/tests/ignitetest/tests/compatibility/__init__.py deleted file mode 100644 index 96c8d85981794..0000000000000 --- a/modules/ducktests/tests/ignitetest/tests/compatibility/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -This package contains compatibility tests. -""" diff --git a/modules/ducktests/tests/ignitetest/tests/compatibility/pds_compatibility_test.py b/modules/ducktests/tests/ignitetest/tests/compatibility/pds_compatibility_test.py deleted file mode 100644 index a17ce65aed938..0000000000000 --- a/modules/ducktests/tests/ignitetest/tests/compatibility/pds_compatibility_test.py +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -This module contains test that checks that PDS "from_version" compatible with "to_version" -""" -from ducktape.mark import parametrize - -from ignitetest.services.ignite import IgniteService -from ignitetest.services.ignite_app import IgniteApplicationService -from ignitetest.services.utils.control_utility import ControlUtility -from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster -from ignitetest.services.utils.ignite_configuration import IgniteConfiguration, DataStorageConfiguration -from ignitetest.services.utils.ignite_configuration.data_storage import DataRegionConfiguration -from ignitetest.utils import cluster -from ignitetest.utils.ignite_test import IgniteTest -from ignitetest.utils.version import DEV_BRANCH, LATEST, IgniteVersion - - -# pylint: disable=W0223 -# pylint: disable=no-member -class PdsCompatibilityTest(IgniteTest): - """ - A simple test to check PDS compatibility of different Ignite versions. - - Start Ignite cluster version "from_version" with PDS enabled. - Start a client application that puts prepared data. - Stop cluster and client. - Start Ignite cluster version "to_version" without PDS clearing. - Start client that reads data and checks that it can be read and have not changed. - - """ - APP_CLASS = "org.apache.ignite.internal.ducktest.tests.compatibility.PdsCompatiblityApplication" - LOAD_OPERATION = "load" - CHECK_OPERATION = "check" - - @cluster(num_nodes=2) - @parametrize(version_from=str(LATEST), version_to=str(DEV_BRANCH)) - def test_pds_compatibility(self, version_from, version_to): - """ - Saves data using one version of ignite and then load with another. - """ - - server_configuration_from = IgniteConfiguration(version=IgniteVersion(version_from), - data_storage=DataStorageConfiguration( - default=DataRegionConfiguration(persistent=True))) - ignite_from = IgniteService(self.test_context, server_configuration_from, num_nodes=1) - - ignite_from.start() - - ControlUtility(ignite_from).activate() - - loader = IgniteApplicationService( - self.test_context, - config=ignite_from.config._replace(client_mode=True, discovery_spi=from_ignite_cluster(ignite_from)), - java_class_name=self.APP_CLASS, - params={"operation": self.LOAD_OPERATION}) - - app_nodes = loader.nodes.copy() - loader.run() - loader.free() - - ignite_from.stop() - nodes = ignite_from.nodes.copy() - ignite_from.free() - - ignite_to = IgniteService( - self.test_context, - config=server_configuration_from._replace(version=IgniteVersion(version_to)), - num_nodes=1) - - ignite_to.nodes = nodes - - ignite_to.start(clean=False) - - ControlUtility(ignite_to).activate() - - checker = IgniteApplicationService( - self.test_context, - config=ignite_to.config._replace(client_mode=True, discovery_spi=from_ignite_cluster(ignite_to)), - java_class_name=self.APP_CLASS, - params={"operation": self.CHECK_OPERATION}) - - checker.nodes = app_nodes - checker.start(clean=False) - checker.await_stopped() diff --git a/modules/ducktests/tests/ignitetest/tests/persistence_upgrade_test.py b/modules/ducktests/tests/ignitetest/tests/persistence_upgrade_test.py new file mode 100644 index 0000000000000..90921373d93cf --- /dev/null +++ b/modules/ducktests/tests/ignitetest/tests/persistence_upgrade_test.py @@ -0,0 +1,66 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Module contains snapshot test. +""" +from ducktape.mark import parametrize + +from ignitetest.services.ignite_app import IgniteApplicationService +from ignitetest.services.utils.control_utility import ControlUtility +from ignitetest.services.utils.ignite_configuration import IgniteConfiguration, DataStorageConfiguration +from ignitetest.services.utils.ignite_configuration.data_storage import DataRegionConfiguration +from ignitetest.utils import cluster +from ignitetest.utils.ignite_test import IgniteTest +from ignitetest.utils.version import IgniteVersion, LATEST, DEV_BRANCH, OLDEST + + +# pylint: disable=W0223 +class PersistenceUpgradeTest(IgniteTest): + """ + Test checks persistence upgrade. + """ + + @cluster(num_nodes=1) + @parametrize(versions=[str(OLDEST), str(LATEST), str(DEV_BRANCH)]) + def upgrade_test(self, versions): + """ + Basic upgrade test. + """ + versions = sorted(list(map(IgniteVersion, versions))) + + self.logger.info(f"Testing: {versions}") + + service = IgniteApplicationService( + self.test_context, + config=None, # will be defined later. + java_class_name="org.apache.ignite.internal.ducktest.tests.persistence_upgrade_test." + "DataLoaderAndCheckerApplication" + ) + + for version in versions: + service.config = IgniteConfiguration( + data_storage=DataStorageConfiguration(default=DataRegionConfiguration(persistent=True)), + version=version + ) + + service.params = {"check": service.stopped} + + service.start(clean=False) + + control_utility = ControlUtility(service) + control_utility.activate() + + service.stop() diff --git a/modules/ducktests/tests/ignitetest/utils/version.py b/modules/ducktests/tests/ignitetest/utils/version.py index cbb2f4d850738..38dd040edec91 100644 --- a/modules/ducktests/tests/ignitetest/utils/version.py +++ b/modules/ducktests/tests/ignitetest/utils/version.py @@ -98,3 +98,4 @@ def __repr__(self): # if you updated the LATEST version # please check DEV version in 'tests/ignitetest/__init__.py' LATEST = LATEST_2_10 +OLDEST = V_2_7_6