sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1651064 - in /sling/trunk/installer/it: pom.xml src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
Date Mon, 12 Jan 2015 11:20:29 GMT
Author: cziegeler
Date: Mon Jan 12 11:20:29 2015
New Revision: 1651064

URL: http://svn.apache.org/r1651064
Log:
SLING-1794 : ConfigInstallTest fails semi-randomly: Configuration is still present

Modified:
    sling/trunk/installer/it/pom.xml
    sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java
    sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java

Modified: sling/trunk/installer/it/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/installer/it/pom.xml?rev=1651064&r1=1651063&r2=1651064&view=diff
==============================================================================
--- sling/trunk/installer/it/pom.xml (original)
+++ sling/trunk/installer/it/pom.xml Mon Jan 12 11:20:29 2015
@@ -483,7 +483,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.framework</artifactId>
-            <version>4.2.1</version>
+            <version>4.4.1</version>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java?rev=1651064&r1=1651063&r2=1651064&view=diff
==============================================================================
--- sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java
(original)
+++ sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/ConfigInstallTest.java
Mon Jan 12 11:20:29 2015
@@ -30,8 +30,8 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.sling.installer.api.InstallableResource;
 import org.apache.sling.installer.api.event.InstallationEvent;
 import org.apache.sling.installer.api.event.InstallationListener;
-import org.apache.sling.installer.api.tasks.InstallTaskFactory;
 import org.apache.sling.installer.api.tasks.ResourceState;
+import org.apache.sling.installer.api.tasks.ResourceTransformer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -95,9 +95,11 @@ public class ConfigInstallTest extends O
     /**
      * @see org.osgi.service.cm.ConfigurationListener#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
      */
