This is an automated email from the ASF dual-hosted git repository.
NSAmelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new 39a6b355 IGNITE-29247 Fix failing test suites (#367)
39a6b355 is described below
commit 39a6b3552bd7d7b68e789581e08500a7819ebd27
Author: Nikita Amelchev <[email protected]>
AuthorDate: Tue Nov 3 20:31:46 2026 +0300
IGNITE-29247 Fix failing test suites (#367)
---
.../examples/src/test/resources/ignite-config.xml | 38 ++++++++++++++++++++
.../test/scala/ignite/DslPutAsyncThinPool.scala | 2 +-
.../src/test/scala/ignite/DslPutGetThinTx.scala | 2 +-
.../test/scala/ignite/LambdaPutBinarySelect.scala | 5 +--
.../testsuites/IgniteExamplesMLTestSuite.java | 17 ++++++---
modules/ml-ext/ml/extdata/p2p/pom.xml | 13 +++++++
.../ignite/ml/composition/bagging/BaggingTest.java | 40 ++++++++--------------
.../ml/selection/cv/CrossValidationTest.java | 14 ++++----
modules/spark-ext/examples/pom.xml | 12 -------
modules/spark-ext/pom.xml | 1 -
.../cache/IgniteCacheTopologyValidatorTest.java | 4 +++
11 files changed, 93 insertions(+), 55 deletions(-)
diff --git a/modules/gatling-ext/examples/src/test/resources/ignite-config.xml
b/modules/gatling-ext/examples/src/test/resources/ignite-config.xml
new file mode 100644
index 00000000..0169bc02
--- /dev/null
+++ b/modules/gatling-ext/examples/src/test/resources/ignite-config.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
diff --git
a/modules/gatling-ext/examples/src/test/scala/ignite/DslPutAsyncThinPool.scala
b/modules/gatling-ext/examples/src/test/scala/ignite/DslPutAsyncThinPool.scala
index 8e6bd0e8..012d1e96 100644
---
a/modules/gatling-ext/examples/src/test/scala/ignite/DslPutAsyncThinPool.scala
+++
b/modules/gatling-ext/examples/src/test/scala/ignite/DslPutAsyncThinPool.scala
@@ -44,7 +44,7 @@ class DslPutAsyncThinPool extends Simulation {
// It is started at the same JVM the simulation would run just for
simplicity.
// In the real world testing conditions server ignite cluster nodes
forming the cluster
// under test would be started in some other way, outside the simulation
class.
- private val server: Ignite = Ignition.start()
+ private val server: Ignite = Ignition.start("ignite-config.xml")
// Ensure Gatling engine creates enough threads.
System.setProperty("io.netty.eventLoopThreads", "16")
diff --git
a/modules/gatling-ext/examples/src/test/scala/ignite/DslPutGetThinTx.scala
b/modules/gatling-ext/examples/src/test/scala/ignite/DslPutGetThinTx.scala
index fb07f394..78c3069c 100644
--- a/modules/gatling-ext/examples/src/test/scala/ignite/DslPutGetThinTx.scala
+++ b/modules/gatling-ext/examples/src/test/scala/ignite/DslPutGetThinTx.scala
@@ -44,7 +44,7 @@ class DslPutGetThinTx extends Simulation {
// It is started at the same JVM the simulation would run just for
simplicity.
// In the real world testing conditions server ignite cluster nodes
forming the cluster
// under test would be started in some other way, outside the simulation
class.
- private val server: Ignite = Ignition.start()
+ private val server: Ignite = Ignition.start("ignite-config.xml")
/**
* Feeder generating random test data for keys and values.
diff --git
a/modules/gatling-ext/examples/src/test/scala/ignite/LambdaPutBinarySelect.scala
b/modules/gatling-ext/examples/src/test/scala/ignite/LambdaPutBinarySelect.scala
index d486baec..ab5c13fb 100644
---
a/modules/gatling-ext/examples/src/test/scala/ignite/LambdaPutBinarySelect.scala
+++
b/modules/gatling-ext/examples/src/test/scala/ignite/LambdaPutBinarySelect.scala
@@ -45,10 +45,11 @@ class LambdaPutBinarySelect extends Simulation {
// It is started at the same JVM the simulation would run just for
simplicity.
// In the real world testing conditions server ignite cluster nodes
forming the cluster
// under test would be started in some other way, outside the simulation
class.
- private val server: Ignite = Ignition.start()
+ private val server: Ignite = Ignition.start("ignite-config.xml")
// Start ignite client node to be used to generate the load.
- private val client = Ignition.start(new
IgniteConfiguration().setIgniteInstanceName("client").setClientMode(true))
+ private val client =
Ignition.start(Ignition.loadSpringBean[IgniteConfiguration]("ignite-config.xml",
"ignite.cfg")
+ .setIgniteInstanceName("client").setClientMode(true))
// Create test table before the simulation start.
client.asInstanceOf[IgniteEx].context().query().querySqlFields(new
SqlFieldsQuery(
diff --git
a/modules/ml-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
b/modules/ml-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
index a32903e1..9f714080 100644
---
a/modules/ml-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
+++
b/modules/ml-ext/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java
@@ -56,6 +56,9 @@ public class IgniteExamplesMLTestSuite {
/** Test class name pattern. */
private static final String clsNamePtrn = ".*Example$";
+ /** Test classes. Created once since JUnit Platform may instantiate the
suite runner more than once. */
+ private static Class<?>[] testClasses;
+
/** */
@BeforeClass
public static void init() {
@@ -70,11 +73,15 @@ public class IgniteExamplesMLTestSuite {
* @throws IOException, ClassNotFoundException If failed.
*/
public static Class<?>[] suite() throws IOException,
ClassNotFoundException {
- return getClasses(basePkgForTests)
- .stream()
- .map(IgniteExamplesMLTestSuite::makeTestClass)
- .collect(Collectors.toList())
- .toArray(new Class[] {null});
+ if (testClasses == null) {
+ testClasses = getClasses(basePkgForTests)
+ .stream()
+ .map(IgniteExamplesMLTestSuite::makeTestClass)
+ .collect(Collectors.toList())
+ .toArray(new Class[] {null});
+ }
+
+ return testClasses;
}
/**
diff --git a/modules/ml-ext/ml/extdata/p2p/pom.xml
b/modules/ml-ext/ml/extdata/p2p/pom.xml
index 5a56a3c0..dab0f5f7 100644
--- a/modules/ml-ext/ml/extdata/p2p/pom.xml
+++ b/modules/ml-ext/ml/extdata/p2p/pom.xml
@@ -49,4 +49,17 @@
<version>${project.parent.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- The module contains only classes for peer class
loading tests. -->
+ <failIfNoTests>false</failIfNoTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git
a/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/composition/bagging/BaggingTest.java
b/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/composition/bagging/BaggingTest.java
index d31b8e4d..b20bc107 100644
---
a/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/composition/bagging/BaggingTest.java
+++
b/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/composition/bagging/BaggingTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.ml.composition.bagging;
-import java.util.HashMap;
import java.util.Map;
import org.apache.ignite.ml.IgniteModel;
import org.apache.ignite.ml.TestUtils;
@@ -49,23 +48,6 @@ import org.junit.Test;
* Tests for bagging algorithm.
*/
public class BaggingTest extends TrainerTest {
- /**
- * Dependency of weights of first model in ensemble after training in
- * {@link BaggingTest#testNaiveBaggingLogRegression()}. This dependency is
tested to ensure that it is
- * fully determined by provided seeds.
- */
- private static Map<Integer, Vector> firstMdlWeights;
-
- static {
- firstMdlWeights = new HashMap<>();
-
- firstMdlWeights.put(1, VectorUtils.of(-0.14721735583126058,
4.366377931980097));
- firstMdlWeights.put(2, VectorUtils.of(0.37824664453495443,
2.9422474282114495));
- firstMdlWeights.put(3, VectorUtils.of(-1.584467989609169,
2.8467326345685824));
- firstMdlWeights.put(4, VectorUtils.of(-2.543461229777167,
0.1317660102621108));
- firstMdlWeights.put(13, VectorUtils.of(-1.6329364937353634,
0.39278455436019116));
- }
-
/**
* Test that count of entries in context is equal to initial dataset size
* subsampleRatio.
*/
@@ -107,20 +89,26 @@ public class BaggingTest extends TrainerTest {
new OnMajorityPredictionsAggregator())
.withEnvironmentBuilder(TestUtils.testEnvBuilder());
- BaggedModel mdl = baggedTrainer.fit(
- cacheMock,
- parts,
- new
DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST)
- );
+ Vectorizer<Integer, double[], Integer, Double> vectorizer =
+ new
DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST);
- Vector weights =
((LogisticRegressionModel)((AdaptableDatasetModel)((ModelsParallelComposition)((AdaptableDatasetModel)mdl
-
.model()).innerModel()).submodels().get(0)).innerModel()).weights();
+ BaggedModel mdl = baggedTrainer.fit(cacheMock, parts, vectorizer);
- TestUtils.assertEquals(firstMdlWeights.get(parts), weights, 0.0);
+ // Training is fully determined by the provided seeds.
+ TestUtils.assertEquals(firstMdlWeights(baggedTrainer.fit(cacheMock,
parts, vectorizer)), firstMdlWeights(mdl), 0.0);
TestUtils.assertEquals(0, mdl.predict(VectorUtils.of(100, 10)),
PRECISION);
TestUtils.assertEquals(1, mdl.predict(VectorUtils.of(10, 100)),
PRECISION);
}
+ /**
+ * @param mdl Bagged model.
+ * @return Weights of the first model in the ensemble.
+ */
+ private static Vector firstMdlWeights(BaggedModel mdl) {
+ return
((LogisticRegressionModel)((AdaptableDatasetModel)((ModelsParallelComposition)((AdaptableDatasetModel)mdl
+
.model()).innerModel()).submodels().get(0)).innerModel()).weights();
+ }
+
/**
* Method used to test counts of data passed in context and in data
builders.
*
diff --git
a/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/selection/cv/CrossValidationTest.java
b/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/selection/cv/CrossValidationTest.java
index f6e1f633..1f78ec5d 100644
---
a/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/selection/cv/CrossValidationTest.java
+++
b/modules/ml-ext/ml/src/test/java/org/apache/ignite/ml/selection/cv/CrossValidationTest.java
@@ -141,9 +141,9 @@ public class CrossValidationTest {
double[] scores = scoreCalculator.scoreByFolds();
assertEquals(0.8389830508474576, scores[0], 1e-6);
- assertEquals(0.9402985074626866, scores[1], 1e-6);
- assertEquals(0.8809523809523809, scores[2], 1e-6);
- assertEquals(0.9921259842519685, scores[3], 1e-6);
+ assertEquals(0.8432835820895522, scores[1], 1e-6);
+ assertEquals(0.7777777777777778, scores[2], 1e-6);
+ assertEquals(0.7480314960629921, scores[3], 1e-6);
}
/**
@@ -188,10 +188,10 @@ public class CrossValidationTest {
assertArrayEquals(
crossValidationRes.getBestScore(),
- new double[]{0.9745762711864406, 1.0, 0.8968253968253969,
0.8661417322834646},
+ new double[]{0.9661016949152542, 0.9925373134328358,
0.9920634920634921, 0.7480314960629921},
1e-6
);
- assertEquals(0.9343858500738256, crossValidationRes.getBestAvgScore(),
1e-6);
+ assertEquals(0.9246834991186436, crossValidationRes.getBestAvgScore(),
1e-6);
assertEquals(80, crossValidationRes.getScoringBoard().size(), 80);
}
@@ -241,7 +241,7 @@ public class CrossValidationTest {
CrossValidationResult crossValidationRes =
scoreCalculator.tuneHyperParameters();
- assertEquals(0.9343858500738256, crossValidationRes.getBestAvgScore(),
1e-6);
+ assertEquals(0.8600770179467511, crossValidationRes.getBestAvgScore(),
1e-6);
assertEquals(10, crossValidationRes.getScoringBoard().size());
}
@@ -295,7 +295,7 @@ public class CrossValidationTest {
CrossValidationResult crossValidationRes =
scoreCalculator.tuneHyperParameters();
- assertEquals(0.9343858500738256, crossValidationRes.getBestAvgScore(),
1e-6);
+ assertEquals(0.8600770179467511, crossValidationRes.getBestAvgScore(),
1e-6);
assertEquals(10, crossValidationRes.getScoringBoard().size());
}
diff --git a/modules/spark-ext/examples/pom.xml
b/modules/spark-ext/examples/pom.xml
index df5bd3eb..1fd61379 100644
--- a/modules/spark-ext/examples/pom.xml
+++ b/modules/spark-ext/examples/pom.xml
@@ -98,18 +98,6 @@
<version>${spark.jackson.version}</version>
</dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>${spark.jackson.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>${spark.jackson.annotations.version}</version>
- </dependency>
-
<!-- Test dependencies -->
<dependency>
diff --git a/modules/spark-ext/pom.xml b/modules/spark-ext/pom.xml
index 891d8cfe..caad0e95 100644
--- a/modules/spark-ext/pom.xml
+++ b/modules/spark-ext/pom.xml
@@ -38,7 +38,6 @@
<scala.test.version>3.2.20</scala.test.version>
<spark.version>3.5.8</spark.version>
<spark.jackson.version>2.21.1</spark.jackson.version>
-
<spark.jackson.annotations.version>2.21</spark.jackson.annotations.version>
</properties>
<modules>
diff --git
a/modules/topology-validator-ext/src/test/java/org/apache/ignite/plugin/cache/IgniteCacheTopologyValidatorTest.java
b/modules/topology-validator-ext/src/test/java/org/apache/ignite/plugin/cache/IgniteCacheTopologyValidatorTest.java
index 9cd53c5f..c8e15f44 100644
---
a/modules/topology-validator-ext/src/test/java/org/apache/ignite/plugin/cache/IgniteCacheTopologyValidatorTest.java
+++
b/modules/topology-validator-ext/src/test/java/org/apache/ignite/plugin/cache/IgniteCacheTopologyValidatorTest.java
@@ -332,6 +332,8 @@ public class IgniteCacheTopologyValidatorTest extends
IgniteCacheTopologySplitAb
checkPutGet(G.allGrids(), false);
+ assertTrue(waitForCondition(() -> ACTIVE_READ_ONLY ==
grid(1).cluster().state(), getTestTimeout()));
+
grid(1).cluster().state(ACTIVE);
checkPutGet(0, false);
@@ -345,6 +347,8 @@ public class IgniteCacheTopologyValidatorTest extends
IgniteCacheTopologySplitAb
checkPutGet(Collections.singleton(grid(3)), false);
+ assertTrue(waitForCondition(() -> ACTIVE_READ_ONLY ==
grid(3).cluster().state(), getTestTimeout()));
+
grid(3).cluster().state(ACTIVE);
checkPutGet(Collections.singleton(grid(3)), true);