Skip to content

Commit 9b5626c

Browse files
author
Xinzhi Zou
committed
Refactored testing code and Added Auto-discovery related tests;
Updated license file and README
1 parent 643a6d4 commit 9b5626c

File tree

78 files changed

+2343
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2343
-519
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2012-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
Copyright (C) 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22

33
Licensed under the Amazon Software License (the "License"). You may not use this
44
file except in compliance with the License. A copy of the License is located at

README.markdown

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,39 @@ command:
1212
This will generate binary, source, and javadoc jars in the build
1313
directory of the project.
1414

15-
More test info will be updated shortly.
16-
1715
# Testing
1816

19-
_Note: The ant test target is in the process of being updated to run the additional tests written for Auto Discovery._
17+
The latest version of Amazon ElastiCache Cluster Client supports unit tests and integration tests.
18+
19+
Unit tests do not require any running memcached servers, and can be run using Apache Ant by the following command:
20+
21+
ant test
22+
23+
Integration tests are always run against local memcached servers. Start integration tests by the
24+
following command:
25+
26+
ant it
27+
28+
It has a set of command line arguments that can be used to configure your client mode and your local testing server. The arguments are listed below.
29+
30+
-Dclient.mode=memcached_client_mode
2031

21-
The latest version of Amazon ElastiCache Cluster Client has a set of command line arguments
22-
that can be used to configure the location of your testing server. The
23-
arguments are listed below.
32+
This argument is used to specify the mode of the client that you want to run. Supported options are _Static_ and _Dynamic_.
33+
_Dynamic_ mode enables Auto Discovery feature. _Static_ mode runs without Auto Discovery and has the same functionality as a classic spymemcached client. By default it is set to _Dynamic_.
2434

25-
-Dserver.address_v4=ipv4_address_of_testing_server
35+
-Dserver.bin=local_binary_of_testing_server
2636

27-
This argument is used to specify the ipv4 address of your testing
28-
server. By default it is set to localhost.
37+
This argument is used to specify the location of your testing
38+
server binary. By default it is set to _/usr/bin/memcached_.
2939

30-
-Dserver.port_number=port_number_of_memcached
40+
-Dserver.version=version_of_testing_server
3141

32-
This argument is used when memcahched is started on a port other than
33-
11211
42+
This argument is used to specify the version of your testing server. Currently supported memcached versions by Elasticache are _1.4.5_, _1.4.14_, _1.4.24_.
43+
By default it is set to _1.4.24_.
3444

3545
-Dtest.type=ci
3646

37-
This argument is used for CI testing where certain unit tests might
38-
be temporarily failing.
47+
This argument is used for CI testing where certain tests might be temporarily failing.
3948

4049
# More Information for Amazon ElastiCache Cluster Client
4150
Github link: https://github.com/amazonwebservices/aws-elasticache-cluster-client-memcached-for-java

build.xml

Lines changed: 156 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
SOFTWARE.
2121
22-
Portions Copyright (C) 2012-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22+
Portions Copyright (C) 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2323
2424
Licensed under the Amazon Software License (the "License"). You may not use this
2525
file except in compliance with the License. A copy of the License is located at
@@ -42,7 +42,7 @@
4242
</taskdef>
4343

4444
<property name="name" value="AmazonElastiCacheClusterClient"/>
45-
<property name="copyright" value="2006-2011 Dustin Sallings, Matt Ingenthron, 2012-2012 Amazon.com, Inc. or its affiliates" />
45+
<property name="copyright" value="2006-2011 Dustin Sallings, Matt Ingenthron, 2012-2015 Amazon.com, Inc. or its affiliates" />
4646
<property name="group" value="spy" />
4747

4848
<property name="base.src.dir" value="${basedir}/src" />
@@ -52,9 +52,11 @@
5252
<property name="lib.dir" value="${basedir}/lib" />
5353
<property name="src.dir" value="${base.src.dir}/main/java" />
5454
<property name="test.dir" value="${base.src.dir}/test/java" />
55+
<property name="it.dir" value="${base.src.dir}/it/java" />
5556
<property name="script.src.dir" value="${base.src.dir}/scripts" />
5657
<property name="build.javadoc" location="${build.dir}/docs/" />
5758
<property name="build.javadoc.test" location="${build.dir}/testdocs/" />
59+
<property name="build.javadoc.it" location="${build.dir}/itdocs/" />
5860
<property name="junit.dir" location="${build.dir}/junit" />
5961

6062
<property name="dist.dir" value="${basedir}/target" />
@@ -83,6 +85,11 @@
8385
<property name="test.log.dir" location="${build.dir}/test/logs"/>
8486
<property name="build.test.classes" location="${build.test}/classes" />
8587

