forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-7398: implement get single deployment end point (apache#4455)
Co-authored-by: Dale Emery <[email protected]>
- Loading branch information
1 parent
ea65f4d
commit 37eb8b4
Showing
3 changed files
with
171 additions
and
17 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
...butedTest/java/org/apache/geode/management/internal/rest/DeployToMultiGroupDUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* 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.rest; | ||
|
||
import static org.apache.geode.test.junit.assertions.ClusterManagementListResultAssert.assertManagementListResult; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.io.FilenameUtils; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import org.apache.geode.management.api.ClusterManagementException; | ||
import org.apache.geode.management.api.ClusterManagementListResult; | ||
import org.apache.geode.management.api.ClusterManagementService; | ||
import org.apache.geode.management.client.ClusterManagementServiceBuilder; | ||
import org.apache.geode.management.configuration.Deployment; | ||
import org.apache.geode.management.runtime.DeploymentInfo; | ||
import org.apache.geode.test.compiler.JarBuilder; | ||
import org.apache.geode.test.dunit.rules.ClusterStartupRule; | ||
import org.apache.geode.test.dunit.rules.MemberVM; | ||
import org.apache.geode.test.junit.assertions.ClusterManagementListResultAssert; | ||
import org.apache.geode.test.junit.rules.GfshCommandRule; | ||
|
||
public class DeployToMultiGroupDUnitTest { | ||
@ClassRule | ||
public static ClusterStartupRule cluster = new ClusterStartupRule(); | ||
|
||
private static MemberVM locator, server1, server2; | ||
|
||
private static ClusterManagementService client; | ||
|
||
@ClassRule | ||
public static GfshCommandRule gfsh = new GfshCommandRule(); | ||
|
||
@ClassRule | ||
public static TemporaryFolder stagingTempDir = new TemporaryFolder(); | ||
private static File stagingDir, jar; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
// prepare the jars to be deployed | ||
stagingDir = stagingTempDir.newFolder("staging"); | ||
jar = new File(stagingDir, "lib.jar"); | ||
JarBuilder jarBuilder = new JarBuilder(); | ||
jarBuilder.buildJarFromClassNames(jar, "Class1"); | ||
locator = cluster.startLocatorVM(0, l -> l.withHttpService()); | ||
server1 = cluster.startServerVM(1, "group1", locator.getPort()); | ||
server2 = cluster.startServerVM(2, "group2", locator.getPort()); | ||
|
||
client = | ||
ClusterManagementServiceBuilder.buildWithHostAddress() | ||
.setHostAddress("localhost", locator.getHttpPort()) | ||
.build(); | ||
gfsh.connect(locator); | ||
|
||
gfsh.executeAndAssertThat("deploy --group=group1 --jar=" + jar.getAbsolutePath()) | ||
.statusIsSuccess(); | ||
gfsh.executeAndAssertThat("deploy --group=group2 --jar=" + jar.getAbsolutePath()) | ||
.statusIsSuccess(); | ||
} | ||
|
||
@Test | ||
public void listAll() { | ||
ClusterManagementListResult<Deployment, DeploymentInfo> list = client.list(new Deployment()); | ||
ClusterManagementListResultAssert<Deployment, DeploymentInfo> resultAssert = | ||
assertManagementListResult(list).isSuccessful(); | ||
resultAssert.hasConfigurations().extracting(Deployment::getJarFileName) | ||
.containsExactlyInAnyOrder("lib.jar", "lib.jar"); | ||
resultAssert.hasRuntimeInfos().extracting(DeploymentInfo::getJarLocation).extracting( | ||
FilenameUtils::getName) | ||
.containsExactlyInAnyOrder("lib.v1.jar", "lib.v1.jar"); | ||
} | ||
|
||
@Test | ||
public void listByGroup() throws Exception { | ||
Deployment filter = new Deployment(); | ||
filter.setGroup("group1"); | ||
ClusterManagementListResult<Deployment, DeploymentInfo> list = client.list(filter); | ||
ClusterManagementListResultAssert<Deployment, DeploymentInfo> resultAssert = | ||
assertManagementListResult(list).isSuccessful(); | ||
resultAssert.hasConfigurations().extracting(Deployment::getJarFileName) | ||
.containsExactlyInAnyOrder("lib.jar"); | ||
resultAssert.hasRuntimeInfos().extracting(DeploymentInfo::getJarLocation).extracting( | ||
FilenameUtils::getName).containsExactlyInAnyOrder("lib.v1.jar"); | ||
} | ||
|
||
@Test | ||
public void listById() throws Exception { | ||
Deployment filter = new Deployment(); | ||
filter.setJarFileName("lib.jar"); | ||
ClusterManagementListResult<Deployment, DeploymentInfo> list = client.list(filter); | ||
ClusterManagementListResultAssert<Deployment, DeploymentInfo> resultAssert = | ||
assertManagementListResult(list).isSuccessful(); | ||
resultAssert.hasConfigurations().extracting(Deployment::getJarFileName) | ||
.containsExactlyInAnyOrder("lib.jar", "lib.jar"); | ||
resultAssert.hasRuntimeInfos().extracting(DeploymentInfo::getJarLocation).extracting( | ||
FilenameUtils::getName).containsExactlyInAnyOrder("lib.v1.jar", "lib.v1.jar"); | ||
} | ||
|
||
@Test | ||
public void getById() throws Exception { | ||
Deployment filter = new Deployment(); | ||
filter.setJarFileName("lib.jar"); | ||
assertThatThrownBy(() -> client.get(filter)).isInstanceOf(ClusterManagementException.class) | ||
.hasMessageContaining("ERROR: Expect only one matching Deployment."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters