Merge pull request #1330 from realm/blagoev/download-ros2.0-for-testing

Blagoev/download ros2.0 for testing
This commit is contained in:
blagoev 2017-09-21 02:24:27 +03:00 committed by GitHub
commit 8c8e75aa40
9 changed files with 95 additions and 196 deletions

1
.gitignore vendored
View File

@ -47,6 +47,7 @@ tsconfig.json
# Tests # Tests
object-server-for-testing/ object-server-for-testing/
realm-object-server-data/
tests/realm-object-server/ tests/realm-object-server/
packager_out.txt packager_out.txt
build.log.* build.log.*

View File

@ -2,4 +2,4 @@ PACKAGE_NAME=realm-js
VERSION=2.0.0-rc9 VERSION=2.0.0-rc9
REALM_CORE_VERSION=3.2.1 REALM_CORE_VERSION=3.2.1
REALM_SYNC_VERSION=2.0.0-rc21 REALM_SYNC_VERSION=2.0.0-rc21
REALM_OBJECT_SERVER_VERSION=2.0.0-alpha.22 REALM_OBJECT_SERVER_VERSION=2.0.0-alpha.32

View File

@ -8,22 +8,18 @@ set -eo pipefail
. dependencies.list . dependencies.list
if [ -f object-server-for-testing/node_modules/realm-object-server-developer/package.json ]; then #use existing server if same version
if grep -q "\"version\": \"$REALM_OBJECT_SERVER_VERSION\"" object-server-for-testing/node_modules/realm-object-server-developer/package.json; then if [ -f node_modules/realm-object-server/package.json ]; then
echo -e "yes\n" | object-server-for-testing/reset-server-realms.command if grep -q "\"version\": \"$REALM_OBJECT_SERVER_VERSION\"" node_modules/realm-object-server/package.json; then
# echo -e "yes\n" | object-server-for-testing/reset-server-realms.command
rm -rf realm-object-server-data
rm -rf realm-object-server
exit exit
fi fi
fi fi
object_server_bundle="realm-object-server-bundled_node_darwin-developer-$REALM_OBJECT_SERVER_VERSION.tar.gz" echo "Uninstalling old version of realm-object-server"
echo "Downloading https://static.realm.io/downloads/object-server/$object_server_bundle" npm uninstall realm-object-server
curl -f -L "https://static.realm.io/downloads/object-server/$object_server_bundle" -o "$object_server_bundle"
rm -rf object-server-for-testing
mkdir object-server-for-testing
tar -C object-server-for-testing -xf "$object_server_bundle"
rm "$object_server_bundle"
echo "enterprise:\n skip_setup: true\n" >> "object-server-for-testing/object-server/configuration.yml" echo "Installing realm-object-server version: " $REALM_OBJECT_SERVER_VERSION
# Change to a "warn" level npm install realm-object-server@$REALM_OBJECT_SERVER_VERSION
sed -i -- "s/# level: 'info'/level: 'warn'/g" object-server-for-testing/object-server/configuration.yml
touch "object-server-for-testing/object-server/do_not_open_browser"

View File

@ -2,5 +2,5 @@
set -o pipefail set -o pipefail
set -e set -e
echo $(pwd) echo "Downloading and starting ROS. Current directory: " $(pwd)
sh scripts/download-object-server.sh && sh object-server-for-testing/start-object-server.command -f && echo \"Server PID: $!\" sh scripts/download-object-server.sh && ./node_modules/.bin/ros start --data realm-object-server-data && echo \"Server PID: $!\"

View File

