Skip to content

Commit 648b541

Browse files
author
Myron Scott
committed
Fix tests that were not running or broken in move to forge
1 parent 8189ec8 commit 648b541

File tree

9 files changed

+241
-3
lines changed

9 files changed

+241
-3
lines changed

build-parent/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
<surefire.min-memory>64m</surefire.min-memory>
6868
<surefire.max-memory>512m</surefire.max-memory>
6969
<surefire.additional-jvm-args/>
70-
<should_skip_tests>true</should_skip_tests>
7170
<surefire.jvm.mode>-server</surefire.jvm.mode>
7271
<surefire.argLine>${surefire.jvm.mode}
7372
-Xms${surefire.min-memory}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@echo off
2+
3+
REM
4+
REM The contents of this file are subject to the Terracotta Public License Version
5+
REM 2.0 (the "License"); You may not use this file except in compliance with the
6+
REM License. You may obtain a copy of the License at
7+
REM
8+
REM http://terracotta.org/legal/terracotta-public-license.
9+
REM
10+
REM Software distributed under the License is distributed on an "AS IS" basis,
11+
REM WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
12+
REM the specific language governing rights and limitations under the License.
13+
REM
14+
REM The Covered Software is Terracotta Platform.
15+
REM
16+
REM The Initial Developer of the Covered Software is
17+
REM Terracotta, Inc., a Software AG company
18+
REM
19+
20+
setlocal enabledelayedexpansion enableextensions
21+
22+
pushd "%~dp0.."
23+
set "TC_SERVER_DIR=%CD%"
24+
popd
25+
26+
if exist "!TC_SERVER_DIR!\bin\setenv.bat" (
27+
pushd "!TC_SERVER_DIR!\bin" && (
28+
call .\setenv.bat
29+
popd
30+
)
31+
)
32+
33+
if not defined JAVA_HOME (
34+
echo Environment variable JAVA_HOME needs to be set
35+
exit /b 1
36+
)
37+
38+
for %%C in ("-d64 -server -XX:MaxDirectMemorySize=1048576g" ^
39+
"-server -XX:MaxDirectMemorySize=1048576g" ^
40+
"-d64 -client -XX:MaxDirectMemorySize=1048576g" ^
41+
"-client -XX:MaxDirectMemorySize=1048576g" ^
42+
"-XX:MaxDirectMemorySize=1048576g") ^
43+
do (
44+
set JAVA_COMMAND="%JAVA_HOME%\bin\java" %%~C
45+
!JAVA_COMMAND! -version > NUL 2>&1
46+
47+
if not errorlevel 1 (
48+
goto setJavaOptsAndClasspath
49+
) else (
50+
echo [!JAVA_COMMAND!] failed - trying further options
51+
)
52+
)
53+
echo No executable Java environment found in [%JAVA_HOME%]
54+
exit /b 1
55+
56+
:setJavaOptsAndClasspath
57+
58+
set "CLASSPATH=%TC_SERVER_DIR%\lib\tc.jar;%TC_SERVER_DIR%\lib\;."
59+
set OPTS=%SERVER_OPT% -Xms256m -Xmx2g -XX:+HeapDumpOnOutOfMemoryError
60+
set OPTS=%OPTS% "-Dtc.install-root=%TC_SERVER_DIR%"
61+
set JAVA_OPTS=%OPTS% %JAVA_OPTS%
62+
63+
64+
:START_TCSERVER
65+
%JAVA_COMMAND% %JAVA_OPTS% -cp "%CLASSPATH%" com.tc.server.TCServerMain %*
66+
if %ERRORLEVEL% EQU 11 (
67+
echo start-tc-server: Restarting the server...
68+
goto START_TCSERVER
69+
)
70+
exit /b %ERRORLEVEL%
71+
endlocal
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
#
4+
# The contents of this file are subject to the Terracotta Public License Version
5+
# 2.0 (the "License"); You may not use this file except in compliance with the
6+
# License. You may obtain a copy of the License at
7+
#
8+
# http://terracotta.org/legal/terracotta-public-license.
9+
#
10+
# Software distributed under the License is distributed on an "AS IS" basis,
11+
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
12+
# the specific language governing rights and limitations under the License.
13+
#
14+
# The Covered Software is Terracotta Platform.
15+
#
16+
# The Initial Developer of the Covered Software is
17+
# Terracotta, Inc., a Software AG company
18+
#
19+
20+
TC_SERVER_DIR=$(dirname "$(cd "$(dirname "$0")";pwd)")
21+
22+
# this will only happen if using sag installer
23+
if [ -r "${TC_SERVER_DIR}/bin/setenv.sh" ] ; then
24+
. "${TC_SERVER_DIR}/bin/setenv.sh"
25+
fi
26+
27+
if ! [ -d "${JAVA_HOME}" ]; then
28+
echo "$0: the JAVA_HOME environment variable is not defined correctly"
29+
exit 2
30+
fi
31+
32+
# Determine supported JVM args
33+
for JAVA_COMMAND_ARGS in \
34+
"-d64 -server -XX:MaxDirectMemorySize=1048576g" \
35+
"-server -XX:MaxDirectMemorySize=1048576g" \
36+
"-d64 -client -XX:MaxDirectMemorySize=1048576g" \
37+
"-client -XX:MaxDirectMemorySize=1048576g" \
38+
"-XX:MaxDirectMemorySize=1048576g"
39+
do
40+
# accept the first one that works
41+
"${JAVA_HOME}/bin/java" $JAVA_COMMAND_ARGS -version > /dev/null 2>&1 && break
42+
done
43+
44+
#rmi.dgc.server.gcInterval is set an year to avoid system gc in case authentication is enabled
45+
#users may change it accordingly
46+
while [ 1 ] ; do
47+
# the solaris 64-bit JVM has a bug that makes it fail to allocate more than 2GB of offheap when
48+
# the max heap is <= 2G, hence we set the heap size to a bit more than 2GB
49+
"${JAVA_HOME}/bin/java" $JAVA_COMMAND_ARGS -Xms256m -Xmx2049m \
50+
-XX:+HeapDumpOnOutOfMemoryError \
51+
-Dtc.install-root="${TC_SERVER_DIR}" \
52+
${JAVA_OPTS} \
53+
-cp "${TC_SERVER_DIR}/lib/tc.jar:${TC_SERVER_DIR}/lib/:." \
54+
com.tc.server.TCServerMain "$@"
55+
exitValue=$?
56+
57+
if [ $exitValue -eq 11 ] ; then
58+
echo "$0: Restarting the server..."
59+
sleep 1
60+
else
61+
exit $exitValue
62+
fi
63+
done