88+
<!-- integration tests -->
89+
<property name="build.it" location="${build.dir}/it"/>
90+
<property name="it.log.dir" location="${build.dir}/it/logs"/>
91+
<property name="build.it.classes" location="${build.it}/classes" />
92+
8693
<!-- maven -->
8794
<property name="mvn.build.dir" value="${build.dir}" />
8895

@@ -124,6 +131,15 @@
124131
<property name="server.port_number" value="11211"/>
125132
<property name="test.type" value="unit"/>
126133

134+
<!--integration test related properties -->
135+
<property name="client.mode" value="Dynamic"/>
136+
<property name="server.address_v4" value="127.0.0.1"/>
137+
<property name="server.address_v6" value="::1"/>
138+
<property name="server.bin" value="/usr/bin/memcached"/>
139+
<property name="server.port_number" value="11211"/>
140+
<property name="server.version" value="1.4.24"/>
141+
<property name="test.type" value="unit"/>
142+
127143
<!--this is the naming policy for artifacts we want pulled down-->
128144
<property name="ivy.artifact.retrieve.pattern"
129145
value="${name}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
@@ -169,6 +185,12 @@
169185
<pathelement location="${build.test.classes}" />
170186
<path refid="compile.classpath" />
171187
</path>
188+
189+
<!-- Classpath for integration tests (superset of compile.classpath) -->
190+
<path id="it.classpath">
191+
<pathelement location="${build.it.classes}" />
192+
<path refid="compile.classpath" />
193+
</path>
172194
</target>
173195

174196
<target name="ivy-probe-antlib" >
@@ -251,10 +273,6 @@
251273

252274
<target name="test" depends="compile, compile-test"
253275
description="Run Spymemcached unit tests">
254-
<echo>IPV4 address ${server.address_v4}</echo>
255-
<echo>IPV6 address ${server.address_v6}</echo>
256-
<echo>Port Number ${server.port_number}</echo>
257-
<echo>Test Type(unit|ci) ${test.type}</echo>
258276
<delete dir="${junit.dir}"/>
259277
<mkdir dir="${junit.dir}/data"/>
260278
<junit fork="yes" timeout="60000" failureproperty="junit.failure">
@@ -265,10 +283,6 @@
265283
<formatter type="xml"/>
266284
</batchtest>
267285
<jvmarg value="-ea" />
268-
<sysproperty key="server.address_v4" value="${server.address_v4}"/>
269-
<sysproperty key="server.address_v6" value="${server.address_v6}"/>
270-
<sysproperty key="server.port_number" value="${server.port_number}"/>
271-
<sysproperty key="test.type" value="${test.type}"/>
272286
<formatter type="plain" usefile="false" />
273287
<classpath refid="test.classpath" />
274288
</junit>
@@ -281,6 +295,38 @@
281295
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
282296
</target>
283297

298+
<target name="it" depends="compile, compile-it"
299+
description="Run Spymemcached integration tests">
300+
<echo>Client mode(Dynamic|Static) ${client.mode}</echo>
301+
<echo>Server binary ${server.bin}</echo>
302+
<echo>Server version ${server.version}</echo>
303+
<echo>Test Type(unit|ci) ${test.type}</echo>
304+
<delete dir="${junit.dir}"/>
305+
<mkdir dir="${junit.dir}/data"/>
306+
<junit fork="yes" timeout="3600000" failureproperty="junit.failure">
307+
<batchtest todir="${junit.dir}/data" fork="yes">
308+
<fileset dir="${it.dir}">
309+
<include name="**/${client.mode}ModeTestSuite.java"/>
310+
</fileset>
311+
<formatter type="xml"/>
312+
</batchtest>
313+
<jvmarg value="-ea" />
314+
<sysproperty key="client.mode" value="${client.mode}"/>
315+
<sysproperty key="server.bin" value="${server.bin}"/>
316+
<sysproperty key="server.version" value="${server.version}"/>
317+
<sysproperty key="test.type" value="${test.type}"/>
318+
<formatter type="plain" usefile="false" />
319+
<classpath refid="it.classpath" />
320+
</junit>
321+
<mkdir dir="${junit.dir}/tmp"/>
322+
<junitreport todir="${junit.dir}/tmp">
323+
<fileset dir="${junit.dir}/data"/>
324+
<report todir="${junit.dir}"/>
325+
</junitreport>
326+
<delete dir="${junit.dir}/tmp"/>
327+
<fail if="junit.failure" message="Integration test(s) failed. See reports!"/>
328+
</target>
329+
284330
<target name="junitreport">
285331
<mkdir dir="${junit.out.dir.html}"/>
286332
<junitreport todir="${junit.out.dir.html}">
@@ -309,6 +355,24 @@
309355
</javac>
310356
</target>
311357