@ -44,21 +44,26 @@ LOGCAT_OUT="$SRCROOT/logcat_out.txt"
download_server() { download_server() {
echo "test.sh: downloading ROS"
./scripts/download-object-server.sh ./scripts/download-object-server.sh
} }
start_server() { start_server() {
return echo "test.sh: starting ROS"
#disabled ROS logging #disabled ROS logging
sh ./object-server-for-testing/start-object-server.command &> /dev/null & # sh ./object-server-for-testing/start-object-server.command &> /dev/null &
#enabled ROS logging #enabled ROS logging
#sh ./object-server-for-testing/start-object-server.command & #sh ./object-server-for-testing/start-object-server.command &
./node_modules/.bin/ros start --data realm-object-server-data &
SERVER_PID=$! SERVER_PID=$!
echo ROS PID: ${SERVER_PID}
} }
stop_server() { stop_server() {
echo stopping server
if [[ ${SERVER_PID} -gt 0 ]] ; then if [[ ${SERVER_PID} -gt 0 ]] ; then
echo server is running. killing it
kill -9 ${SERVER_PID} kill -9 ${SERVER_PID}
fi fi
} }
@ -242,7 +247,7 @@ elif [ -x "$(command -v brew)" ] && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
# TODO: change the mac slaves to use manual nvm installation # TODO: change the mac slaves to use manual nvm installation
. "$(brew --prefix nvm)/nvm.sh" . "$(brew --prefix nvm)/nvm.sh"
fi fi
[[ "$(command -v nvm)" ]] && nvm install 6.5.0 && nvm use 6.5.0 || true [[ "$(command -v nvm)" ]] && nvm install 7.10.0 && nvm use 7.10.0 || true
# Remove cached packages # Remove cached packages
rm -rf ~/.yarn-cache/npm-realm-* rm -rf ~/.yarn-cache/npm-realm-*
@ -336,11 +341,15 @@ case "$TARGET" in
;; ;;
"node") "node")
npm run check-environment npm run check-environment
if [ "$(uname)" = 'Darwin' ]; then if [ "$(uname)" = 'Darwin' ]; then
echo "downloading server"
download_server download_server
echo "starting server"
start_server start_server
npm_tests_cmd="npm run test" npm_tests_cmd="npm run test"
npm install --build-from-source=realm --realm_enable_sync npm install --build-from-source=realm --realm_enable_sync
else else
npm_tests_cmd="npm run test" npm_tests_cmd="npm run test"
npm install --build-from-source=realm npm install --build-from-source=realm
@ -431,14 +440,6 @@ case "$TARGET" in
echo -e "enterprise:\n skip_setup: true\n" >> "tests/sync-bundle/object-server/configuration.yml" echo -e "enterprise:\n skip_setup: true\n" >> "tests/sync-bundle/object-server/configuration.yml"
touch "tests/sync-bundle/object-server/do_not_open_browser" touch "tests/sync-bundle/object-server/do_not_open_browser"
;; ;;
"object-server-integration")
echo -e "yes\n" | ./tests/sync-bundle/reset-server-realms.command
pushd "$SRCROOT/tests"
npm install
npm run test-sync-integration
popd
;;
*) *)
echo "Invalid target '${TARGET}'" echo "Invalid target '${TARGET}'"
exit 1 exit 1

View File

