Skip to content

Commit 1e7bba0

Browse files
jinmeiliaodschneider-pivotaldemery-pivotal
authored
GEODE-7398 :show deployer and deploy time (apache#4509)
Co-authored-by: Darrel Schneider <[email protected]> Co-authored-by: Dale Emery <[email protected]> Co-authored-by: Jinmei Liao <[email protected]>
1 parent 8d399ab commit 1e7bba0

File tree

19 files changed

+795
-289
lines changed

19 files changed

+795
-289
lines changed

geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/DeploymentManagementDUnitTest.java

+25-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.junit.Test;
2929
import org.junit.rules.TemporaryFolder;
3030

31+
import org.apache.geode.distributed.internal.DistributionConfig;
32+
import org.apache.geode.examples.SimpleSecurityManager;
3133
import org.apache.geode.management.api.ClusterManagementGetResult;
3234
import org.apache.geode.management.api.ClusterManagementListResult;
3335
import org.apache.geode.management.api.ClusterManagementService;
@@ -68,15 +70,20 @@ public static void beforeClass() throws Exception {
6870
jarBuilder.buildJarFromClassNames(group2Jar, "Class2");
6971
jarBuilder.buildJarFromClassNames(clusterJar, "Class3");
7072

71-
locator = cluster.startLocatorVM(0, l -> l.withHttpService());
72-
server1 = cluster.startServerVM(1, "group1", locator.getPort());
73-
server2 = cluster.startServerVM(2, "group2", locator.getPort());
73+
locator = cluster.startLocatorVM(0, l -> l.withHttpService().withSecurityManager(
74+
SimpleSecurityManager.class));
75+
int locatorPort = locator.getPort();
76+
server1 = cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort).withProperty(
77+
DistributionConfig.GROUPS_NAME, "group1").withCredential("cluster", "cluster"));
78+
server2 = cluster.startServerVM(2, s -> s.withConnectionToLocator(locatorPort).withProperty(
79+
DistributionConfig.GROUPS_NAME, "group2").withCredential("cluster", "cluster"));
7480

7581
client =
7682
ClusterManagementServiceBuilder.buildWithHostAddress()
7783
.setHostAddress("localhost", locator.getHttpPort())
84+
.setCredentials("cluster", "cluster")
7885
.build();
79-
gfsh.connect(locator);
86+
gfsh.secureConnect(locatorPort, GfshCommandRule.PortType.locator, "cluster", "cluster");
8087

