diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle index bcb7c4b3dc41..1c2ac837b1a6 100755 --- a/geode-assembly/build.gradle +++ b/geode-assembly/build.gradle @@ -36,6 +36,15 @@ publishing { } } +task createObjectSizerTenJar(type: Jar) { + description 'Assembles jar for use in "ConfigureEvictionThroughGfsh" "deploy jar" command.' + archiveName 'ObjectSizerTen.jar' + from sourceSets.acceptanceTest.output + destinationDir new File("${buildDir}/resources/acceptanceTest") + include 'org/apache/geode/management/internal/cli/commands/ObjectSizerTen.*' +} +acceptanceTest.dependsOn createObjectSizerTenJar + logger.info("Gradle doesn't automatically remove the jar artifact even though we disabled it") logger.info("this causes publishing to fail. So we nuke all the disabled artifacts from all configurations.") configurations.all { diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java index e40ec3a5d168..73379b7fb18c 100644 --- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ConfigureEvictionThroughGfsh.java @@ -17,25 +17,36 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.io.File; -import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.apache.geode.test.compiler.JarBuilder; 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; +/** + * Consumes {@link ObjectSizerTen} as built and packaged into the jar deployed below. + */ // GEODE-1897 Users should be able to configure eviction through gfsh public class ConfigureEvictionThroughGfsh { @Rule public GfshRule gfsh = new GfshRule(); + private URL jarToDeploy; + + @Before + public void setJar() { + jarToDeploy = getClass().getResource("/ObjectSizerTen.jar"); + assertThat(jarToDeploy).isNotNull(); + } + @Test - public void configureEvictionByEntryCount() throws Exception { + public void configureEvictionByEntryCount() { GfshExecution execution = GfshScript .of("start locator --name=locator", "start server --name=server", @@ -92,7 +103,7 @@ public void configureEvictionByEntryCount() throws Exception { } @Test - public void configureEvictionByMaxMemory() throws Exception { + public void configureEvictionByMaxMemory() { 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", @@ -145,28 +156,16 @@ public void configureEvictionByMaxMemory() throws Exception { .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 { + public void configureEvictionByObjectSizer() throws URISyntaxException { 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") + "deploy --jar=" + jarToDeploy.toURI().getPath(), + "create region --name=region1 --eviction-action=local-destroy --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=REPLICATE", + "create region --name=region2 --eviction-action=overflow-to-disk --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=REPLICATE", + "create region --name=region3 --eviction-action=overflow-to-disk --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=REPLICATE_PERSISTENT", + "create region --name=region4 --eviction-action=local-destroy --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=LOCAL", + "create region --name=region5 --eviction-action=overflow-to-disk --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=LOCAL") .execute(gfsh); assertThat(execution.getOutputText()).contains("Region \"/region1\" created on \"server\""); @@ -177,7 +176,7 @@ public void configureEvictionByObjectSizer() throws Exception { 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") + "create region --name=region6 --eviction-action=local-destroy --eviction-max-memory=1000 --eviction-object-sizer=org.apache.geode.management.internal.cli.commands.ObjectSizerTen --type=REPLICATE_PERSISTENT") .expectFailure().execute(gfsh); assertThat(execution.getOutputText()).contains( "ERROR: An Eviction Controller with local destroy eviction action is incompatible with"); diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ObjectSizerTen.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ObjectSizerTen.java new file mode 100644 index 000000000000..c5749f4cbb87 --- /dev/null +++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/management/internal/cli/commands/ObjectSizerTen.java @@ -0,0 +1,30 @@ +/* + * 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 org.apache.geode.cache.Declarable; +import org.apache.geode.cache.util.ObjectSizer; + +/** + * This class is built and packaged into a jar for consumption in + * {@link ConfigureEvictionThroughGfsh} + */ +@SuppressWarnings("unused") +public class ObjectSizerTen implements ObjectSizer, Declarable { + public int sizeof(Object o) { + return 10; + } +} diff --git a/gradle/test.gradle b/gradle/test.gradle index 670675536a7b..ea8ef73309f2 100644 --- a/gradle/test.gradle +++ b/gradle/test.gradle @@ -173,32 +173,37 @@ subprojects { } task repeatDistributedTest(type: RepeatTest) { + dependsOn distributedTest.taskDependencies classpath = project.sourceSets.distributedTest.runtimeClasspath testClassesDirs = project.sourceSets.distributedTest.output.classesDirs } task repeatIntegrationTest(type: RepeatTest) { + dependsOn integrationTest.taskDependencies classpath = project.sourceSets.integrationTest.runtimeClasspath testClassesDirs = project.sourceSets.integrationTest.output.classesDirs } task repeatAcceptanceTest(type: RepeatTest) { + dependsOn acceptanceTest.taskDependencies classpath = project.sourceSets.acceptanceTest.runtimeClasspath testClassesDirs = project.sourceSets.acceptanceTest.output.classesDirs } task repeatUpgradeTest(type: RepeatTest) { + dependsOn upgradeTest.taskDependencies classpath = project.sourceSets.upgradeTest.runtimeClasspath testClassesDirs = project.sourceSets.upgradeTest.output.classesDirs } task repeatUnitTest(type: RepeatTest) { + dependsOn test.taskDependencies // default classpath works for this one. } configure([repeatDistributedTest, repeatIntegrationTest, repeatUpgradeTest, repeatUnitTest, repeatAcceptanceTest]) { times = Integer.parseInt(repeat) - useJUnit {} + useJUnit() outputs.upToDateWhen { false } if (project.hasProperty("failOnNoMatchingTests")) {