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-6811: be able to create GWR in management api. (apache#3687)
* add createGWR methods in the gateway controllers * add GatewaReceiverConfigValidator * add MemberValidator to validate same element can't exists in multiple groups which have common member * add ConfigurationManager.get method to replace ConfigurationValidator.exists method for more conflict validation
- Loading branch information
1 parent
bdcdf0c
commit 7b4870a
Showing
33 changed files
with
822 additions
and
313 deletions.
There are no files selected for viewing
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
100 changes: 100 additions & 0 deletions
100
...st/java/org/apache/geode/management/internal/rest/GatewayReceiverManagementDUnitTest.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,100 @@ | ||
/* | ||
* 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.ClusterManagementResultAssert.assertManagementResult; | ||
|
||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
import org.apache.geode.cache.configuration.GatewayReceiverConfig; | ||
import org.apache.geode.examples.SimpleSecurityManager; | ||
import org.apache.geode.management.api.ClusterManagementResult; | ||
import org.apache.geode.management.api.ClusterManagementService; | ||
import org.apache.geode.management.client.ClusterManagementServiceBuilder; | ||
import org.apache.geode.test.dunit.rules.ClusterStartupRule; | ||
import org.apache.geode.test.dunit.rules.MemberVM; | ||
|
||
public class GatewayReceiverManagementDUnitTest { | ||
@ClassRule | ||
public static ClusterStartupRule cluster = new ClusterStartupRule(); | ||
|
||
private static MemberVM locator, server; | ||
private static ClusterManagementService cms; | ||
private GatewayReceiverConfig receiver; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
locator = cluster.startLocatorVM(0, | ||
l -> l.withSecurityManager(SimpleSecurityManager.class).withHttpService()); | ||
int locatorPort = locator.getPort(); | ||
server = cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort) | ||
.withProperty("groups", "group1") | ||
.withCredential("cluster", "cluster")); | ||
} | ||
|
||
@Before | ||
public void before() throws Exception { | ||
receiver = new GatewayReceiverConfig(); | ||
} | ||
|
||
@Test | ||
public void withInsuffientCredential() throws Exception { | ||
cms = ClusterManagementServiceBuilder.buildWithHostAddress() | ||
.setHostAddress("localhost", locator.getHttpPort()) | ||
.setCredentials("test", "test").build(); | ||
|
||
assertManagementResult(cms.create(receiver)).failed() | ||
.hasStatusCode(ClusterManagementResult.StatusCode.UNAUTHORIZED) | ||
.containsStatusMessage("test not authorized for CLUSTER:MANAGE"); | ||
} | ||
|
||
@Test | ||
public void createGWR() throws Exception { | ||
cms = ClusterManagementServiceBuilder.buildWithHostAddress() | ||
.setHostAddress("localhost", locator.getHttpPort()) | ||
.setCredentials("cluster", "cluster").build(); | ||
|
||
receiver.setStartPort("5000"); | ||
receiver.setGroup("group1"); | ||
assertManagementResult(cms.create(receiver)).isSuccessful() | ||
.containsStatusMessage("Successfully updated config for group1") | ||
.hasMemberStatus().hasSize(1); | ||
|
||
// try create another GWR on the same group | ||
receiver.setStartPort("5001"); | ||
receiver.setGroup("group1"); | ||
assertManagementResult(cms.create(receiver)).failed() | ||
.hasStatusCode(ClusterManagementResult.StatusCode.ENTITY_EXISTS) | ||
.containsStatusMessage("Member(s) server-1 already has this element created"); | ||
|
||
// try create another GWR on another group but has no server | ||
receiver.setStartPort("5002"); | ||
receiver.setGroup("group2"); | ||
assertManagementResult(cms.create(receiver)).isSuccessful() | ||
.containsStatusMessage("Successfully updated config for group2") | ||
.hasMemberStatus().hasSize(0); | ||
|
||
// try create another GWR on another group but has a common member in another goup | ||
receiver.setStartPort("5003"); | ||
receiver.setGroup(null); | ||
assertManagementResult(cms.create(receiver)).failed() | ||
.hasStatusCode(ClusterManagementResult.StatusCode.ENTITY_EXISTS) | ||
.containsStatusMessage("Member(s) server-1 already has this element created"); | ||
} | ||
} |
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
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
Oops, something went wrong.