358+
<target name="compile-it" depends="compile"
359+
description="Compile integration test classes">
360+
<mkdir dir="${build.it.classes}" />
361+
<javac
362+
encoding="${build.encoding}"
363+
srcdir="${it.dir}"
364+
includes="**/*.java"
365+
destdir="${build.it.classes}"
366+
debug="${javac.debug}"
367+
includeantruntime="false"
368+
target="1.6"
369+
source="1.6">
370+
<classpath>
371+
<path refid="it.classpath"/>
372+
</classpath>
373+
</javac>
374+
</target>
375+
312376
<!-- =======================================
313377
Section: Documentation Generation
314378
======================================= -->
@@ -323,6 +387,10 @@
323387
<include name="**/*.java" />
324388
<include name="**/*.html" />
325389
</srcfiles>
390+
<srcfiles dir="${it.dir}">
391+
<include name="**/*.java" />
392+
<include name="**/*.html" />
393+
</srcfiles>
326394
<mapper type="merge" to="${build.javadoc}/index.html" />
327395
</uptodate>
328396
</target>
@@ -331,6 +399,7 @@
331399
depends="init,javadoc-uptodate,compile" >
332400
<mkdir dir="${build.javadoc}" />
333401
<mkdir dir="${build.javadoc.test}" />
402+
<mkdir dir="${build.javadoc.it}" />
334403
<exec executable="date" outputproperty="year">
335404
<arg value="+%Y" />
336405
</exec>
@@ -366,6 +435,21 @@
366435
</packageset>
367436
<classpath refid="test.classpath" />
368437
</javadoc>
438+
<javadoc
439+
packagenames="src"
440+
sourcepath="${it.dir}"
441+
destdir="${build.javadoc.it}"
442+
author="true"
443+
version="true"
444+
use="true"
445+
windowtitle="${name}-it ${version} API"
446+
doctitle="${name}-it ${version} API"
447+
bottom="Copyright &amp;copy; 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.">
448+
<packageset dir="${it.dir}">
449+
<include name="**" />
450+
</packageset>
451+
<classpath refid="it.classpath" />
452+
</javadoc>
369453
</target>
370454

371455
<target name="docsjar" depends="docs"
@@ -375,6 +459,8 @@
375459
basedir="${build.javadoc}" />
376460
<zip destfile="${build.dir}/javadocs/${name}-test-${version}.jar"
377461
basedir="${build.javadoc.test}" />
462+
<zip destfile="${build.dir}/javadocs/${name}-it-${version}.jar"
463+
basedir="${build.javadoc.it}" />
378464
</target>
379465

380466
<!-- =======================================
@@ -442,9 +528,12 @@
442528
<jar jarfile="${build.dir}/sources/${name}-test-${version}.jar">
443529
<fileset dir="${test.dir}" />
444530
</jar>
531+
<jar jarfile="${build.dir}/sources/${name}-it-${version}.jar">
532+
<fileset dir="${it.dir}" />
533+
</jar>
445534
</target>
446535

447-
<target name="jar" depends="compile,compile-test" description="Creates a jar file for the library">
536+
<target name="jar" depends="compile,compile-test,compile-it" description="Creates a jar file for the library">
448537
<mkdir dir="${build.dir}/jars" />
449538
<jar jarfile="${build.dir}/jars/${name}-${version}.jar" basedir="${build.classes}">
450539
<manifest>
@@ -456,6 +545,7 @@
456545
</manifest>
457546
</jar>
458547
<jar jarfile="${build.dir}/jars/${name}-test-${version}.jar" basedir="${build.test.classes}"/>
548+
<jar jarfile="${build.dir}/jars/${name}-it-${version}.jar" basedir="${build.it.classes}"/>
459549
</target>
460550

461551
<target name="package" depends="jar,srcjar,docsjar"
@@ -497,6 +587,7 @@
497587
<!-- prepare for mvn tasks. -->
498588
<property name="spymemcached.pom" value="${mvn.build.dir}/poms/spymemcached-${version}.pom" />
499589
<property name="spymemcached-test.pom" value="${mvn.build.dir}/poms/spymemcached-test-${version}.pom" />
590+
<property name="spymemcached-it.pom" value="${mvn.build.dir}/poms/spymemcached-it-${version}.pom" />
500591

