Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 791201e

Browse files
committed
fixed issue #96. added travis support
1 parent 7dd552a commit 791201e

File tree

12 files changed

+196
-6
lines changed

12 files changed

+196
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
src/test/resources/user.properties
99
setenv.bat
1010
src/test/resources/scaffold-test/
11+
.DS_Store

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: java
2+
jdk:
3+
- oraclejdk7
4+
sudo: true
5+
before_install:
6+
- echo 'America/Los_Angeles' | sudo tee /etc/timezone
7+
- sudo dpkg-reconfigure --frontend noninteractive tzdata
8+
install:
9+
- ./shared/dev-tasks/install-dependencies.sh
10+
script:
11+
- '[ "${TRAVIS_SECURE_ENV_VARS}" = "false" ] && ./gradlew test'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] ; then
4+
./shared/dev-tasks/travis-install-ml.sh release
5+
./shared/dev-tasks/setup-marklogic.sh
6+
fi

shared/dev-tasks/setup-marklogic.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
sudo /etc/init.d/MarkLogic start
4+
sleep 10
5+
curl -X POST -d "" http://localhost:8001/admin/v1/init
6+
sleep 10
7+
curl -X POST -H "Content-type: application/x-www-form-urlencoded" \
8+
--data "admin-username=admin" \
9+
--data "admin-password=admin" \
10+
--data "realm=public" \
11+
"http://localhost:8001/admin/v1/instance-admin"
12+
sleep 10

