You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2024/11/15 12:01:19 UTC

(uima-uimaj) branch release/3.5.x updated: No issue: Add logging to test

This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch release/3.5.x
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git


The following commit(s) were added to refs/heads/release/3.5.x by this push:
     new 4b12d84ec No issue: Add logging to test
4b12d84ec is described below

commit 4b12d84ec5f41a4af63a6f359038ec005ae6436a
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Fri Nov 15 13:01:14 2024 +0100

    No issue: Add logging to test
---
 .../org/apache/uima/cas/impl/TypeSystemImplTest.java | 20 ++++++++++++++++++++
 uimaj-core/src/test/resources/log4j2-test.xml        |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/TypeSystemImplTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/TypeSystemImplTest.java
index ebb72e14a..a6edee853 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/TypeSystemImplTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/TypeSystemImplTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.uima.cas.impl;
 
+import static java.lang.System.currentTimeMillis;
 import static org.apache.uima.UIMAFramework.getResourceSpecifierFactory;
 import static org.apache.uima.util.CasCreationUtils.createCas;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -25,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.assertj.core.api.Assertions.assertThatNoException;
 import static org.assertj.core.api.InstanceOfAssertFactories.throwable;
 
+import java.lang.invoke.MethodHandles;
 import java.lang.management.ManagementFactory;
 
 import org.apache.uima.cas.CAS;
@@ -36,12 +38,16 @@ import org.apache.uima.resource.impl.ResourceManager_impl;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import x.y.z.Sentence;
 
 class TypeSystemImplTest {
   private TypeSystemDescription tsd;
 
+  static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
   @BeforeEach
   void setup() {
     tsd = getResourceSpecifierFactory().createTypeSystemDescription();
@@ -109,7 +115,16 @@ class TypeSystemImplTest {
     var type = tsd.addType(Sentence._TypeName, "", CAS.TYPE_NAME_ANNOTATION);
     type.addFeature(Sentence._FeatName_sentenceLength, null, CAS.TYPE_NAME_INTEGER);
 
+    LOG.info("Metaspace exhaustion test starting - this may take a while...");
+    var startTime = currentTimeMillis();
+    var target = threshold * 2;
     for (var i = 0; i < threshold * 2; i++) {
+      if ((i + 1) % 250 == 0) {
+        var duration = currentTimeMillis() - startTime;
+        LOG.info("Metaspace exhaustion test - progress: {} / {} -- {}ms per CAS", i + 1, target,
+                duration / i + 1);
+      }
+
       var resMgr = new ResourceManager_impl();
       resMgr.setExtensionClassPath(".", false);
       createCas(tsd, null, null, null, resMgr).getJCas();
@@ -121,5 +136,10 @@ class TypeSystemImplTest {
               .as("High number of new loaded classes during test indicates leak")
               .isLessThan(classesLoadedAtStart + threshold);
     }
+    LOG.info("Classes accumulated during test: {}",
+            classLoadingMXBean.getLoadedClassCount() - classesLoadedAtStart);
+    var duration = currentTimeMillis() - startTime;
+    LOG.info("Metaspace exhaustion test finished in {}ms ({}ms per CAS)", duration,
+            duration / target);
   }
 }
diff --git a/uimaj-core/src/test/resources/log4j2-test.xml b/uimaj-core/src/test/resources/log4j2-test.xml
index 848041694..1cbdb7ce0 100644
--- a/uimaj-core/src/test/resources/log4j2-test.xml
+++ b/uimaj-core/src/test/resources/log4j2-test.xml
@@ -25,6 +25,8 @@
     </Console>
   </Appenders>
   <Loggers>
+    <Logger name="org.apache.uima.cas.impl.TypeSystemImplTest" level="INFO" />
+  
     <Root level="WARN">
       <AppenderRef ref="Console"/>
     </Root>