8188
gfsh.executeAndAssertThat("deploy --group=group1 --jar=" + group1Jar.getAbsolutePath())
8289
.statusIsSuccess();
@@ -115,15 +122,24 @@ public void listByGroup() throws Exception {
115122
public void listById() throws Exception {
116123
Deployment filter = new Deployment();
117124
filter.setJarFileName("cluster.jar");
125+
118126
ClusterManagementListResult<Deployment, DeploymentInfo> list = client.list(filter);
127+
119128
ClusterManagementListResultAssert<Deployment, DeploymentInfo> resultAssert =
120129
assertManagementListResult(list).isSuccessful();
121-
resultAssert.hasConfigurations().extracting(Deployment::getJarFileName)
122-
.containsExactlyInAnyOrder("cluster.jar");
130+
131+
assertThat(list.getConfigResult()).hasSize(1);
132+
Deployment deployment = list.getConfigResult().get(0);
133+
assertThat(deployment.getJarFileName()).isEqualTo("cluster.jar");
134+
assertThat(deployment.getDeployedBy()).isEqualTo("cluster");
135+
assertThat(deployment.getDeployedTime()).isNotNull();
136+
123137
List<DeploymentInfo> runtimeResult = resultAssert.getActual().getRuntimeResult();
124-
assertThat(runtimeResult).extracting(DeploymentInfo::getJarLocation).extracting(
125-
FilenameUtils::getName).containsExactlyInAnyOrder("cluster.v1.jar", "cluster.v1.jar");
126-
assertThat(runtimeResult.get(0).getTimeDeployed()).isNotNull();
138+
assertThat(runtimeResult)
139+
.extracting(DeploymentInfo::getJarLocation)
140+
.extracting(FilenameUtils::getName)
141+
.containsExactlyInAnyOrder("cluster.v1.jar", "cluster.v1.jar");
142+
assertThat(runtimeResult.get(0).getLastModified()).isNotNull();
127143
}
128144

129145
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for additional information regarding
4+
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
5+
* "License"); you may not use this file except in compliance with the License. You may obtain a
6+
* copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software distributed under the License
11+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
* or implied. See the License for the specific language governing permissions and limitations under
13+
* the License.
14+
*/
15+
16+
package org.apache.geode.management;
17+
18+
import static org.apache.geode.test.junit.assertions.ClusterManagementListResultAssert.assertManagementListResult;
19+
20+
import java.io.File;
21+
import java.io.IOException;
22+
23+
import org.junit.BeforeClass;
24+
import org.junit.ClassRule;
25+
import org.junit.Rule;
26+
import org.junit.Test;
27+
import org.junit.rules.TemporaryFolder;
28+
29+
import org.apache.geode.internal.AvailablePortHelper;
30+
import org.apache.geode.management.api.ClusterManagementService;
31+
import org.apache.geode.management.client.ClusterManagementServiceBuilder;
32+
import org.apache.geode.management.configuration.Deployment;
33+
import org.apache.geode.test.compiler.JarBuilder;
34+
import org.apache.geode.test.junit.rules.gfsh.GfshRule;
35+
36+
public class DeploymentManagementUpgradeTest {
37+
@Rule
38+
public GfshRule oldGfsh = new GfshRule("1.10.0");
39+
40+
@Rule
41+
public GfshRule gfsh = new GfshRule();
42+
43+
@ClassRule
44+
public static TemporaryFolder tempFolder = new TemporaryFolder();
45+
private static File stagingDir, clusterJar;
46+
47+
@BeforeClass
48+
public static void beforeClass() throws Exception {
49+
// prepare the jars to be deployed
50+
stagingDir = tempFolder.newFolder("staging");
51+
clusterJar = new File(stagingDir, "cluster.jar");
52+
JarBuilder jarBuilder = new JarBuilder();
53+
jarBuilder.buildJarFromClassNames(clusterJar, "Class1");
54+
}
55+
56+
@Test
57+
public void newLocatorCanReadOldConfigurationData() throws IOException {
58+
File workingDir = tempFolder.newFolder();
59+
int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
60+
oldGfsh.execute("start locator --name=test --port=" + ports[0] + " --http-service-port="
61+
+ ports[1] + " --dir=" + workingDir.getAbsolutePath() + " --J=-Dgemfire.jmx-manager-port="
62+
+ ports[2],
63+
"deploy --jar=" + clusterJar.getAbsolutePath(),
64+
"shutdown --include-locators");
65+
66+
gfsh.execute("start locator --name=test --port=" + ports[0] + " --http-service-port=" + ports[1]
67+
+ " --dir=" + workingDir.getAbsolutePath() + " --J=-Dgemfire.jmx-manager-port=" + ports[2]);
68+
69+
ClusterManagementService cms =
70+
ClusterManagementServiceBuilder.buildWithHostAddress().setHostAddress("localhost", ports[1])
71+
.build();
72+
assertManagementListResult(cms.list(new Deployment())).isSuccessful()
73+
.hasConfigurations().hasSize(1);
74+
}
75+
}

geode-core/src/integrationTest/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2034,8 +2034,8 @@ fromData,17
20342034
toData,17
20352035

20362036
org/apache/geode/management/internal/configuration/domain/Configuration,2
2037-
fromData,49
2038-
toData,52
2037+
fromData,110
2038+
toData,62
20392039

20402040
org/apache/geode/management/internal/configuration/domain/ConfigurationChangeResult,2
20412041
fromData,31

0 commit comments

Comments
 (0)