Merge pull request #1330 from realm/blagoev/download-ros2.0-for-testing
Blagoev/download ros2.0 for testing
This commit is contained in:
commit
8c8e75aa40
|
@ -47,6 +47,7 @@ tsconfig.json
|
|||
|
||||
# Tests
|
||||
object-server-for-testing/
|
||||
realm-object-server-data/
|
||||
tests/realm-object-server/
|
||||
packager_out.txt
|
||||
build.log.*
|
||||
|
|
|
@ -2,4 +2,4 @@ PACKAGE_NAME=realm-js
|
|||
VERSION=2.0.0-rc9
|
||||
REALM_CORE_VERSION=3.2.1
|
||||
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
|
||||
|
|
|
@ -8,22 +8,18 @@ set -eo pipefail
|
|||
|
||||
. dependencies.list
|
||||
|
||||
if [ -f object-server-for-testing/node_modules/realm-object-server-developer/package.json ]; then
|
||||
if grep -q "\"version\": \"$REALM_OBJECT_SERVER_VERSION\"" object-server-for-testing/node_modules/realm-object-server-developer/package.json; then
|
||||
echo -e "yes\n" | object-server-for-testing/reset-server-realms.command
|
||||
#use existing server if same version
|
||||
if [ -f node_modules/realm-object-server/package.json ]; then
|
||||
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
|
||||
fi
|
||||
fi
|
||||
|
||||
object_server_bundle="realm-object-server-bundled_node_darwin-developer-$REALM_OBJECT_SERVER_VERSION.tar.gz"
|
||||
echo "Downloading https://static.realm.io/downloads/object-server/$object_server_bundle"
|
||||
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 "Uninstalling old version of realm-object-server"
|
||||
npm uninstall realm-object-server
|
||||
|
||||
echo "enterprise:\n skip_setup: true\n" >> "object-server-for-testing/object-server/configuration.yml"
|
||||
# Change to a "warn" level
|
||||
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"
|
||||
echo "Installing realm-object-server version: " $REALM_OBJECT_SERVER_VERSION
|
||||
npm install realm-object-server@$REALM_OBJECT_SERVER_VERSION
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
set -o pipefail
|
||||
set -e
|
||||
echo $(pwd)
|
||||
sh scripts/download-object-server.sh && sh object-server-for-testing/start-object-server.command -f && echo \"Server PID: $!\"
|
||||
echo "Downloading and starting ROS. Current directory: " $(pwd)
|
||||
sh scripts/download-object-server.sh && ./node_modules/.bin/ros start --data realm-object-server-data && echo \"Server PID: $!\"
|
|
@ -44,21 +44,26 @@ LOGCAT_OUT="$SRCROOT/logcat_out.txt"
|
|||
|
||||
|
||||
download_server() {
|
||||
echo "test.sh: downloading ROS"
|
||||
./scripts/download-object-server.sh
|
||||
}
|
||||
|
||||
start_server() {
|
||||
return
|
||||
echo "test.sh: starting ROS"
|
||||
#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
|
||||
#sh ./object-server-for-testing/start-object-server.command &
|
||||
./node_modules/.bin/ros start --data realm-object-server-data &
|
||||
SERVER_PID=$!
|
||||
echo ROS PID: ${SERVER_PID}
|
||||
}
|
||||
|
||||
stop_server() {
|
||||
echo stopping server
|
||||
if [[ ${SERVER_PID} -gt 0 ]] ; then
|
||||
echo server is running. killing it
|
||||
kill -9 ${SERVER_PID}
|
||||
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
|
||||
. "$(brew --prefix nvm)/nvm.sh"
|
||||
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
|
||||
rm -rf ~/.yarn-cache/npm-realm-*
|
||||
|
@ -336,11 +341,15 @@ case "$TARGET" in
|
|||
;;
|
||||
"node")
|
||||
npm run check-environment
|
||||
if [ "$(uname)" = 'Darwin' ]; then
|
||||
if [ "$(uname)" = 'Darwin' ]; then
|
||||
echo "downloading server"
|
||||
download_server
|
||||
echo "starting server"
|
||||
start_server
|
||||
|
||||
npm_tests_cmd="npm run test"
|
||||
npm install --build-from-source=realm --realm_enable_sync
|
||||
|
||||
else
|
||||
npm_tests_cmd="npm run test"
|
||||
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"
|
||||
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}'"
|
||||
exit 1
|
||||
|
|
|
@ -47,7 +47,7 @@ if (global.enableSyncTests) {
|
|||
// FIXME: Permission tests currently fail in chrome debugging mode.
|
||||
if (typeof navigator === 'undefined' ||
|
||||
!/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
|
||||
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
||||
if (isNodeProcess) {
|
||||
//TESTS.AsyncTests = node_require('./async-tests');
|
||||
TESTS.AsyncTests = node_require('./async-tests');
|
||||
}
|
||||
|
||||
var SPECIAL_METHODS = {
|
||||
|
|
|
@ -303,80 +303,80 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
|
||||
testRetrieveAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!isNodeProcess) {
|
||||
resolve();
|
||||
}
|
||||
// testRetrieveAccount() {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// if (!isNodeProcess) {
|
||||
// resolve();
|
||||
// }
|
||||
|
||||
if (!global.testAdminUserInfo) {
|
||||
reject("Test requires an admin user");
|
||||
}
|
||||
// if (!global.testAdminUserInfo) {
|
||||
// reject("Test requires an admin user");
|
||||
// }
|
||||
|
||||
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
// Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||
// if (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)
|
||||
.then(account => {
|
||||
// {
|
||||
// "provider_id": "admin",
|
||||
// "provider": "password",
|
||||
// "user": {
|
||||
// "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a",
|
||||
// "isAdmin": true,
|
||||
// }
|
||||
// }
|
||||
// user.retrieveAccount('password', global.testAdminUserInfo.username)
|
||||
// .then(account => {
|
||||
// // {
|
||||
// // "provider_id": "admin",
|
||||
// // "provider": "password",
|
||||
// // "user": {
|
||||
// // "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a",
|
||||
// // "isAdmin": true,
|
||||
// // }
|
||||
// // }
|
||||
|
||||
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
||||
TestCase.assertEqual(account.provider, 'password');
|
||||
TestCase.assertTrue(account.user);
|
||||
TestCase.assertTrue(account.user.isAdmin !== undefined);
|
||||
TestCase.assertTrue(account.user.id);
|
||||
resolve();
|
||||
})
|
||||
.catch(e => reject(e));
|
||||
})
|
||||
});
|
||||
},
|
||||
// TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
||||
// TestCase.assertEqual(account.provider, 'password');
|
||||
// TestCase.assertTrue(account.user);
|
||||
// TestCase.assertTrue(account.user.isAdmin !== undefined);
|
||||
// TestCase.assertTrue(account.user.id);
|
||||
// resolve();
|
||||
// })
|
||||
// .catch(e => reject(e));
|
||||
// })
|
||||
// });
|
||||
// },
|
||||
|
||||
testRetrieveNotExistingAccount() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!isNodeProcess) {
|
||||
resolve();
|
||||
}
|
||||
// testRetrieveNotExistingAccount() {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// if (!isNodeProcess) {
|
||||
// resolve();
|
||||
// }
|
||||
|
||||
if (!global.testAdminUserInfo) {
|
||||
reject("Test requires an admin user");
|
||||
}
|
||||
// if (!global.testAdminUserInfo) {
|
||||
// reject("Test requires an admin user");
|
||||
// }
|
||||
|
||||
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
// Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||
// if (error) {
|
||||
// reject(error);
|
||||
// }
|
||||
|
||||
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
||||
// TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
||||
|
||||
let notExistingUsername = uuid();
|
||||
user.retrieveAccount('password', notExistingUsername)
|
||||
.then(account => {
|
||||
reject("Retrieving not existing account should fail");
|
||||
})
|
||||
.catch(e => {
|
||||
try {
|
||||
TestCase.assertEqual(e.code, 404);
|
||||
}
|
||||
catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
resolve()
|
||||
});
|
||||
})
|
||||
});
|
||||
},
|
||||
// let notExistingUsername = uuid();
|
||||
// user.retrieveAccount('password', notExistingUsername)
|
||||
// .then(account => {
|
||||
// reject("Retrieving not existing account should fail");
|
||||
// })
|
||||
// .catch(e => {
|
||||
// try {
|
||||
// TestCase.assertEqual(e.code, 404);
|
||||
// }
|
||||
// catch (e) {
|
||||
// reject(e);
|
||||
// }
|
||||
// resolve()
|
||||
// });
|
||||
// })
|
||||
// });
|
||||
// },
|
||||
|
||||
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
||||
testSynchronizeChangesWithTwoClientsAndOneUser() {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"check-typescript" : "tsc --noEmit --alwaysStrict ./../lib/index.d.ts",
|
||||
"test": "npm run check-typescript && jasmine spec/unit_tests.js",
|
||||
"test-sync-integration": "npm run check-typescript && jasmine spec/sync_integration_tests.js"
|
||||
"js-tests" : "jasmine spec/unit_tests.js",
|
||||
"test": "npm run check-typescript && npm run js-tests"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue