Skip to content

Commit 5b4e1f1

Browse files
committed
Added unit tests that require a running server
1 parent 7d32d81 commit 5b4e1f1

22 files changed

+8425
-102
lines changed

README.md

Lines changed: 347 additions & 38 deletions
Large diffs are not rendered by default.

driver/pom.xml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<version>5.2.24-SNAPSHOT</version>
1212
<packaging>jar</packaging>
1313

14+
<organization>
15+
<name>Oracle Corporation</name>
16+
<url>http://www.oracle.com/</url>
17+
</organization>
18+
1419
<properties>
1520
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1621
<maven.compiler.source>1.8</maven.compiler.source>
@@ -32,14 +37,43 @@
3237

3338
<profiles>
3439

35-
<!-- test profiles used with the test target -->
40+
<!-- test profiles used with the test target
41+
Running tests requires a running on-premise service and httpproxy
42+
or a running cloud simulator. Required information:
43+
o endpoint
44+
Examples:
45+
mvn -Ptest-cloudsim test -DargLine="test.endpoint=http://localhost:8080"
46+
mvn -Ptest-onprem test -DargLine="test.endpoint=http://localhost:8090"
47+
48+
These tests are not designed to work directly against the cloud service
49+
as they require a high rate of DDL operations and generally use more
50+
resource than a user might want to use in the cloud.
51+
52+
A secure, onprem configuration requires more information:
53+
1. user name and password
54+
2. trust store and optional password for the SSL certificate to use to
55+
communicate with the proxy
56+
These are also passed as system properties, e.g.:
57+
mvn -Ptest-onprem-secure test -DargLine="-Dtest.endpoint=<secure-endpoint> -Dtest.user=<username> -Dtest.password=<user-password> -Dtest.trust=<path-to-trust-store> -Dtest.trust.password=<trust-store-password>"
58+
59+
Individual test methods can be traced by adding "-Dtest.trace=true" to
60+
the argLine string
61+
-->
3662
<profile>
3763
<id>test-cloudsim</id>
3864
<properties>
3965
<maven.test.skip>false</maven.test.skip>
4066
<secure>false</secure>
4167
<onprem>false</onprem>
4268
<serverType>cloudsim</serverType>
69+
<!-- exclude non-server tests and on-premise tests -->
70+
<excluded.tests>
71+
StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
72+
ConfigFileTest.java, SignatureProviderTest.java,
73+
UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
74+
HandleConfigTest.java, JsonTest.java, ValueTest.java,
75+
OnPremiseTest.java
76+
</excluded.tests>
4377
</properties>
4478
</profile>
4579

@@ -50,6 +84,13 @@
5084
<secure>false</secure>
5185
<onprem>true</onprem>
5286
<serverType>onprem</serverType>
87+
<!-- exclude non-server tests -->
88+
<excluded.tests>
89+
StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
90+
ConfigFileTest.java, SignatureProviderTest.java,
91+
UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
92+
HandleConfigTest.java, JsonTest.java, ValueTest.java
93+
</excluded.tests>
5394
</properties>
5495
</profile>
5596

@@ -60,6 +101,13 @@
60101
<secure>true</secure>
61102
<onprem>true</onprem>
62103
<serverType>onprem</serverType>
104+
<!-- exclude non-server tests -->
105+
<excluded.tests>
106+
StoreAccessTokenProviderTest.java, ResourcePrincipalProviderTest.java,
107+
ConfigFileTest.java, SignatureProviderTest.java,
108+
UserProfileProviderTest.java, InstancePrincipalsProviderTest.java,
109+
HandleConfigTest.java, JsonTest.java, ValueTest.java
110+
</excluded.tests>
63111
</properties>
64112
</profile>
65113

@@ -188,6 +236,9 @@
188236
<includes>
189237
<include>${included.tests}</include>
190238
</includes>
239+
<excludes>
240+
<exclude>${excluded.tests}</exclude>
241+
</excludes>
191242
</configuration>
192243
</plugin>
193244
<plugin>

