Skip to content

Commit

Permalink
CXF-9013: Move performance benchmark to distribution samples folder (#…
Browse files Browse the repository at this point in the history
…1867)

* [CXF-9013] Add JAX-RS performance suite to benchmarks

* [CXF-9013] Remove debugging print statements, add validation

* [CXF-9013] Update README file

* [CXF-9013] Move performance benchmark to distribution samples folder

* [CXF-9013] add back in bin folders
  • Loading branch information
jgoodyear committed May 15, 2024
1 parent d5cbaed commit f383915
Show file tree
Hide file tree
Showing 65 changed files with 879 additions and 35 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf.benchmark</groupId>

<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>cxf-benchmark-base</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Apache CXF Benchmark Base</name>
<description>Apache CXF Benchmark Base</description>
<url>https://cxf.apache.org</url>
<properties>
<cxf.version>4.1.0-SNAPSHOT</cxf.version>
</properties>

<build>
<defaultGoal>install</defaultGoal>
<pluginManagement>
Expand All @@ -48,7 +52,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>${cxf.version}</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.util.*;

import org.apache.cxf.jaxrs.client.WebClient;

import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;

Expand Down Expand Up @@ -134,6 +136,15 @@ public void processArgs() {
}
}

private boolean validateRS() {
if (operationName == null || operationName.trim().isEmpty()) {
System.out.println("Operation is not specified");
faultReason = "Missing REST verb";
return false;
}
return true;
}