@ -47,7 +47,7 @@ if (global.enableSyncTests) {
// FIXME: Permission tests currently fail in chrome debugging mode. // FIXME: Permission tests currently fail in chrome debugging mode.
if (typeof navigator === 'undefined' || if (typeof navigator === 'undefined' ||
!/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef !/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
TESTS.PermissionTests = require('./permission-tests'); //TESTS.PermissionTests = require('./permission-tests');
} }
} }
@ -56,7 +56,7 @@ function node_require(module) { return require(module); }
// If on node, run the async tests // If on node, run the async tests
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]'; const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
if (isNodeProcess) { if (isNodeProcess) {
//TESTS.AsyncTests = node_require('./async-tests'); TESTS.AsyncTests = node_require('./async-tests');
} }
var SPECIAL_METHODS = { var SPECIAL_METHODS = {

View File

@ -303,80 +303,80 @@ module.exports = {
}); });
}, },
testRetrieveAccount() { // testRetrieveAccount() {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
if (!isNodeProcess) { // if (!isNodeProcess) {
resolve(); // resolve();
} // }
if (!global.testAdminUserInfo) { // if (!global.testAdminUserInfo) {
reject("Test requires an admin user"); // reject("Test requires an admin user");
} // }
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => { // Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
if (error) { // if (error) {
reject(error); // reject(error);
} // }
TestCase.assertTrue(user.isAdmin, "Test requires an admin user"); // TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
user.retrieveAccount('password', global.testAdminUserInfo.username) // user.retrieveAccount('password', global.testAdminUserInfo.username)
.then(account => { // .then(account => {
// { // // {
// "provider_id": "admin", // // "provider_id": "admin",
// "provider": "password", // // "provider": "password",
// "user": { // // "user": {
// "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a", // // "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a",
// "isAdmin": true, // // "isAdmin": true,
// } // // }
// } // // }
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username); // TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
TestCase.assertEqual(account.provider, 'password'); // TestCase.assertEqual(account.provider, 'password');
TestCase.assertTrue(account.user); // TestCase.assertTrue(account.user);
TestCase.assertTrue(account.user.isAdmin !== undefined); // TestCase.assertTrue(account.user.isAdmin !== undefined);
TestCase.assertTrue(account.user.id); // TestCase.assertTrue(account.user.id);
resolve(); // resolve();
}) // })
.catch(e => reject(e)); // .catch(e => reject(e));
}) // })
}); // });
}, // },
testRetrieveNotExistingAccount() { // testRetrieveNotExistingAccount() {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
if (!isNodeProcess) { // if (!isNodeProcess) {
resolve(); // resolve();
} // }
if (!global.testAdminUserInfo) { // if (!global.testAdminUserInfo) {
reject("Test requires an admin user"); // reject("Test requires an admin user");
} // }
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => { // Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
if (error) { // if (error) {
reject(error); // reject(error);
} // }
TestCase.assertTrue(user.isAdmin, "Test requires an admin user"); // TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
let notExistingUsername = uuid(); // let notExistingUsername = uuid();
user.retrieveAccount('password', notExistingUsername) // user.retrieveAccount('password', notExistingUsername)
.then(account => { // .then(account => {
reject("Retrieving not existing account should fail"); // reject("Retrieving not existing account should fail");
}) // })
.catch(e => { // .catch(e => {
try { // try {
TestCase.assertEqual(e.code, 404); // TestCase.assertEqual(e.code, 404);
} // }
catch (e) { // catch (e) {
reject(e); // reject(e);
} // }
resolve() // resolve()
}); // });
}) // })
}); // });
}, // },
/* This test fails because of realm-object-store #243 . We should use 2 users. /* This test fails because of realm-object-store #243 . We should use 2 users.
testSynchronizeChangesWithTwoClientsAndOneUser() { testSynchronizeChangesWithTwoClientsAndOneUser() {

View File

@ -15,7 +15,7 @@
}, },
"scripts": { "scripts": {
"check-typescript" : "tsc --noEmit --alwaysStrict ./../lib/index.d.ts", "check-typescript" : "tsc --noEmit --alwaysStrict ./../lib/index.d.ts",
"test": "npm run check-typescript && jasmine spec/unit_tests.js", "js-tests" : "jasmine spec/unit_tests.js",
"test-sync-integration": "npm run check-typescript && jasmine spec/sync_integration_tests.js" "test": "npm run check-typescript && npm run js-tests"
} }
} }

View File

@ -1,99 +0,0 @@
"use strict";
const spawn = require("child_process").spawn;
const readline = require("readline");
const fs = require("fs");
const Realm = require("realm");
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
describe('Sync Integration', () => {
beforeEach(function(done) {
this.objectServer = spawn("sync-bundle/start-object-server.command");
this.objectServer.once("close", (code) => {
if (typeof code === "number" && code != 0) {
console.error(`Object Server exited with code ${code}`);
process.exit(-1);
}
});
this.rl = readline.createInterface({ input: this.objectServer.stdout });
this.rl.on("line", (line) => {
var match;
if ((match = line.match(/Connection\[1\]: Session\[1\]: Received: BIND\(server_path='\/(.+)',/))) {
var adminUser = Realm.Sync.User.adminUser(fs.readFileSync("sync-bundle/admin_token.base64", "utf-8"));
this.adminRealmPath = match[1];
this.adminRealm = new Realm({
path: "__admin.realm",
sync: {
user: adminUser,
url: `realm://127.0.0.1:9080/${this.adminRealmPath}`
},
schema: [
{
name: "RealmFile",
properties: {
id: 'string',
path: 'string'
}
}
]
});
done();
}
});
});
afterEach(function(done) {
this.rl.close();
this.objectServer.kill('SIGKILL');
this.adminRealm.close();
let reset = spawn("sync-bundle/reset-server-realms.command");
reset.once("close", done);
reset.stdin.write("yes\n");
Realm.clearTestState();
});
it("should work", function(done) {
Realm.Sync.User.create('http://127.0.0.1:9080/', 'foo', 'bar', function(error) {
if (error) {
fail(error);
return;
}
Realm.Sync.User.login('http://127.0.0.1:9080/', 'foo', 'bar', function(error, user) {
if (error) {
fail(error);
return;
}
var _realm = new Realm({
syncConfig: {
identity: user.identity,
url: 'realm://127.0.0.1:9080/~/demo/realm1'
},
schema: [
{
name: 'IntObject',
properties: {
int: 'int'
}
}
]
});
});
});
var realms = this.adminRealm.objects("RealmFile");
realms.addListener((sender, changeset) => {
if (changeset.insertions.length === 1) {
expect(realms[changeset.insertions[0]].path).toMatch(/demo\/realm1$/);
done();
}
});
});
});