shared/dev-tasks/travis-install-ml.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# runs command from parameters and exits with the eoror code of the command
4+
# if it fails
5+
function successOrExit {
6+
"$@"
7+
local status=$?
8+
if [ $status -ne 0 ]; then
9+
echo "$1 exited with error: $status"
10+
exit $status
11+
fi
12+
}
13+
14+
set | grep TRAVIS
15+
16+
test $1 && arg1=$1
17+
if [[ $arg1 = 'release' ]]; then
18+
ver=8.0-5
19+
fname=MarkLogic-${ver}.x86_64.rpm
20+
fnamedeb="marklogic_"
21+
fnamedeb=$fnamedeb$ver
22+
suff="_amd64.deb"
23+
fnamedeb=$fnamedeb$suff
24+
25+
curl -c cookies.txt --data "email=${MLBUILD_USER}&password=${MLBUILD_PASSWORD}" https://developer.marklogic.com/login
26+
dl_link=$(curl -b cookies.txt --data "download=/download/binaries/8.0/${fname}" https://developer.marklogic.com/get-download-url | perl -pe 's/.*"path":"([^"]+).*/\1/')
27+
url="https://developer.marklogic.com${dl_link}"
28+
29+
echo "********* Downloading MarkLogic $ver"
30+
31+
successOrExit curl -k -o ./$fname $url
32+
33+
fname=$(pwd)/$fname
34+
35+
sudo apt-get update
36+
sudo apt-get install wajig alien rpm lsb-base dpkg-dev debhelper build-essential
37+
(cd /etc && sudo ln -s default sysconfig)
38+
sudo wajig rpminstall $fname
39+
40+
echo "********* MarkLogic $ver installed"
41+
else
42+
# find today
43+
day=$(date +"%Y%m%d")
44+
45+
# if the user passed a day string as a param then use it instead
46+
test $1 && day=$1
47+
# make a version number out of the date
48+
ver="8.0-$day"
49+
50+
echo "********* Downloading MarkLogic nightly $ver"
51+
52+
# fetch/install ML nightly
53+
fname="MarkLogic-$ver.x86_64.rpm"
54+
fnamedeb="marklogic_"
55+
fnamedeb=$fnamedeb$ver
56+
suff="_amd64.deb"
57+
fnamedeb=$fnamedeb$suff
58+
59+
url="https://root.marklogic.com/nightly/builds/linux64/rh6-intel64-80-test-1.marklogic.com/b8_0/pkgs.$day/$fname"
60+
61+
status=$(curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD --head --write-out %{http_code} --silent --output /dev/null $url)
62+
if [[ $status = 200 ]]; then
63+
successOrExit curl -k --anyauth -u $MLBUILD_USER:$MLBUILD_PASSWORD -o ./$fname $url
64+
65+
fname=$(pwd)/$fname
66+
67+
sudo apt-get update
68+
sudo apt-get install alien dpkg-dev debhelper build-essential
69+
sudo alien -d -k $fname
70+
sudo dpkg -i $fnamedeb
71+
72+
echo "********* MarkLogic nightly $ver installed"
73+
else
74+
echo "CANNOT DOWNLOAD: status = $status for date $day (URL=\"$url\")"
75+
exit 1
76+
fi
77+
fi

src/main/java/com/marklogic/appdeployer/command/appservers/UpdateRestApiServersCommand.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@
1313
*/
1414
public class UpdateRestApiServersCommand extends AbstractCommand {
1515

16+
private String restApiFilename;
17+
1618
public UpdateRestApiServersCommand() {
1719
setExecuteSortOrder(SortOrderConstants.UPDATE_REST_API_SERVERS);
1820
}
1921

22+
public UpdateRestApiServersCommand(String restApiFilename) {
23+
this();
24+
this.restApiFilename = restApiFilename;
25+
}
26+
2027
/**
2128
* This uses a different file than that of creating a REST API, as the payload for /v1/rest-apis differs from that
2229
* of the /manage/v2/servers endpoint.
2330
*/
2431
@Override
2532
public void execute(CommandContext context) {
26-
File f = context.getAppConfig().getConfigDir().getRestApiServerFile();
33+
File f = findRestApiConfigFile(context);
2734
if (f.exists()) {
2835
AppConfig appConfig = context.getAppConfig();
2936

@@ -43,4 +50,11 @@ public void execute(CommandContext context) {
4350
}
4451
}
4552

53+
protected File findRestApiConfigFile(CommandContext context) {
54+
if (restApiFilename != null) {
55+
return new File(context.getAppConfig().getConfigDir().getBaseDir(), restApiFilename);
56+
} else {
57+
return context.getAppConfig().getConfigDir().getRestApiServerFile();
58+
}
59+
}
4660
}

src/main/java/com/marklogic/rest/util/RestConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public String toString() {
3030
* Using the java.net.URI constructor that takes a string. Using any other constructor runs into encoding problems,
3131
* e.g. when a mimetype has a plus in it, that plus needs to be encoded, but doing as %2B will result in the % being
3232
* double encoded.
33-
*
33+
*
3434
* @param path
3535
* @return
3636
*/
3737
public URI buildUri(String path) {
3838
try {
39-
return new URI(String.format("%s://%s:%d%s", getScheme(), getHost(), getPort(), path));
39+
return new URI(String.format("%s://%s:%d%s", getScheme(), getHost(), getPort(), path.replace(" ", "+")));
4040
} catch (URISyntaxException ex) {
4141
throw new RuntimeException("Unable to build URI for path: " + path + "; cause: " + ex.getMessage(), ex);
4242
}

src/test/java/com/marklogic/appdeployer/command/admin/RequireAtLeastMl8Test.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.marklogic.appdeployer.command.admin;
22

33
import org.junit.Test;
4+
import org.junit.After;
45

56
import com.marklogic.appdeployer.AbstractAppDeployerTest;
67

@@ -11,4 +12,9 @@ public void testThatNoExceptionIsThrown() {
1112
initializeAppDeployer(new RequireAtLeastMl8Command());
1213
appDeployer.deploy(appConfig);
1314
}
15+
16+
@After
17+
public void teardown() {
18+
undeploySampleApp();
19+
}
1420
}

src/test/java/com/marklogic/appdeployer/command/databases/ClearDatabaseTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ public void teardown() {
1616

1717
/**
1818
* Testing against the modules database, but the operation is the same regardless of database.
19-
*
19+
*
2020
* Also, for the modules database, ml-gradle 1.+ had the ability to exclude certain modules from being deleted in
2121
* case those modules were needed by the REST API rewriter. But in that case, it's usually preferable to just use
2222
* the XCC approach for loading asset modules.
2323
*/
2424
@Test
2525
public void modulesDatabase() {
26-
initializeAppDeployer(new DeployRestApiServersCommand(), buildLoadModulesCommand());
26+
initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand());
2727

2828
appDeployer.deploy(appConfig);
2929

src/test/java/com/marklogic/appdeployer/command/servers/UpdateRestApiServersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void updateMainAndRestRestApiServers() {
2929
appConfig.getTestRestServerName(), "digest");
3030

3131
// Now redeploy with the update command
32-
initializeAppDeployer(new DeployRestApiServersCommand(), new UpdateRestApiServersCommand());
32+
initializeAppDeployer(new DeployRestApiServersCommand(true), new UpdateRestApiServersCommand());
3333
appDeployer.deploy(appConfig);
3434

3535
assertAuthentication(

0 commit comments

Comments
 (0)