-    public void configurationEvent(ConfigurationEvent e) {
-        synchronized ( events ) {
-            events.add(e);
+    public void configurationEvent(final ConfigurationEvent e) {
+        if ( e.getType() == ConfigurationEvent.CM_DELETED || e.getType() == ConfigurationEvent.CM_UPDATED)
{
+            synchronized ( events ) {
+                events.add(e);
+            }
         }
 	}
 
@@ -445,44 +447,50 @@ public class ConfigInstallTest extends O
 
     @Test
     public void testDeferredConfigRemove() throws Exception {
-        final AtomicInteger factoryCount = new AtomicInteger();
+        final AtomicInteger transformerCount = new AtomicInteger();
 
-        final ServiceTracker st = new ServiceTracker(bundleContext, InstallTaskFactory.class.getName(),
new ServiceTrackerCustomizer() {
+        final ServiceTracker st = new ServiceTracker(bundleContext,
+                ResourceTransformer.class.getName(), new ServiceTrackerCustomizer() {
 
             public void removedService(ServiceReference reference, Object service) {
                 bundleContext.ungetService(reference);
-                factoryCount.decrementAndGet();
+                transformerCount.decrementAndGet();
             }
 
             public void modifiedService(ServiceReference reference, Object service) {
             }
 
             public Object addingService(ServiceReference reference) {
-                factoryCount.incrementAndGet();
+                transformerCount.incrementAndGet();
                 return bundleContext.getService(reference);
             }
         });
         st.open();
 
-        // get config admin bundle and wait for service
-        final Bundle configAdmin = this.getConfigAdminBundle();
-        assertNotNull("ConfigAdmin bundle must be found", configAdmin);
-        waitForConfigAdmin(true);
-
-        // when everything is up and running, we have two factories
-        waitForCondition("Task Factories should be 2", new Condition() {
+        final AtomicInteger expectedCount = new AtomicInteger();
+        final Condition cond = new Condition() {
 
             @Override
             boolean isTrue() throws Exception {
-                return factoryCount.get() == 2;
+                return transformerCount.get() == expectedCount.get();
             }
 
             @Override
             String additionalInfo() {
-                return "Task Factories is " + String.valueOf(factoryCount.get());
+                return "Resource transformer count is " + String.valueOf(transformerCount.get())
+
+                       ", should be " + String.valueOf(expectedCount.get());
             }
 
-        });
+        };
+
+        // get config admin bundle and wait for service
+        final Bundle configAdmin = this.getConfigAdminBundle();
+        assertNotNull("ConfigAdmin bundle must be found", configAdmin);
+        waitForConfigAdmin(true);
+
+        // when everything is up and running, we have two factories
+        expectedCount.set(2);
+        waitForCondition(null, cond);
 
         // check that configuration is not available
         final String cfgPid = getClass().getSimpleName() + ".deferred." + uniqueID();
@@ -495,48 +503,28 @@ public class ConfigInstallTest extends O
         installer.updateResources(URL_SCHEME, rsrc, null);
         waitForConfiguration("Config must be installed before stopping ConfigurationAdmin",
                 cfgPid, true);
+        this.waitForResource(URL_SCHEME + ":" + rsrc[0].getId(), ResourceState.INSTALLED);
 
         // Configuration uninstalls must be deferred if ConfigAdmin service is stopped
         configAdmin.stop();
         waitForConfigAdmin(false);
 
-        // only bundle task factory
-        waitForCondition("Task Factories should be 1", new Condition() {
-
-            @Override
-            boolean isTrue() throws Exception {
-                return factoryCount.get() == 1;
-            }
-
-            @Override
-            String additionalInfo() {
-                return "Task Factories is " + String.valueOf(factoryCount.get());
-            }
-
-        });
+        // only bundle transformer
+        expectedCount.set(1);
+        waitForCondition(null, cond);
 
         // remove configuration
         installationEvents = 0;
         installer.updateResources(URL_SCHEME, null, new String[] {rsrc[0].getId()});
         waitForInstallationEvents(2);
+        this.waitForResource(URL_SCHEME + ":" + rsrc[0].getId(), ResourceState.UNINSTALL);
 
         configAdmin.start();
         waitForConfigAdmin(true);
 
-        // when everything is up and running, we have two factories
-        waitForCondition("Task Factories should be 2", new Condition() {
-
-            @Override
-            boolean isTrue() throws Exception {
-                return factoryCount.get() == 2;
-            }
-
-            @Override
-            String additionalInfo() {
-                return "Task Factories is " + String.valueOf(factoryCount.get());
-            }
-
-        });
+        // when everything is up and running, we have two transformers again
+        expectedCount.set(2);
+        waitForCondition(null, cond);
 
         waitForConfiguration("Config must be removed once ConfigurationAdmin restarts",
                 cfgPid, false);

Modified: sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java?rev=1651064&r1=1651063&r2=1651064&view=diff
==============================================================================
--- sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
(original)
+++ sling/trunk/installer/it/src/test/java/org/apache/sling/installer/it/OsgiInstallerTestBase.java
Mon Jan 12 11:20:29 2015
@@ -510,9 +510,9 @@ public class OsgiInstallerTestBase imple
                         mavenBundle("org.slf4j", "jcl-over-slf4j", "1.6.4"),
                         mavenBundle("org.slf4j", "log4j-over-slf4j", "1.6.4"),
 
-        	            mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.8.0"),
-        	            mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.2.8"),
-                        mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.0.2"),
+        	            mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.8.2"),
+        	            mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.0"),
+                        mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.0.10"),
         	        	mavenBundle("org.apache.sling", "org.apache.sling.installer.core", POM_VERSION).startLevel(5),
                         mavenBundle("org.apache.sling", "org.apache.sling.installer.factory.configuration",
CONFIG_VERSION).startLevel(5)
         		)
@@ -599,7 +599,7 @@ public class OsgiInstallerTestBase imple
 
         do {
             final InstallationState is = this.infoProvider.getInstallationState();
-            for(final ResourceGroup rg : is.getInstalledResources()) {
+            for(final ResourceGroup rg : (state == ResourceState.INSTALL || state == ResourceState.UNINSTALL
? is.getActiveResources() : is.getInstalledResources())) {
                 for(final Resource rsrc : rg.getResources()) {
                     if ( url.equals(rsrc.getURL()) ) {
                         if ( rsrc.getState() == state ) {
@@ -610,9 +610,10 @@ public class OsgiInstallerTestBase imple
             }
             sleep(50);
         } while ( System.currentTimeMillis() < end);
-        fail("Resource " + url + " not found with state " + state);
+        fail("Resource " + url + " not found with state " + state + " : " + this.infoProvider.getInstallationState());
         return null;
     }
+
     private final class BundleEventListener implements SynchronousBundleListener {
 
         private final List<BundleEvent> events = new ArrayList<BundleEvent>();



Mime
View raw message