Search in sources :

Example 1 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class LauncherLifecycleCommandsDUnitTest method waitForGemFireProcessToStop.

protected Status waitForGemFireProcessToStop(final ServiceState serviceState, final String workingDirectory) {
    if (!Status.STOPPED.equals(serviceState.getStatus())) {
        try {
            final Integer pid = readPid(new File(workingDirectory));
            if (pid != null) {
                WaitCriterion waitCriteria = new WaitCriterion() {

                    private LauncherLifecycleCommands launcherLifecycleCommands = new LauncherLifecycleCommands();

                    @Override
                    public boolean done() {
                        return !ProcessUtils.isProcessAlive(pid);
                    }

                    @Override
                    public String description() {
                        return String.format("Waiting for GemFire Process with PID (%1$d) to stop.", pid);
                    }
                };
                waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(15), TimeUnit.SECONDS.toMillis(5), false);
                if (!waitCriteria.done()) {
                    processIds.offer(pid);
                }
            }
        } catch (IOException ignore) {
        }
    }
    return serviceState.getStatus();
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) IOException(java.io.IOException) File(java.io.File)

Example 2 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class ConnectionPoolDUnitTest method waitForEntry.

/**
   * A handy method to poll for arrival of non-null/non-invalid entries
   * 
   * @param r the Region to poll
   * @param key the key of the Entry to poll for
   */
public static void waitForEntry(final Region r, final Object key) {
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return r.containsValueForKey(key);
        }

        public String description() {
            return "Waiting for entry " + key + " on region " + r;
        }
    };
    Wait.waitForCriterion(ev, 10 * 1000, 200, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 3 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class CqTimeTestListener method waitForUpdated.

public boolean waitForUpdated(final Object key) {
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return CqTimeTestListener.this.updates.contains(key);
        }

        public String description() {
            return "never got update event for CQ " + CqTimeTestListener.this.cqName;
        }
    };
    Wait.waitForCriterion(ev, MAX_TIME, 200, true);
    return true;
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 4 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class AsynchIndexMaintenanceJUnitTest method testIndexMaintenanceBasedOnThreshhold.

@Test
public void testIndexMaintenanceBasedOnThreshhold() throws Exception {
    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "AsynchIndexMaintenanceThreshold", "50");
    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "AsynchIndexMaintenanceInterval", "0");
    final Index ri = qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "p.getID", "/portfolio p");
    for (int i = 0; i < 49; ++i) {
        region.put("" + (i + 1), new Portfolio(i + 1));
        idSet.add((i + 1) + "");
    }
    // assertIndexDetailsEquals(0, getIndexSize(ri));
    region.put("50", new Portfolio(50));
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return (getIndexSize(ri) == 50);
        }

        public String description() {
            return "valueToEntriesMap never became 50";
        }
    };
    Wait.waitForCriterion(ev, 3000, 200, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Portfolio(org.apache.geode.cache.query.data.Portfolio) Index(org.apache.geode.cache.query.Index) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class AsynchIndexMaintenanceJUnitTest method testIndexMaintenanceBasedOnThresholdAsZero.

@Test
public void testIndexMaintenanceBasedOnThresholdAsZero() throws Exception {
    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "AsynchIndexMaintenanceThreshold", "0");
    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "AsynchIndexMaintenanceInterval", "60000");
    final Index ri = (Index) qs.createIndex("statusIndex", IndexType.FUNCTIONAL, "p.getID", "/portfolio p");
    for (int i = 0; i < 3; ++i) {
        region.put("" + (i + 1), new Portfolio(i + 1));
        idSet.add((i + 1) + "");
    }
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            return (getIndexSize(ri) == 3);
        }

        public String description() {
            return "valueToEntries map never became size 3";
        }
    };
    Wait.waitForCriterion(ev, 10 * 1000, 200, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) Portfolio(org.apache.geode.cache.query.data.Portfolio) Index(org.apache.geode.cache.query.Index) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)368 Test (org.junit.Test)132 Region (org.apache.geode.cache.Region)105 VM (org.apache.geode.test.dunit.VM)96 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)73 LocalRegion (org.apache.geode.internal.cache.LocalRegion)58 CacheException (org.apache.geode.cache.CacheException)57 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)53 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)50 AttributesFactory (org.apache.geode.cache.AttributesFactory)41 IgnoredException (org.apache.geode.test.dunit.IgnoredException)40 IOException (java.io.IOException)36 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)36 Cache (org.apache.geode.cache.Cache)34 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)34 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)33 Properties (java.util.Properties)31 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)28 Iterator (java.util.Iterator)27