terracotta-kit/src/test/resources/setenv.bat

100644100755
File mode changed.

terracotta-kit/src/test/resources/setenv.sh

100644100755
File mode changed.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@echo off
2+
3+
REM
4+
REM The contents of this file are subject to the Terracotta Public License Version
5+
REM 2.0 (the "License"); You may not use this file except in compliance with the
6+
REM License. You may obtain a copy of the License at
7+
REM
8+
REM http://terracotta.org/legal/terracotta-public-license.
9+
REM
10+
REM Software distributed under the License is distributed on an "AS IS" basis,
11+
REM WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
12+
REM the specific language governing rights and limitations under the License.
13+
REM
14+
REM The Covered Software is Terracotta Platform.
15+
REM
16+
REM The Initial Developer of the Covered Software is
17+
REM Terracotta, Inc., a Software AG company
18+
REM
19+
20+
setlocal EnableExtensions EnableDelayedExpansion
21+
set TC_VOTER_MAIN=org.terracotta.voter.TCVoterMain
22+
23+
pushd "%~dp0.."
24+
set "TC_VOTER_DIR=%CD%"
25+
popd
26+
27+
if exist "!TC_VOTER_DIR!\bin\setenv.bat" (
28+
pushd "!TC_VOTER_DIR!\bin" && (
29+
call .\setenv.bat
30+
popd
31+
)
32+
)
33+
34+
if not defined JAVA_HOME (
35+
echo Environment variable JAVA_HOME needs to be set
36+
exit /b 1
37+
)
38+
39+
pushd "%TC_VOTER_DIR%\.."
40+
set "TC_KIT_ROOT=%CD%"
41+
popd
42+
set "TC_LOGGING_ROOT=%TC_KIT_ROOT%\client\logging"
43+
set "TC_CLIENT_ROOT=%TC_KIT_ROOT%\client\lib"
44+
45+
set "CLASSPATH=%TC_VOTER_DIR%\lib\*;%TC_CLIENT_ROOT%\*;%TC_LOGGING_ROOT%\*;%TC_LOGGING_ROOT%\impl\*;%TC_LOGGING_ROOT%\impl"
46+
set "JAVA=%JAVA_HOME%\bin\java.exe"
47+
48+
"%JAVA%" %JAVA_OPTS% -cp "%CLASSPATH%" %TC_VOTER_MAIN% %*
49+
50+
exit /b %ERRORLEVEL%
51+
52+
endlocal
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
#
3+
# The contents of this file are subject to the Terracotta Public License Version
4+
# 2.0 (the "License"); You may not use this file except in compliance with the
5+
# License. You may obtain a copy of the License at
6+
#
7+
# http://terracotta.org/legal/terracotta-public-license.
8+
#
9+
# Software distributed under the License is distributed on an "AS IS" basis,
10+
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
11+
# the specific language governing rights and limitations under the License.
12+
#
13+
# The Covered Software is Terracotta Platform.
14+
#
15+
# The Initial Developer of the Covered Software is
16+
# Terracotta, Inc., a Software AG company
17+
#
18+
19+
20+
TC_VOTER_DIR="$(dirname "$(cd "$(dirname "$0")";pwd)")"
21+
TC_VOTER_MAIN=org.terracotta.voter.TCVoterMain
22+
23+
# this will only happen if using sag installer
24+
if [ -r "${TC_VOTER_DIR}/bin/setenv.sh" ] ; then
25+
. "${TC_VOTER_DIR}/bin/setenv.sh"
26+
fi
27+
28+
if ! [ -d "${JAVA_HOME}" ]; then
29+
echo "$0: the JAVA_HOME environment variable is not defined correctly"
30+
exit 2
31+
fi
32+
33+
TC_KIT_ROOT="$(dirname "$TC_VOTER_DIR")"
34+
TC_LOGGING_ROOT="$TC_KIT_ROOT/client/logging"
35+
TC_CLIENT_ROOT="$TC_KIT_ROOT/client/lib"
36+
37+
CLASS_PATH="${TC_VOTER_DIR}/lib/*:${TC_CLIENT_ROOT}/*:${TC_LOGGING_ROOT}/*:${TC_LOGGING_ROOT}/impl/*:${TC_LOGGING_ROOT}/impl/"
38+
39+
"$JAVA_HOME/bin/java" ${JAVA_OPTS} -cp "$CLASS_PATH" $TC_VOTER_MAIN "$@"

