Skip to content
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c8d74d7
GPII-1987: Initial check in of a start on creating data loaders.
cindyli Nov 11, 2016
ef671e4
GPII-1987: In progress with dataLoader.js
cindyli Nov 14, 2016
3c0c6ca
GPII-1987: In progress of implementing data loaders.
cindyli Nov 16, 2016
64c175e
GPII-1987: In progress of loading the authorization data.
cindyli Nov 21, 2016
83a426a
Merge branch 'master' into GPII-1987
cindyli Nov 25, 2016
c4cd5b4
Merge branch 'master' into GPII-1987
cindyli Dec 7, 2016
22e41d1
GPII-1987: Dropped the use of kettle.dataSource.CouchDB by using kett…
cindyli Dec 9, 2016
5f7285d
Merge branch 'GPII-1987' of https://github.com/cindyli/universal into…
cindyli Dec 15, 2016
de78b86
GPII-1987: Completed the script for loading authorization data into C…
cindyli Dec 16, 2016
19b8436
GPII-1987: In progress of creating the preferences data loader.
cindyli Dec 19, 2016
a27423b
GPII-1987: In progress of creating preferences data loader.
cindyli Dec 21, 2016
a06801d
GPII-1987: A little adjustment on constructing the preferences data s…
cindyli Dec 21, 2016
745bbfc
GPII-1987: Completed on the preferences data loader.
cindyli Dec 23, 2016
23762e9
GPII-1987: Allow to pass the data base name as an option. Added code …
cindyli Jan 3, 2017
6ce660c
GPII-1987: Splitted authDataLoader.js into 2 js files that one contai…
cindyli Jan 3, 2017
ec33391
Merge branch 'master' into GPII-1987
cindyli Jan 24, 2017
7798a42
GPII-1987: Refactored data loaders as well as adding test for the aut…
cindyli Jan 31, 2017
eef277d
GPII-1987: Added the validation process before the loading starts.
cindyli Feb 2, 2017
1bd667d
GPII-1987: File renaming and tests fixing.
cindyli Feb 2, 2017
cf907b9
GPII-1987: Adjusted auth data loader tests.
cindyli Feb 3, 2017
47764a8
GPII-1987: Refactored auth data loader test to reuse the code for tes…
cindyli Feb 6, 2017
908f9ff
GPII-1987: Added error test case for auth data loader.
cindyli Feb 7, 2017
e036123
GPII-1987: Created "gpii.dataLoader.reporter" grade to report success…
cindyli Feb 7, 2017
89c14cf
GPII-1987: Added tests for preferences data loader.
cindyli Feb 9, 2017
86bb666
GPII-1987: Corrected a duplicate grade name that causes running all-t…
cindyli Feb 9, 2017
0b0a07f
Merge branch 'master' into GPII-1987
cindyli Feb 9, 2017
c88e17c
GPII-1987: Added README for "scripts" directory.
cindyli Feb 10, 2017
521f72c
GPII-1987: In progress of using data loaders to set up GPII productio…
cindyli Feb 13, 2017
025cba4
GPII-1987: Uses avtar's fix on ansible-preferences-server that allows…
cindyli Feb 15, 2017
67715b9
GPII-1987: Addressed code review comments.
cindyli Feb 17, 2017
0e75218
GPII-1987: Adjusted data loader scripts to use the new gpii dataLoade…
cindyli Feb 17, 2017
1af51a9
GPII-1987: Use the correct branch to pull out ansible-preferences-ser…
cindyli Feb 17, 2017
72aab68
GPII-1987: Use the latest gpii-pouchdb changes to include the improve…
cindyli Feb 21, 2017
34e211e
GPII-1987: Sync up infusion versions used by universal and gpii-pouch…
cindyli Feb 21, 2017
4f7f072
GPII-1987: Use the correct gpii-pouchdb version after checking with T…
cindyli Feb 22, 2017
3907f0c
GPII-1987: Improved code comments and linted.
cindyli Feb 23, 2017
24b45c3
Merge branch 'GPII-1987' of https://github.com/cindyli/universal into…
cindyli Feb 23, 2017
2818200
GPII-1987: Switched to use gpii-ops/ansible-preferences-server master…
cindyli Feb 24, 2017
8d03025
Merge branch 'master' into GPII-1987
cindyli Mar 1, 2017
2778b60
Merge branch 'master' into GPII-1987
cindyli Apr 26, 2017
f6a1d79
GPII-1987: Experimenting with the lastest gpii-pouchdb release.
cindyli Apr 26, 2017
2da973e
GPII-1987: Updated to use the latest gpii-pouchdb repo commits.
cindyli Apr 28, 2017
f02e7d8
GPII-1987: Updated to use the latest gpii-pouchdb release.
cindyli May 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
This directory contains these scripts:

