You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by nabarunnag <gi...@git.apache.org> on 2017/03/09 00:23:49 UTC

[GitHub] geode pull request #420: GEODE-2635: Creating DUnit tests to test eviction i...

GitHub user nabarunnag opened a pull request:

    https://github.com/apache/geode/pull/420

    GEODE-2635: Creating DUnit tests to test eviction in lucene

    	* DUnit tests for eviction with local destroy and overflow
    	* Refactored the integration tests for eviction
    
    @upthewaterspout @jhuynh1 @boglesby @gesterzhou @ladyVader 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nabarunnag/incubator-geode feature/GEODE-2635

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/geode/pull/420.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #420
    
----
commit 642634cb1359249cba1d3030f761260dddaf217e
Author: nabarunnag <na...@cs.wisc.edu>
Date:   2017-03-09T00:16:52Z

    GEODE-2635: Creating DUnit tests to test eviction in lucene
    
    	* DUnit tests for eviction with local destroy and overflow
    	* Refactored the integration tests for eviction

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode pull request #420: GEODE-2635: Creating DUnit tests to test eviction i...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/geode/pull/420


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode pull request #420: GEODE-2635: Creating DUnit tests to test eviction i...

Posted by upthewaterspout <gi...@git.apache.org>.
Github user upthewaterspout commented on a diff in the pull request:

    https://github.com/apache/geode/pull/420#discussion_r105061375
  
    --- Diff: geode-lucene/src/test/java/org/apache/geode/cache/lucene/EvictionDUnitTest.java ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.geode.cache.lucene;
    +
    +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
    +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNull;
    +import static org.junit.Assert.assertTrue;
    +
    +import org.apache.geode.cache.Cache;
    +import org.apache.geode.cache.Region;
    +import org.apache.geode.distributed.internal.DistributionConfig;
    +import org.apache.geode.internal.cache.GemFireCacheImpl;
    +import org.apache.geode.internal.cache.PartitionedRegion;
    +import org.apache.geode.internal.cache.control.HeapMemoryMonitor;
    +import org.apache.geode.test.dunit.SerializableRunnableIF;
    +import org.apache.geode.test.junit.categories.DistributedTest;
    +import org.awaitility.Awaitility;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.runner.RunWith;
    +
    +import java.util.List;
    +import java.util.concurrent.TimeUnit;
    +import java.util.stream.IntStream;
    +import junitparams.JUnitParamsRunner;
    +import junitparams.Parameters;
    +
    +
    +@Category(DistributedTest.class)
    +@RunWith(JUnitParamsRunner.class)
    +public class EvictionDUnitTest extends LuceneQueriesAccessorBase {
    +
    +  protected final static float INITIAL_EVICTION_HEAP_PERCENTAGE = 50.9f;
    +  protected final static float EVICTION_HEAP_PERCENTAGE_FAKE_NOTIFICATION = 85.0f;
    +  protected final static int TEST_MAX_MEMORY = 100;
    +  protected final static int MEMORY_USED_FAKE_NOTIFICATION = 90;
    +
    +  protected RegionTestableType[] getPartitionRedundantOverflowEvictionRegionType() {
    +    return new RegionTestableType[] {RegionTestableType.PARTITION_REDUNDANT_EVICTION_OVERFLOW,
    +        RegionTestableType.PARTITION_PERSISTENT_REDUNDANT_EVICTION_OVERFLOW};
    +  }
    +
    +  protected RegionTestableType[] getPartitionRedundantLocalDestroyEvictionRegionType() {
    +    return new RegionTestableType[] {RegionTestableType.PARTITION_REDUNDANT_EVICTION_LOCAL_DESTROY};
    +  }
    +
    +  @Test
    +  @Parameters(method = "getPartitionRedundantLocalDestroyEvictionRegionType")
    +  public void regionWithEvictionWithLocalDestroyMustNotbeAbleToCreateLuceneIndexes(
    +      RegionTestableType regionTestType) {
    +    SerializableRunnableIF createIndex = () -> {
    +      LuceneService luceneService = LuceneServiceProvider.get(getCache());
    +      luceneService.createIndex(INDEX_NAME, REGION_NAME, "text");
    +    };
    +
    +    dataStore1.invoke(() -> {
    +      try {
    +        initDataStore(createIndex, regionTestType);
    +      } catch (UnsupportedOperationException e) {
    +        assertEquals(
    +            "Lucene indexes on regions with eviction and action local destroy are not supported",
    +            e.getMessage());
    +        assertNull(getCache().getRegion(REGION_NAME));
    +      }
    +    });
    +
    +  }
    +
    +  @Test
    +  @Parameters(method = "getPartitionRedundantOverflowEvictionRegionType")
    +  public void regionsWithEvictionWithOverflowMustBeAbleToCreateLuceneIndexes(
    +      RegionTestableType regionTestType) {
    +    SerializableRunnableIF createIndex = () -> {
    +      LuceneService luceneService = LuceneServiceProvider.get(getCache());
    +      luceneService.createIndex(INDEX_NAME, REGION_NAME, "text");
    +    };
    +
    +    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    +
    +    accessor.invoke(() -> initDataStore(createIndex, regionTestType));
    +
    +    accessor.invoke(() -> {
    +      Cache cache = getCache();
    +      Region region = cache.getRegion(REGION_NAME);
    +      IntStream.range(0, NUM_BUCKETS).forEach(i -> region.put(i, new TestObject("hello world")));
    +    });
    +
    +    dataStore1.invoke(() -> {
    +      try {
    +        getCache().getResourceManager().setEvictionHeapPercentage(INITIAL_EVICTION_HEAP_PERCENTAGE);
    +        final PartitionedRegion partitionedRegion = (PartitionedRegion) getRootRegion(REGION_NAME);
    +        raiseFakeNotification();
    +        Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
    --- End diff --
    
    This should probably wait longer than 5 seconds.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---