test-common/src/main/java/com/tc/test/BaseScriptTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
import static com.tc.test.ScriptTestUtil.extractEnvironment;
6666
import static com.tc.test.ScriptTestUtil.extractProperties;
6767
import static java.lang.System.arraycopy;
68+
import java.nio.file.CopyOption;
69+
import java.nio.file.StandardCopyOption;
70+
import java.nio.file.attribute.PosixFilePermission;
6871

6972
/**
7073
* Test harness for testing Java launch scripts.
@@ -372,8 +375,15 @@ protected final Path installScript(String scriptResource, Path binPath) throws I
372375
} catch (Exception e) {
373376
throw new AssertionError("Unexpected error converting \"" + scriptFile + "\" to a Path; uri=" + uri, e);
374377
}
375-
376-
return Files.copy(scriptPath, binPath.resolve(scriptPath.getFileName()));
378+
Set<PosixFilePermission> perms = EnumSet.of(PosixFilePermission.GROUP_EXECUTE,
379+
PosixFilePermission.GROUP_READ,
380+
PosixFilePermission.OWNER_EXECUTE,
381+
PosixFilePermission.OWNER_READ,
382+
PosixFilePermission.OWNER_WRITE
383+
);
384+
Path f = Files.copy(scriptPath, binPath.resolve(scriptPath.getFileName()), StandardCopyOption.COPY_ATTRIBUTES);
385+
Files.setPosixFilePermissions(f, perms);
386+
return f;
377387
}
378388

379389
/**

voter/src/test/java/org/terracotta/voter/ActiveVoterTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void testTopologyUpdate() throws TimeoutException, InterruptedException {
5050
} else {
5151
ClientVoterManager mockClientVoterManager = mock(ClientVoterManager.class);
5252
when(mockClientVoterManager.getTargetHostPort()).thenReturn(hostPort);
53+
when(mockClientVoterManager.isConnected()).thenReturn(true);
5354
return mockClientVoterManager;
5455
}
5556
};
@@ -95,6 +96,7 @@ public void testOverLappingHostPortsWhileAddingServers() throws TimeoutException
9596
} else {
9697
ClientVoterManager mockClientVoterManager = mock(ClientVoterManager.class);
9798
when(mockClientVoterManager.getTargetHostPort()).thenReturn(hostPort);
99+
when(mockClientVoterManager.isConnected()).thenReturn(true);
98100
return mockClientVoterManager;
99101
}
100102
};
@@ -143,6 +145,7 @@ public void testOverLappingHostPortsWhileRemovingServers() throws TimeoutExcepti
143145
} else {
144146
ClientVoterManager mockClientVoterManager = mock(ClientVoterManager.class);
145147
when(mockClientVoterManager.getTargetHostPort()).thenReturn(hostPort);
148+
when(mockClientVoterManager.isConnected()).thenReturn(true);
146149
return mockClientVoterManager;
147150
}
148151
};
@@ -192,6 +195,7 @@ public void testWhenStaticPassivePortsRemoved() throws TimeoutException, Interru
192195
} else {
193196
ClientVoterManager mockClientVoterManager = mock(ClientVoterManager.class);
194197
when(mockClientVoterManager.getTargetHostPort()).thenReturn(hostPort);
198+
when(mockClientVoterManager.isConnected()).thenReturn(true);
195199
return mockClientVoterManager;
196200
}
197201
};

0 commit comments

Comments
 (0)