* **browserifyTestDependency.js**: To browserify test dependencies required for running some web tests.
* **dataLoader-auth.js**: To load authorization test data into CouchDB.
* **dataLoader-prefs.js**: To load preferences test data into CouchDB.

## Browserify Test Dependencies:

**Script name:** `browserifyTestDependency.js`

This script runs as a npm postinstall step to browserify some node modules that are required for running a few web tests. The creation of this script is to work around the issue that some of these node modules are only pulled in as `devDependencies`(see [GPII package.json](../package.json)), which means the browserifying should only occurs when GPII runs in the development mode. This script ensures the present of these node modules before proceeding with the browserifying. It prevents the failure of running `npm install` when setting up GPII in the production mode.

To start this script, run the following command in the `universal` directory:

```
node scripts/browserifyTestDependency.js
```

## Data Loaders

Data loaders are used for setting up GPII production environment by loading authorization and/or preferences test data into CouchDB. See [Data Loader issue ticket](https://issues.gpii.net/browse/GPII-1987) for details.

### Preferences Data Loader

**Script name:** `dataLoader-prefs.js`

Preferences Data Loader reads all json files from the given directory. Each json file is loaded as a individual CouchDB document with its file name as the corresponding document id.

To start the data loading, run the following command in the `universal` directory:

```
node scripts/dataLoader-prefs.js
```

#### How to config Preferences Data Loader

`dataLoader-prefs.js` instantiates the infusion component `gpii.dataLoader.prefsDataLoader` to load preferences data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct throughout infusion -> Infusion


#### Component Options

| Option | Type | Description | Default |
| ----------------- | ---------- | ----------- | ------- |
| `dbName` | String | Required. The name of the CouchDB database to be created for loading preferences data. If the dabase already exists, delete it and recreate. | preferences |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type dabase

| `dataPath` | String | Required. The directory where all preference json files reside. | %universal/testData/preferences/ |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct throughout: json -> JSON

| `couchDbUrl` | String | Required. The URL to the CouchDB. | http://localhost:5984 |

#### Supported Events

| Event | Description | Parameters | Parameters Description |
| ----- | ----------- | ---------- | ---------------------- |
| `onDataLoaded` | Fires when all preference data has been loaded into the CouchDB. | None | |
| `onDataLoadedError` | Fires when an error occurs at loading preference data. | errorMsg | The error message. |

### Authorization Data Loader

**Script name:** `dataLoader-auth.js`

Authorization Data Loader reads given json files from the file system and load them into CouchDB as they are.

To start the data loading, run the following command in the `universal` directory:

```
node scripts/dataLoader-auth.js
```

#### How to config Authorization Data Loader

`dataLoader-auth.js` instantiates the infusion component `gpii.dataLoader.authDataLoader` to load authorization data.

#### Component Options

| Option | Type | Description | Default |
| ----------------- | ---------- | ----------- | ------- |
| `dbName` | String | Required. The name of the CouchDB database to be created for loading authorization data. If the dabase already exists, delete it and recreate. | auth |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dabase etc. throughout

| `dataFile` | Array | Required. An array of data files to be loaded. | ["%universal/testData/security/TestOAuth2DataStore.json", "%universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-datastore/dbViews/views.json"] |
| `couchDbUrl` | String | Required. The URL to the CouchDB. | `http://localhost:5984` |

#### Supported Events

| Event | Description | Parameters | Parameters Description |
| ----- | ----------- | ---------- | ---------------------- |
| `onDataLoaded` | Fires when all preference data has been loaded into the CouchDB. | None | |
| `onDataLoadedError` | Fires when an error occurs at loading preference data. | errorMsg | The error message. |
36 changes: 36 additions & 0 deletions scripts/dataLoader-auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
Copyright 2016-2017 OCAD University

Licensed under the New BSD license. You may not use this file except in
compliance with this License.

The research leading to these results has received funding from the European Union's
Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016.

You may obtain a copy of the License at
https://github.com/GPII/universal/blob/master/LICENSE.txt
*/

/**
* The data loader to load GPII authorization server data into CouchDB.
* Before running this script, make sure CouchDB is started and ready for handling
* database operation requests.
*/

"use strict";

var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii");

fluid.setLogging(true);

require("./shared/authDataLoader.js");

gpii.dataLoader.authDataLoader({
dbName: "auth",
dataFile: [
"%universal/testData/security/TestOAuth2DataStore.json",
"%universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-datastore/dbViews/views.json"
],
couchDbUrl: "http://localhost:5984"
});
33 changes: 33 additions & 0 deletions scripts/dataLoader-prefs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*!
Copyright 2016-2017 OCAD University

Licensed under the New BSD license. You may not use this file except in
compliance with this License.

The research leading to these results has received funding from the European Union's
Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016.

You may obtain a copy of the License at
https://github.com/GPII/universal/blob/master/LICENSE.txt
*/

/**
* The data loader to load GPII preferences data into CouchDB.
* Before running this script, make sure CouchDB is started and ready for handling
* database operation requests.
*/

"use strict";

var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii");

fluid.setLogging(true);

require("./shared/prefsDataLoader.js");

gpii.dataLoader.prefsDataLoader({
dbName: "preferences",
dataPath: "%universal/testData/preferences/",
couchDbUrl: "http://localhost:5984"
});
48 changes: 48 additions & 0 deletions scripts/shared/authDataLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to see all the contents of scripts/shared placed into a fresh "micromodule" named dataLoader, and all the tests can then be similarly named, since tests/scripts looks rather peculiar

Copyright 2017 OCAD University

Licensed under the New BSD license. You may not use this file except in
compliance with this License.

The research leading to these results has received funding from the European Union's
Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016.

You may obtain a copy of the License at
https://github.com/GPII/universal/blob/master/LICENSE.txt
*/

"use strict";

var fluid = require("infusion"),
gpii = fluid.registerNamespace("gpii");

require("./dataLoader.js");

fluid.defaults("gpii.dataLoader.authDataLoader", {
gradeNames: ["gpii.dataLoader", "gpii.dataLoader.reporter"],
databases: {
expander: {
funcName: "gpii.dataLoader.authDataLoader.constructAuthData",
args: ["{that}.options.dbName", "{that}.options.dataFile"]
}
},
listeners: {
"onCreate.load": {
listener: "gpii.dataLoader.performLoad",
args: ["{that}.options.dbName", "{that}"]
}
}
});

/**
* Construct the value of `options.databases` that to be accepted by `gpii.dataLoader` (See dataLoader.js).
*
* @param dbName {String} The database name;
* @param dataFile {Array} An array of data paths to files to be loaded into the database.
*/
gpii.dataLoader.authDataLoader.constructAuthData = function (dbName, dataFile) {
var togo = {};
fluid.set(togo, dbName + ".dataFile", dataFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[dbName, "dataFile"] is a bit clearer and safer


return togo;
};
Loading