You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2021/04/06 10:23:41 UTC
[ignite] branch ignite-ducktape updated: IGNITE-13605 Basic PDS
compatibility test (#8971)
This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch ignite-ducktape
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-ducktape by this push:
new 21c0a5c IGNITE-13605 Basic PDS compatibility test (#8971)
21c0a5c is described below
commit 21c0a5c473781388cb3063211748e295dfcc15f6
Author: Mikhail Filatov <mi...@mfilatov.ru>
AuthorDate: Tue Apr 6 13:23:06 2021 +0300
IGNITE-13605 Basic PDS compatibility test (#8971)
---
.../compatibility/PdsCompatiblityApplication.java | 107 +++++++++++++++++++++
.../ignitetest/tests/compatibility/__init__.py | 18 ++++
.../tests/compatibility/pds_compatibility_test.py | 98 +++++++++++++++++++
3 files changed, 223 insertions(+)
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
new file mode 100644
index 0000000..b2d1116
--- /dev/null
+++ b/modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/compatibility/PdsCompatiblityApplication.java
@@ -0,0 +1,107 @@
+/*
+ * 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<User> 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<Integer, User> 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/tests/ignitetest/tests/compatibility/__init__.py b/modules/ducktests/tests/ignitetest/tests/compatibility/__init__.py
new file mode 100644
index 0000000..96c8d85
--- /dev/null
+++ b/modules/ducktests/tests/ignitetest/tests/compatibility/__init__.py
@@ -0,0 +1,18 @@
+# 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
new file mode 100644
index 0000000..a17ce65
--- /dev/null
+++ b/modules/ducktests/tests/ignitetest/tests/compatibility/pds_compatibility_test.py
@@ -0,0 +1,98 @@
+# 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()