driver/src/main/java/oracle/nosql/driver/httpclient/HttpClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import io.netty.channel.ChannelFutureListener;
2929
import io.netty.channel.ChannelOption;
3030
import io.netty.channel.nio.NioEventLoopGroup;
31-
import io.netty.channel.pool.ChannelPool;
3231
import io.netty.channel.pool.FixedChannelPool;
3332
import io.netty.channel.socket.nio.NioSocketChannel;
3433
import io.netty.handler.codec.http.HttpRequest;
@@ -204,6 +203,11 @@ public HttpClient(String host,
204203
poolHandler =
205204
new HttpClientChannelPoolHandler(this);
206205

206+
/*
207+
* TODO: FixedChannelPool has a method to return the number of
208+
* channels it has -- acquiredChannelCount(). Look at exposing
209+
* this somehow.
210+
*/
207211
pool = new FixedChannelPool(b,
208212
poolHandler, /* pool handler */
209213
poolHandler, /* health checker */
@@ -214,10 +218,6 @@ public HttpClient(String host,
214218
true); /* do health check on release */
215219
}
216220

217-
ChannelPool getPool() {
218-
return pool;
219-
}
220-
221221
SslContext getSslContext() {
222222
return sslCtx;
223223
}
@@ -285,7 +285,6 @@ public int getProxyPort() {
285285
*/
286286
public void shutdown() {
287287
pool.close();
288-
poolHandler.close();
289288
workerGroup.shutdownGracefully().syncUninterruptibly();
290289
}
291290

driver/src/main/java/oracle/nosql/driver/httpclient/HttpClientChannelPoolHandler.java

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import static oracle.nosql.driver.util.LogUtil.logFine;
1111
import static oracle.nosql.driver.util.LogUtil.logInfo;
1212
import java.net.InetSocketAddress;
13-
import java.util.concurrent.atomic.AtomicInteger;
14-
1513
import javax.net.ssl.SSLEngine;
1614
import javax.net.ssl.SSLParameters;
1715

@@ -42,13 +40,6 @@ public class HttpClientChannelPoolHandler implements ChannelPoolHandler,
4240

4341
private final HttpClient client;
4442

45-
/*
46-
* Debugging -- use these to ensure proper acquire/release calls.
47-
* TODO: keep these or not?
48-
*/
49-
private final AtomicInteger count = new AtomicInteger(0);
50-
private final AtomicInteger createCount = new AtomicInteger(0);
51-
5243
/**
5344
* Creates an instance of this object
5445
*
@@ -59,12 +50,6 @@ public class HttpClientChannelPoolHandler implements ChannelPoolHandler,
5950
this.client = client;
6051
}
6152

62-
@Override
63-
public void channelAcquired(Channel ch) {
64-
//logFine(client.getLogger(), "Channel acquired: " + ch);
65-
count.incrementAndGet();
66-
}
67-
6853
/**
6954
* Initialize a channel with handlers that:
7055
* 1 -- handle and HTTP
@@ -105,53 +90,14 @@ public void channelCreated(Channel ch) {
10590
client.getProxyUsername(),
10691
client.getProxyPassword()));
10792
}
108-
count.incrementAndGet();
109-
createCount.incrementAndGet();
11093
}
11194

11295
@Override
113-
public void channelReleased(Channel ch) {
114-
/*
115-
* no need to log this -- it happens on every release. What would be
116-
* nice is to log when a channel is destroyed, but that doesn't seem
117-
* possible
118-
*/
119-
//logFine(client.getLogger(), "Channel release: " + ch);
120-
count.decrementAndGet();
121-
}
122-
123-
/*
124-
* Maybe remove the count-based debugging
125-
*/
126-
void close() {
127-
int chCount = count.get();
128-
logInfo(client.getLogger(),
129-
"HttpClient " + client.getName() +
130-
", close pool handler, create count, ref count: "
131-
+ createCount.get() + ", " + chCount);
132-
if (chCount > 0) {
133-
logInfo(client.getLogger(),
134-
"HttpClient " + client.getName() +
135-
", possible channel leak, count is non-zero: " + chCount);
136-
}
137-
}
138-
139-
/**
140-
* Returns the number of channels that are in active use. Note that this is
141-
* less than or equal to the number of channels currently in the pool.
142-
*/
143-
int getCount() {
144-
return count.get();
96+
public void channelAcquired(Channel ch) {
14597
}
14698

147-
/**
148-
* Returns the total number of channels that were created over the lifetime
149-
* of the pool. This could be greater than the max number of connections
150-
* configured for the pool if unhealthy connections are replaced with new
151-
* healthy ones.
152-
*/
153-
int getCreateCount() {
154-
return createCount.get();
99+
@Override
100+
public void channelReleased(Channel ch) {
155101
}
156102

157103
/**

0 commit comments

Comments
 (0)