Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into geode-6400
Browse files Browse the repository at this point in the history
  • Loading branch information
PurelyApplied authored and robbadler committed Apr 2, 2019
2 parents 6fdaae3 + 1ff5f2e commit c3e8c60
Show file tree
Hide file tree
Showing 85 changed files with 3,326 additions and 896 deletions.
20 changes: 8 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ buildscript {
}

dependencies {
// Newer versions of the nebula plugins require gradle-info-plugin 4.0.2 or higher, which in
// depends on JGit 5.0. Conversely, gradle-git relies of JGit 4.0.
// Be mindful of potential classpath issues when updating any of these three dependencies.
classpath "com.netflix.nebula:nebula-project-plugin:5.1.0"
classpath "com.netflix.nebula:gradle-lint-plugin:10.1.0"
classpath "org.ajoberstar:gradle-git:1.7.2"

classpath "gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.3.1"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2'
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.10.0"
classpath "com.netflix.nebula:nebula-project-plugin:6.0.2"
classpath "com.netflix.nebula:gradle-lint-plugin:11.4.4"
classpath "org.ajoberstar.grgit:grgit-gradle:3.1.1"
classpath "org.nosphere.apache:creadur-rat-gradle:0.4.0"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7'
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.21.1"
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.8"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.7.RELEASE'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LogEvent;
Expand All @@ -33,45 +32,39 @@
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.configuration.RegionConfig;
import org.apache.geode.management.api.ClusterManagementResult;
import org.apache.geode.management.api.ClusterManagementService;
import org.apache.geode.management.client.ClusterManagementServiceProvider;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GeodeDevRestClient;

public class ManagementRequestLoggingDUnitTest {

@ClassRule
public static ClusterStartupRule cluster = new ClusterStartupRule();

private static MemberVM locator, server;

private static GeodeDevRestClient restClient;
private static ClusterManagementService service;

@BeforeClass
public static void beforeClass() {
locator = cluster.startLocatorVM(0, l -> l.withHttpService());
server = cluster.startServerVM(1, locator.getPort());
restClient =
new GeodeDevRestClient("/geode-management/v2", "localhost", locator.getHttpPort(), false);
service = ClusterManagementServiceProvider.getService("localhost", locator.getHttpPort());
}

@Test
public void checkRequestsAreLogged() throws Exception {
locator.invoke(() -> {
Logger logger = (Logger) LogManager.getLogger(ManagementLoggingFilter.class);
logger.addAppender(new ListAppender("ListAppender"));
ListAppender listAppender = new ListAppender("ListAppender");
logger.addAppender(listAppender);
listAppender.start();
});

RegionConfig regionConfig = new RegionConfig();
regionConfig.setName("customers");
regionConfig.setType(RegionShortcut.REPLICATE);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(regionConfig);

ClusterManagementResult result =
restClient.doPostAndAssert("/regions", json)
.hasStatusCode(201)
.getClusterManagementResult();

ClusterManagementResult result = service.create(regionConfig);
assertThat(result.isSuccessful()).isTrue();

locator.invoke(() -> {
Expand All @@ -80,9 +73,13 @@ public void checkRequestsAreLogged() throws Exception {
ListAppender listAppender = (ListAppender) appenders.get("ListAppender");
List<LogEvent> logEvents = listAppender.getEvents();

assertThat(logEvents.size()).as("Expected LogEvents").isEqualTo(1);
assertThat(logEvents.get(0).getMessage().getFormattedMessage())
.startsWith("Management request:");
assertThat(logEvents.size()).as("Expected LogEvents").isEqualTo(2);
String beforeMessage = logEvents.get(0).getMessage().getFormattedMessage();
assertThat(beforeMessage).startsWith("Management Request: POST");
assertThat(beforeMessage).contains("user=").contains("payload={")
.contains("regionAttributes");
assertThat(logEvents.get(1).getMessage().getFormattedMessage())
.startsWith("Management Response: ").contains("response={").contains("Status=");

logger.removeAppender(listAppender);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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.assertj.core.api.Assertions.assertThat;

import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;

import org.apache.geode.cache.configuration.CacheElement;
import org.apache.geode.management.api.ClusterManagementResult;
import org.apache.geode.management.api.ClusterManagementService;
import org.apache.geode.management.client.ClusterManagementServiceProvider;
import org.apache.geode.management.configuration.MemberConfig;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;

public class MemberManagementServiceDunitTest {
@ClassRule
public static ClusterStartupRule cluster = new ClusterStartupRule(2);

private static MemberVM locator, server;
private static ClusterManagementService cmsClient;

@BeforeClass
public static void beforeClass() {
locator = cluster.startLocatorVM(0, l -> l.withHttpService());
server = cluster.startServerVM(1, locator.getPort());
cmsClient = ClusterManagementServiceProvider.getService("localhost", locator.getHttpPort());
}

@Test
public void listAllMembers() {
MemberConfig config = new MemberConfig();
ClusterManagementResult result = cmsClient.list(config);

assertThat(result.isSuccessful()).isTrue();
assertThat(result.getStatusCode()).isEqualTo(ClusterManagementResult.StatusCode.OK);
assertThat(result.getResult().size()).isEqualTo(2);

MemberConfig memberConfig =
(MemberConfig) CacheElement.findElement(result.getResult(), "locator-0");
assertThat(memberConfig.isCoordinator()).isTrue();
assertThat(memberConfig.isLocator()).isTrue();
assertThat(memberConfig.getPorts().get(0)).isEqualTo(locator.getPort());
}

@Test
public void listOneMember() throws Exception {
MemberConfig config = new MemberConfig();
config.setId("locator-0");

ClusterManagementResult result = cmsClient.list(config);
assertThat(result.isSuccessful()).isTrue();
assertThat(result.getStatusCode()).isEqualTo(ClusterManagementResult.StatusCode.OK);
assertThat(result.getResult().size()).isEqualTo(1);

MemberConfig memberConfig = (MemberConfig) result.getResult().get(0);
assertThat(memberConfig.isCoordinator()).isTrue();
assertThat(memberConfig.isLocator()).isTrue();
assertThat(memberConfig.getPorts().get(0)).isEqualTo(locator.getPort());
}

@Test
public void listNonExistentMember() throws Exception {
MemberConfig config = new MemberConfig();
config.setId("locator");
ClusterManagementResult result = cmsClient.list(config);
assertThat(result.isSuccessful()).isTrue();
assertThat(result.getStatusCode())
.isEqualTo(ClusterManagementResult.StatusCode.OK);
assertThat(result.getResult().size()).isEqualTo(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.controllers;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;

import org.apache.geode.management.api.ClusterManagementService;
import org.apache.geode.management.internal.ClientClusterManagementService;
import org.apache.geode.test.junit.rules.LocatorStarterRule;

public class ClusterManagementRestLoggingTest {
@ClassRule
public static LocatorStarterRule locator = new LocatorStarterRule().withHttpService()
.withSystemProperty("geode.management.request.logging", "false").withAutoStart();

private static ClusterManagementService cms;

@BeforeClass
public static void beforeClass() throws Exception {
cms = new ClientClusterManagementService("localhost", locator.getHttpPort());
}

@Test
public void ping() throws Exception {
assertThat(cms.isConnected()).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ javadoc/org/apache/geode/management/client/ClusterManagementServiceProvider.html
javadoc/org/apache/geode/management/client/package-frame.html
javadoc/org/apache/geode/management/client/package-summary.html
javadoc/org/apache/geode/management/client/package-tree.html
javadoc/org/apache/geode/management/configuration/MemberConfig.html
javadoc/org/apache/geode/management/configuration/package-frame.html
javadoc/org/apache/geode/management/configuration/package-summary.html
javadoc/org/apache/geode/management/configuration/package-tree.html
javadoc/org/apache/geode/management/membership/ClientMembership.html
javadoc/org/apache/geode/management/membership/ClientMembershipEvent.html
javadoc/org/apache/geode/management/membership/ClientMembershipListener.html
Expand Down Expand Up @@ -904,13 +908,13 @@ lib/geode-cq-0.0.0.jar
lib/geode-dependencies.jar
lib/geode-jca-0.0.0.rar
lib/geode-lucene-0.0.0.jar
lib/geode-redis-0.0.0.jar
lib/geode-memcached-0.0.0.jar
lib/geode-management-0.0.0.jar
lib/geode-memcached-0.0.0.jar
lib/geode-old-client-support-0.0.0.jar
lib/geode-protobuf-0.0.0.jar
lib/geode-protobuf-messages-0.0.0.jar
lib/geode-rebalancer-0.0.0.jar
lib/geode-redis-0.0.0.jar
lib/geode-wan-0.0.0.jar
lib/gfsh-dependencies.jar
lib/grumpy-core-0.2.2.jar
Expand Down
1 change: 1 addition & 0 deletions geode-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ apply from: "${project.projectDir}/../gradle/publish.gradle"

dependencies {
compile(platform(project(':boms:geode-all-bom')))
compile('com.fasterxml.jackson.core:jackson-databind')
testCompile('junit:junit')
testCompile('org.assertj:assertj-core')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.util.internal;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* helper class for creating various json mappers used by Geode Project
*/
public class GeodeJsonMapper {

/**
* @return a jackson json mapper that allows single quotes and is able to deserialize json
* string without @JsonTypeInfo if base class is a concrete implementation.
*/
public static ObjectMapper getMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
mapper.configure(MapperFeature.USE_BASE_TYPE_AS_DEFAULT_IMPL, true);
return mapper;
}
}
7 changes: 7 additions & 0 deletions geode-common/src/test/resources/expected-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
8 changes: 7 additions & 1 deletion geode-concurrency-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply from: "${project.projectDir}/../gradle/publish.gradle"

apply from: "${project.projectDir}/../gradle/publish.gradle"

dependencies {
compile(platform(project(':boms:geode-all-bom')))
compile('junit:junit')
compile('org.apache.logging.log4j:log4j-api')
testCompile('org.assertj:assertj-core')
}

test {
// Some tests have inner tests that should be ignored
exclude "**/*\$*.class"
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
* test can use to invoke code in parallel.
*
* This test run will try to exercise the test method to flush out any concurrent bugs in the
* parallel execution. Currently this runner is using Java PathFinder to run the test with *all*
* possible thread interleavings, but other methods such as invoking the method multiple times in a
* normal JVM may be supported in the feature.
* parallel execution.
*
* All test logic and state *must* be encapsulated in the individual test methods. This is because
* the concurrency testing logic may need to invoke the test body multiple times, possibly in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.apache.geode.test.concurrency;

import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand All @@ -40,9 +42,18 @@ default <T> Future<T> inParallel(RunnableWithException runnable) {
});
}

default <T> Collection<Future<T>> inParallel(RunnableWithException runnable, int count) {
ArrayList<Future<T>> futures = new ArrayList<>(count);
for (; count > 0; count--) {
futures.add(inParallel(runnable));
}
return futures;
}

/**
* Execute all tasks in parallel, wait for them to complete and throw an exception if any of the
* tasks throw an exception.
*/
void execute() throws ExecutionException, InterruptedException;

}
Loading

0 comments on commit c3e8c60

Please sign in to comment.