[ 
https://issues.apache.org/jira/browse/GEODE-2563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16260985#comment-16260985
 ] 

ASF GitHub Bot commented on GEODE-2563:
---------------------------------------

jdeppe-pivotal closed pull request #1056: GEODE-2563:Added acceptance test
URL: https://github.com/apache/geode/pull/1056
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java
 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java
new file mode 100644
index 0000000000..61b9a8c913
--- /dev/null
+++ 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java
@@ -0,0 +1,229 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.compiler.JarBuilder;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.AcceptanceTest;
+import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+import org.apache.geode.test.junit.rules.gfsh.GfshScript;
+
+// GEODE-1897 Users should be able to configure eviction through gfsh
+@Category(AcceptanceTest.class)
+public class ConfigureEvictionThroughGfsh {
+
+  @Rule
+  public GfshRule gfsh = new GfshRule();
+
+
+  @Test
+  public void ConfigureEvictionByEntryCount() throws Exception {
+
+    GfshExecution execution = GfshScript
+        .of("start locator --name=locator", "start server --name=server",
+            "create region --name=region1 --eviction-action=local-destroy 
--eviction-entry-count=1000 --type=REPLICATE",
+            "create region --name=region2 --eviction-action=overflow-to-disk 
--eviction-entry-count=1000 --type=REPLICATE",
+            "create region --name=region3 --eviction-action=overflow-to-disk 
--eviction-entry-count=1000 --type=REPLICATE_PERSISTENT",
+            "create region --name=region4 --eviction-action=local-destroy 
--eviction-entry-count=1000 --type=LOCAL",
+            "create region --name=region5 --eviction-action=overflow-to-disk 
--eviction-entry-count=1000 --type=LOCAL")
+        .execute(gfsh);
+
+    assertThat(execution.getOutputText()).contains("Region \"/region1\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region2\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region3\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region4\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region5\" 
created on \"server\"");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]",
+            "create region --name=region6 --eviction-action=local-destroy 
--eviction-entry-count=1000 --type=REPLICATE_PERSISTENT")
+        .expectFailure().execute(gfsh);
+    assertThat(execution.getOutputText()).contains(
+        "ERROR: An Eviction Controller with local destroy eviction action is 
incompatible with");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region1").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region1")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-maximum-value\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region2").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region2")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-maximum-value\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region3").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region3")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-maximum-value\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region4").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region4")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-maximum-value\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region5").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region5")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-maximum-value\\s+ | 1000");
+
+  }
+
+  @Test
+  public void ConfigureEvictionByMaxMemory() throws Exception {
+    GfshExecution execution = GfshScript
+        .of("start locator --name=locator", "start server --name=server",
+            "create region --name=region1 --eviction-action=local-destroy 
--eviction-max-memory=1000 --type=REPLICATE",
+            "create region --name=region2 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --type=REPLICATE",
+            "create region --name=region3 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --type=REPLICATE_PERSISTENT",
+            "create region --name=region4 --eviction-action=local-destroy 
--eviction-max-memory=1000 --type=LOCAL",
+            "create region --name=region5 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --type=LOCAL")
+        .execute(gfsh);
+    assertThat(execution.getOutputText()).contains("Region \"/region1\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region2\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region3\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region4\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region5\" 
created on \"server\"");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]",
+            "create region --name=region6 --eviction-action=local-destroy 
--eviction-max-memory=1000 --type=REPLICATE_PERSISTENT")
+        .expectFailure().execute(gfsh);
+    assertThat(execution.getOutputText()).contains(
+        "ERROR: An Eviction Controller with local destroy eviction action is 
incompatible with");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region1").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region1")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region2").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region2")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region3").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region3")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region4").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region4")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region5").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region5")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+
+  }
+
+
+  private File createJar() throws IOException {
+    File jarToDeploy = new File(gfsh.getTemporaryFolder().getRoot(), 
"ourJar.jar");
+
+    String classContents =
+        "import org.apache.geode.cache.util.ObjectSizer; import 
org.apache.geode.cache.Declarable;public class MySizer implements ObjectSizer, 
Declarable { public int sizeof(Object o) { return 10; } }";
+
+    JarBuilder jarBuilder = new JarBuilder();
+    jarBuilder.buildJar(jarToDeploy, classContents);
+
+    return jarToDeploy;
+  }
+
+  @Test
+  public void ConfigureEvictionByObjectSizer() throws Exception {
+    GfshExecution execution = GfshScript
+        .of("start locator --name=locator", "start server --name=server", 
"sleep --time=1",
+            "deploy --jar=" + createJar().getAbsolutePath(),
+            "create region --name=region1 --eviction-action=local-destroy 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer --type=REPLICATE",
+            "create region --name=region2 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer --type=REPLICATE",
+            "create region --name=region3 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer 
--type=REPLICATE_PERSISTENT",
+            "create region --name=region4 --eviction-action=local-destroy 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer --type=LOCAL",
+            "create region --name=region5 --eviction-action=overflow-to-disk 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer --type=LOCAL")
+        .execute(gfsh);
+
+    assertThat(execution.getOutputText()).contains("Region \"/region1\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region2\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region3\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region4\" 
created on \"server\"");
+    assertThat(execution.getOutputText()).contains("Region \"/region5\" 
created on \"server\"");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]",
+            "create region --name=region6 --eviction-action=local-destroy 
--eviction-max-memory=1000 --eviction-object-sizer=MySizer 
--type=REPLICATE_PERSISTENT")
+        .expectFailure().execute(gfsh);
+    assertThat(execution.getOutputText()).contains(
+        "ERROR: An Eviction Controller with local destroy eviction action is 
incompatible with");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region1").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region1")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region2").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region2")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region3").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region3")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region4").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region4")
+        .containsPattern("eviction-action\\s+| local-destroy")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+    execution = GfshScript
+        .of("connect --locator=localhost[10334]", "describe region 
--name=region5").execute(gfsh);
+    assertThat(execution.getOutputText()).containsPattern("region5")
+        .containsPattern("eviction-action\\s+| overflow-to-disk")
+        .containsPattern("eviction-max-memory\\s+ | 1000");
+
+  }
+
+
+
+}
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyIndexIfExistsTest.java
 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyIndexIfExistsTest.java
new file mode 100644
index 0000000000..dfadbd67dd
--- /dev/null
+++ 
b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyIndexIfExistsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.compiler.JarBuilder;
+import org.apache.geode.test.junit.categories.AcceptanceTest;
+import org.apache.geode.test.junit.rules.gfsh.GfshExecution;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+import org.apache.geode.test.junit.rules.gfsh.GfshScript;
+
+@Category(AcceptanceTest.class)
+public class DestroyIndexIfExistsTest {
+
+  @Rule
+  public GfshRule gfsh = new GfshRule();
+
+
+  @Test
+  public void destroyIndexIfExists() throws Exception {
+    GfshExecution execution =
+        GfshScript.of("start locator --name=locator", "start server 
--name=server",
+            "sleep --time=1", "destroy index --name=i1 
--if-exists=true").execute(gfsh);
+
+    assertThat(execution.getOutputText()).contains("Index i1 not found - 
skipped");
+  }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> All destroy commands in gfsh should be idempotent
> -------------------------------------------------
>
>                 Key: GEODE-2563
>                 URL: https://issues.apache.org/jira/browse/GEODE-2563
>             Project: Geode
>          Issue Type: Improvement
>          Components: gfsh
>            Reporter: Swapnil Bawaskar
>
> If a developer is using gfsh script to define the geode cluster, we should 
> support the ability to run the gfsh script multiple times.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to