You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/07/04 09:47:27 UTC
[isis] branch master updated: ISIS-2382: adds a test,
that makes this issue reproducible
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 132777e ISIS-2382: adds a test, that makes this issue reproducible
132777e is described below
commit 132777e2dc2a1d6bb5d8ed3f4d87329cf11d22c6
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Jul 4 11:47:09 2020 +0200
ISIS-2382: adds a test, that makes this issue reproducible
---
.../isis/testdomain/domainmodel/MetamodelUtil.java | 51 ++++++++++++++++++++++
...nceTest.java => SpecloaderPerformanceTest.java} | 31 +++++++++++--
2 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/MetamodelUtil.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/MetamodelUtil.java
new file mode 100644
index 0000000..2e0fd09
--- /dev/null
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/MetamodelUtil.java
@@ -0,0 +1,51 @@
+/*
+ * 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.isis.testdomain.domainmodel;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.isis.core.commons.internal.collections._Sets;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+
+import lombok.val;
+
+final class MetamodelUtil {
+
+ static Set<String> featuresSummarized(Collection<ObjectSpecification> allSpecs){
+
+ val features = _Sets.<String>newHashSet();
+
+ allSpecs.stream()
+ .forEach(spec->{
+ spec.streamObjectActions(Contributed.INCLUDED)
+ .forEach(feature->{
+ features.add(feature.getIdentifier().toString());
+ });
+ spec.streamAssociations(Contributed.INCLUDED)
+ .forEach(feature->{
+ features.add(feature.getIdentifier().toString());
+ });
+ });
+
+ return features;
+ }
+
+}
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/UnstableSpecloaderPerformanceTest.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/SpecloaderPerformanceTest.java
similarity index 74%
rename from examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/UnstableSpecloaderPerformanceTest.java
rename to examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/SpecloaderPerformanceTest.java
index 04e95d5..ef843e5 100644
--- a/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/UnstableSpecloaderPerformanceTest.java
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/domainmodel/SpecloaderPerformanceTest.java
@@ -18,6 +18,12 @@
*/
package org.apache.isis.testdomain.domainmodel;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.util.Collections;
+import java.util.Set;
+
import javax.inject.Inject;
import org.junit.jupiter.api.BeforeEach;
@@ -26,9 +32,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
-import static org.junit.jupiter.api.Assertions.fail;
-
+import org.apache.isis.core.commons.internal.base._Lazy;
import org.apache.isis.core.commons.internal.base._Timing;
+import org.apache.isis.core.commons.internal.collections._Sets;
import org.apache.isis.core.commons.internal.reflection._Annotations;
import org.apache.isis.core.config.IsisConfiguration;
import org.apache.isis.core.config.presets.IsisPresets;
@@ -58,19 +64,38 @@ import lombok.extern.log4j.Log4j2;
})
@Incubating("not a real test, just for performance tuning")
@Log4j2
-class UnstableSpecloaderPerformanceTest {
+class SpecloaderPerformanceTest {
@Inject private IsisConfiguration config;
@Inject private SpecificationLoader specificationLoader;
+ private final _Lazy<Set<String>> referenceMetamodelSummary = _Lazy.threadSafe(()->
+ MetamodelUtil.featuresSummarized(specificationLoader.snapshotSpecifications()));
+
@BeforeEach
void setup() {
+ config.getCore().getMetaModel().getIntrospector().setParallelize(false);
+ referenceMetamodelSummary.get(); // memoize
config.getCore().getMetaModel().getIntrospector().setParallelize(true);
}
static long ITERATIONS = 100; /* should typically run in ~10s */
static long EXPECTED_MILLIS_PER_ITERATION = 100;
+ @Test
+ void concurrentSpecloading_shouldYieldSameMetamodelAsSequential() {
+ _Annotations.clearCache();
+ specificationLoader.disposeMetaModel();
+ specificationLoader.createMetaModel();
+ val mmSummary = MetamodelUtil.featuresSummarized(specificationLoader.snapshotSpecifications());
+
+ val missingFeatures = _Sets.minus(referenceMetamodelSummary.get(), mmSummary);
+ if(!missingFeatures.isEmpty()) {
+ System.err.println(String.format("%d missing features", missingFeatures.size()));
+ }
+ assertEquals(Collections.<String>emptySet(), missingFeatures);
+ }
+
@Test @Tag("LongRunning")
void repeatedConcurrentSpecloading_shouldNotDeadlock() {