501592
<!-- Register mvn tasks -->
502593
<path id="mvn-ant-task.classpath" path="${mvn.jar}" />
@@ -530,6 +621,18 @@
530621
<dependency group="com.codahale.metrics" artifact="metrics-core" version="${codahale.metrics.version}" />
531622
</ivy:makepom>
532623

624+
<ivy:makepom ivyfile="ivy/spymemcached-it.xml"
625+
pomfile="${spymemcached-it.pom}"
626+
templatefile="ivy/pom.template.xml"
627+
settingsRef="${name}.ivy.settings">
628+
<mapping conf="default" scope="compile" />
629+
<mapping conf="runtime" scope="runtime" />
630+
<dependency group="log4j" artifact="log4j" version="${log4j.version}" optional="true" />
631+
<dependency group="org.slf4j" artifact="slf4j-api" version="${slf4j.version}" optional="true" />
632+
<dependency group="org.springframework" artifact="spring-beans" version="${spring-beans.version}" optional="true" />
633+
<dependency group="com.codahale.metrics" artifact="metrics-core" version="${codahale.metrics.version}" />
634+
</ivy:makepom>
635+
533636
<!-- Change the version in the pom file to reflect our claimed version. -->
534637
<replaceregexp>
535638
<regexp pattern="&lt;version&gt;.*&lt;/version&gt;" />
@@ -559,6 +662,14 @@
559662
<attach file="${build.dir}/javadocs/${name}-test-${version}.jar"
560663
classifier="javadoc" />
561664
</artifact:install>
665+
<artifact:pom id="spymemcached-it" file="${spymemcached-it.pom}" />
666+
<artifact:install file="${build.dir}/jars/${name}-it-${version}.jar">
667+
<pom refid="${name}-it" />
668+
<attach file="${build.dir}/sources/${name}-it-${version}.jar"
669+
classifier="sources" />
670+
<attach file="${build.dir}/javadocs/${name}-it-${version}.jar"
671+
classifier="javadoc" />
672+
</artifact:install>
562673
</target>
563674

564675
<target name="mvn-deploy" depends="mvn-install" description="deploy snapshot version to maven snapshot repository">
@@ -634,6 +745,38 @@
634745
<arg value="-Dfile=${build.dir}/javadocs/${name}-test-${version}.jar" />
635746
<arg value="-Dclassifier=javadoc" />
636747
<arg value="-Pgpg" />
748+
</artifact:mvn>
749+
750+
<!-- sign and deploy the main artifact -->
751+
<artifact:mvn>
752+
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
753+
<arg value="-Durl=${maven-staging-repository-url}" />
754+
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
755+
<arg value="-DpomFile=${spymemcached-it.pom}" />
756+
<arg value="-Dfile=${build.dir}/jars/${name}-it-${version}.jar" />
757+
<arg value="-Pgpg" />
758+
</artifact:mvn>
759+
760+
<!-- sign and deploy the sources artifact -->
761+
<artifact:mvn>
762+
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
763+
<arg value="-Durl=${maven-staging-repository-url}" />
764+
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
765+
<arg value="-DpomFile=${spymemcached-it.pom}" />
766+
<arg value="-Dfile=${build.dir}/sources/${name}-it-${version}.jar" />
767+
<arg value="-Dclassifier=sources" />
768+
<arg value="-Pgpg" />
769+
</artifact:mvn>
770+
771+
<!-- sign and deploy the javadoc artifact -->
772+
<artifact:mvn>
773+
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
774+
<arg value="-Durl=${maven-staging-repository-url}" />
775+
<arg value="-DrepositoryId=${maven-staging-repository-id}" />
776+
<arg value="-DpomFile=${spymemcached-it.pom}" />
777+
<arg value="-Dfile=${build.dir}/javadocs/${name}-it-${version}.jar" />
778+
<arg value="-Dclassifier=javadoc" />
779+
<arg value="-Pgpg" />
637780
</artifact:mvn>
638781
</target>
639782

@@ -662,6 +805,7 @@
662805
</auxClasspath>
663806
<sourcePath path="${src.dir}" />
664807
<sourcePath path="${test.dir}" />
808+
<sourcePath path="${it.dir}" />
665809
<class location="${build.dir}/${dest.jar}" />
666810
</findbugs>
667811
<xslt style="${findbugs.home}/src/xsl/default.xsl"
@@ -689,6 +833,7 @@
689833
<classpath>
690834
<source path="${src.dir}" />
691835
<source path="${test.dir}" />
836+
<source path="${it.dir}" />
692837
<output path="${build.dir}/eclipse-build" />
693838
<library pathref="${name}.common.classpath" />
694839
</classpath>

0 commit comments

Comments
 (0)