private boolean validate() {
if (wsdlNameSpace == null || wsdlNameSpace.trim().isEmpty()) {
System.out.println("WSDL name space is not specified");
Expand Down Expand Up @@ -176,9 +187,16 @@ protected void setUp() throws Exception {
printTitle();
printSetting("Default Setting: ");
processArgs();
if (!validate()) {
System.out.println("Configure Exception!" + faultReason);
System.exit(1);
if (getPort() instanceof WebClient) {
if (!validateRS()) {
System.out.println("Configure Exception!" + faultReason);
System.exit(1);
}
} else {
if (!validate()) {
System.out.println("Configure Exception!" + faultReason);
System.exit(1);
}
}
init();
printSetting("Runtime Setting: ");
Expand Down Expand Up @@ -345,12 +363,15 @@ public List getTestResults() {
public abstract void printUsage();

public void printSetting(String settingType) {
System.out.println(settingType + " [Service] -- > " + serviceName);
System.out.println(settingType + " [Port] -- > " + portName);
if (!(getPort() instanceof WebClient)) {
System.out.println(settingType + " [Service] -- > " + serviceName);
System.out.println(settingType + " [Port] -- > " + portName);
}
System.out.println(settingType + " [Operation] -- > " + operationName);
System.out.println(settingType + " [Threads] -- > " + numberOfThreads);
System.out.println(settingType + " [Packet Size] -- > " + packetSize
+ " packet(s) ");
if (!(getPort() instanceof WebClient)) {
System.out.println(settingType + " [Packet Size] -- > " + packetSize + " packet(s) ");
}
if (usingTime) {
System.out.println(settingType + " [Running] --> " + amount + " (secs)");
} else {
Expand Down
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions distribution/src/main/release/samples/performance/jaxrs/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
JAX-RS Basic With HTTPS communications Performance Suite
=========================================================

This sample takes the JAX-RS basic HTTPS demo a step further
by integrating it with the performance test framework.

The JAX-RS server is configured with a HTTPS listener. The listener
requires client authentication so the client must provide suitable
credentials. The listener configuration is taken from the
"ServerConfig.xml" file located under demo directory.

The client is configured to provide its certificate
from its keystore "config/clientKeystore.jks" to the server.
The server authenticates the client's certificate using its own
keystore "config/serviceKeystore.jks", which contains the
public cert of the client. The client makes HTTPS calls using
CXF's WebClient object.

Likewise the client authenticates the server's certificate "CN=localhost"
using its keystore. Note also the usage of the cipherSuitesFilter
configuration in the configuration files, where each party imposes
different ciphersuites constraints, so that the ciphersuite eventually
negotiated during the TLS handshake is acceptable to both sides.
This may be viewed by adding a -Djavax.net.debug=all argument to the JVM.

But please note that it is not advisable to store sensitive data such
as passwords stored in a clear text configuration file, unless the
file is sufficiently protected by OS level permissions. The KeyStores
may be configured programmatically so using user interaction may be
employed to keep passwords from being stored in configuration files.
The approach taken here is for demonstration reasons only.

Please review the README in the samples directory before
continuing.


Building and running the performance test case using Maven
----------------------------------------------------------
From the base directory of this sample (i.e., where this README file is
located), the Maven pom.xml file can be used to build and run the demo.


Using either UNIX or Windows:

cd base
mvn install
cd ../jaxrs
mvn install
mvn -Pserver (from one command line window)
mvn -Pclient (from a second command line window)

Alternatively, client and server may be executed from one window.

mvn -Pclientserver [-Dthreads=N] [-Doperation=get] [-Dtime=M]

To remove the target dir, run "mvn clean".

The JAX-RS Client takes the following arguments:
-Operation The rest verb to execute (get, post, put, delete)
-Time define the amount of time to spend making invocations in seconds
-Threads define the number of threads to run the performance client


Certificates
------------
See the src/main/config folder for the sample keys used (don't use
these keys in production!) as well as scripts used for their creation.
168 changes: 168 additions & 0 deletions distribution/src/main/release/samples/performance/jaxrs/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>cxf-benchmark-jaxrs-basic-https</artifactId>
<name>JAX-RS Basic With HTTPS communications</name>
<description>Apache CXF Benchmark JAX-RS Basic HTTPS communications</description>
<url>https://cxf.apache.org</url>

<profiles>
<profile>
<id>server</id>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.apache.cxf.performance.https.server.Server</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<properties>
<operation>get</operation>
<threads>4</threads>
<time>30</time>
</properties>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${maven.exec.plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.apache.cxf.performance.https.client.Client</mainClass>
<arguments>
<argument>-Operation</argument>
<argument>${operation}</argument>
<argument>-Threads</argument>
<argument>${threads}</argument>
<argument>-Amount</argument>
<argument>${time}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>clientserver</id>
<properties>
<operation>get</operation>
<threads>4</threads>
<time>30</time>
</properties>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>org.apache.cxf.performance.https.client.Client</mainClass>
<arguments>
<argument>-Operation</argument>
<argument>${operation}</argument>
<argument>-Threads</argument>
<argument>${threads}</argument>
<argument>-Amount</argument>
<argument>${time}</argument>
<argument>-Server</argument>
<argument>-nowait</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-benchmark-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${cxf.httpcomponents.client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The below scripts show the commands used to generate the self-signed keys for this sample.
# If you use the below script to create your own keys be sure to change the passwords used here
# DO NOT USE THE SUPPLIED KEYS IN PRODUCTION--everyone has them!!
# For production recommended to use keys signed by a third-party certificate authority (CA)

# Create the combination keystore/truststore for the client and service.
# Note you can create separate keystores/truststores for both if desired
keytool -genkeypair -validity 730 -alias myservicekey -keystore serviceKeystore.jks -dname "cn=localhost" -keypass skpass -storepass sspass
keytool -genkeypair -validity 730 -alias myclientkey -keystore clientKeystore.jks -keypass ckpass -storepass cspass

# Place server public cert in client key/truststore
keytool -export -rfc -keystore serviceKeystore.jks -alias myservicekey -file MyService.cer -storepass sspass
keytool -import -noprompt -trustcacerts -file MyService.cer -alias myservicekey -keystore clientKeystore.jks -storepass cspass

# Place client public cert in service key/truststore
# Note this needs to be done only if you're requiring client authentication
# as configured in resources/ServerConfig.xml
keytool -export -rfc -keystore clientKeystore.jks -alias myclientkey -file MyClient.cer -storepass cspass
keytool -import -noprompt -trustcacerts -file MyClient.cer -alias myclientkey -keystore serviceKeystore.jks -storepass sspass
Binary file not shown.
Binary file not shown.

0 comments on commit f383915

Please sign in to comment.