Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPII-2307: Add combined code coverage reports. #508

Merged
merged 29 commits into from Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e173cd4
GPII-2307: Added combined code coverage and reporting.
the-t-in-rtf Mar 29, 2017
88b1cea
GPII-2307: Updated `testem.js` to bypass QUnit composite, which resol…
the-t-in-rtf Mar 29, 2017
c58a1c5
Merge remote-tracking branch 'upstream/master' into GPII-2307
the-t-in-rtf Mar 29, 2017
44426ee
GPII-2307: Removed working notes in checking browser code coverage co…
the-t-in-rtf Mar 29, 2017
f3c0828
GPII-2307: Updated to use `testDef` pattern per PR feedback.
the-t-in-rtf Mar 30, 2017
e903c26
Committed work in progress on "testDefs" branch. All tests working c…
the-t-in-rtf Apr 11, 2017
39e8cad
GPII-2307: Standardized gpii-testem work to include only minimum fix…
the-t-in-rtf Apr 12, 2017
80ab887
NOJIRA: Removed 'skip' rules, all available browser launchers will be…
the-t-in-rtf May 8, 2017
3af8ebb
GPII-2307: Relativised all paths to dependencies to support local bro…
the-t-in-rtf May 19, 2017
d67a12d
GPII-2307: Updated to latest testem and gpii-testem.
the-t-in-rtf May 19, 2017
76694bd
GPII-2307: Removed cruft from (now unneeded) "testDefs" approach.
the-t-in-rtf May 19, 2017
f07b196
GPII-2307: Relativised remaining paths in all-tests.html.
the-t-in-rtf May 24, 2017
85e2a9c
Cleaned up absolute path to QUnit CSS and removed duplicate include o…
the-t-in-rtf May 29, 2017
e115ee3
Added a warning about 404 console errors when hosting the tests in py…
the-t-in-rtf May 29, 2017
fbda4da
GPII-2307: Added instrumentation steps to individual npm scripts. S…
the-t-in-rtf May 31, 2017
75699b4
GPII-2307: Removed "skip" options for Safari and Opera.
the-t-in-rtf May 31, 2017
bf8eb0a
GPII-2307: Added information about the need for the browser to be "i…
the-t-in-rtf Jun 1, 2017
7185106
GPII-2307: Added a section on code covfefe to the README.
the-t-in-rtf Jun 1, 2017
b95df8f
GPII-2307: Added `.nyc_output` to pretest cleanup.
the-t-in-rtf Jun 2, 2017
30b5a4f
GPII-2307: Added `posttest` to the list of "scripts you should not n…
the-t-in-rtf Jun 2, 2017
02cdbd6
GPII-2307: Removed duplicated, commented includes, and simplified al…
the-t-in-rtf Jun 2, 2017
3155daa
GPII-2307: Removed `yarn.lock` for the time being.
the-t-in-rtf Jun 8, 2017
a4a95e7
GPII-2307: Removed unneeded coverage client dependencies per PR feedb…
the-t-in-rtf Jun 13, 2017
456ba1c
Merge remote-tracking branch 'upstream/master' into GPII-2307 and res…
the-t-in-rtf Jun 22, 2017
b24c923
GPII-2307: Updated to gpii-pouchdb 1.0.2. Refactored to avoid doubl…
the-t-in-rtf Jun 26, 2017
304a887
NOJIRA: Added `.idea` directory to `.gitignore`.
the-t-in-rtf Jun 26, 2017
f9a1e43
GPII-2307: Committed fix for Windows "403" errors when running browse…
the-t-in-rtf Jun 27, 2017
017d88f
GPII-2307: Disabled non-passing IE tests for now.
the-t-in-rtf Jun 27, 2017
1dc0f9c
GPII-2307: Removed original `cwd` workaround and the workaround for …
the-t-in-rtf Jun 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -13,3 +13,7 @@ Vagrantfile.local
.vagrant/

report.tap
coverage
.nyc_output
instrumented
reports
37 changes: 0 additions & 37 deletions Gruntfile.js
Expand Up @@ -29,49 +29,12 @@ module.exports = function (grunt) {
enableJSON5: true
},
src: ["gpii/**/*.json5", "tests/**/*.json5", "testData/**/*.json5", "*.json5"]
},
shell: {
options: {
stdout: true,
stderr: true,
failOnError: true,
execOptions: {
maxBuffer: Infinity
}
},
runBrowserTests: {
command: "vagrant ssh -c 'cd /home/vagrant/sync/node_modules/universal; DISPLAY=:0 testem ci --file tests/web/testem_qi.json'"
},
runNodeTests: {
command: "vagrant ssh -c 'cd /home/vagrant/sync/node_modules/universal; npm test'"
},
runNodeProductionTests: {
command: "vagrant ssh -c 'cd /home/vagrant/sync/node_modules/universal; node tests/ProductionConfigTests.js'"
}
}
});

grunt.loadNpmTasks("fluid-grunt-eslint");
grunt.loadNpmTasks("grunt-jsonlint");
grunt.loadNpmTasks("fluid-grunt-json5lint");
grunt.loadNpmTasks("grunt-shell");

grunt.registerTask("browser-tests", "Run browser tests in a VM", function () {
grunt.task.run("shell:runBrowserTests");
});

grunt.registerTask("node-tests", "Run Node tests in a VM", function () {
grunt.task.run("shell:runNodeTests");
});

grunt.registerTask("node-production-tests", "Run Node production tests in a VM", function () {
grunt.task.run("shell:runNodeProductionTests");
});

grunt.registerTask("tests", "Run browser and node tests in a VM", function () {
grunt.task.run("shell:runBrowserTests");
grunt.task.run("shell:runNodeTests");
});

grunt.registerTask("lint", "Apply jshint, jsonlint and json5lint", ["eslint", "jsonlint", "json5lint"]);
};
104 changes: 71 additions & 33 deletions README.md
@@ -1,26 +1,27 @@
GPII Universal
==============

Cross platform, core components of the GPII personalization infrastructure. This repository should not be used directly,
but in conjunction with one of the top-level GPII architecture-specific repositories. Documentation for this project is
housed beneath http://wiki.gpii.net/w/Architecture .
The package contains cross-platform core components of the GPII personalization infrastructure. This repository should
not be used directly, but in conjunction with one of the top-level GPII architecture-specific repositories.
Additional documentation is available [on our wiki](http://wiki.gpii.net/w/Architecture).

Installation
------------

In production, this repository should be installed using one of the top-level GPII architecture-specific repositories -
* windows - https://github.com/GPII/windows
* linux - https://github.com/GPII/linux
* android - https://github.com/GPII/android
In production, this repository should be installed using one of the top-level GPII architecture-specific repositories:

For development purposes this repository could be cloned directly.
* [windows](https://github.com/GPII/windows)
* [linux](https://github.com/GPII/linux)
* [android](https://github.com/GPII/android)

For development purposes this repository can also be cloned directly.

Quick Start
-----------

To verify the basic installation of GPII universal, you can start the core framework with

npm start
`npm start`

If all is well, you will see a message like

Expand All @@ -44,70 +45,107 @@ Testing
-------

There are currently 3 different sets of tests:
* the ones that run in the browser
* the ones run in node.js
* production tests, running in node.js but having external requirements

* Tests that run in the browser
* Tests that run in node.js
* Production tests, that run in node.js, but which interact with external services.

The `npm test` command will run the browser and Node based tests. Please note, the node tests may behave oddly if you
have set the `NODE_ENV` variable.

#### Running browser tests:
open `{universal}/tests/web/html/all-tests.html` in your preferred browser

You can run the browser tests in this package with a range of browsers using [Testem](https://github.com/testem/testem),
and the configuration file `tests/testem.js`, which will ensure that code coverage information is collected. From the
root of the `universal` folder, run the following command:

`npm run test:browser`

You can also run (and debug) the tests manually by running `testem --file tests/testem.js` from the root of the
repository. The required test fixtures and testem will start, and Testem will provide a URL you can open in a browser.

If you would like to debug individual tests or view the test summary in a browser without using Testem, you can:

1. Host the working directory, for example, using a command like the following from the root of the repository: `python -m SimpleHTTPServer 4103`
2. Open the "rollup" file `tests/all-tests.html` that runs all tests in a browser. Continuing the above example, you would load the URL `http://localhost:4103/tests/web/html/all-tests.html`.


#### Running node-based tests

From the root of the `universal` folder, run the following command:

npm test
`npm run test:node`

Please note, the node tests may behave oddly if you have set the `NODE_ENV` variable.

#### Running tests using a VM
A VM can be automatically created using tools provided by the [Prosperity4All Quality Infrastructure](https://github.com/GPII/qi-development-environments/). Please ensure the [requirements](https://github.com/GPII/qi-development-environments/#requirements) have been met. The ``vagrant up`` command can then be used to provision a new VM.

Within the VM, the application will be installed in the directory specified by the nodejs_app_install_dir variable, which is defined in the provisioning/vagrant-vars.yml configuration file in this repository. By default it is set to "/home/vagrant/sync/node_modules/universal".
A VM can be automatically created using tools provided by the
[Prosperity4All Quality Infrastructure](https://github.com/GPII/qi-development-environments/). Please ensure the
[requirements](https://github.com/GPII/qi-development-environments/#requirements) have been met. The `vagrant up`
command can then be used to provision a new VM.

Within the VM, the application will be installed in the directory specified by the `nodejs_app_install_dir` variable,
which is defined in `provisioning/vagrant-vars.yml` configuration file in this repository. By default the installation
directory is set to `/home/vagrant/sync/node_modules/universal`.

Following the provisioning phase, tests can be run in the VM directly from the host system, without the need to log into the VM or interact with its console.
Following the provisioning phase, tests can be run in the VM directly from the host system, without the need to log
into the VM or interact with its console.

From your project's top-level directory (where the Vagrantfile and Gruntfile.js files reside), run:
From your project's top-level directory (where the `Vagrantfile` and `package.json` files reside), run:

- node-based tests: `grunt node-tests`
- browser-based tests: `grunt browser-tests`
- production tests: `grunt node-production-tests`
- Node and browser tests: `npm run test:vagrant`
- Node tests only: `npm run test:vagrantNode`
- browser tests only: `npm run test:vagrantBrowser`
- production tests: `npm run test:vagrantProduction`

The ``grunt tests`` command will run the browser and Node based tests.

These Grunt tasks will run the correct Vagrant commands to connect to the VM and run the tests within the isolated environment. You can also run `vagrant ssh` to connect to the VM (or open the VirtualBox console and interface with the desktop environment) and run the tests manually if you wish.
You can also run `vagrant ssh` to connect to the VM (or open the VirtualBox console and interface with the desktop
environment) and run the tests manually if you wish.

Usage
-----

To use any of the gpii components or functionality in node.js, use the
To use any of the gpii components or functionality in Node.js, use the
following statements to get access to fluid and/or gpii objects.

var fluid = require("universal"),
gpii = fluid.registerNamespace("gpii");
// Now you will have access to both fluid and gpii namespaces.
```
var fluid = require("universal"),
gpii = fluid.registerNamespace("gpii");
// Now you will have access to both fluid and gpii namespaces.
```


#### Running node-based production tests
The purpose of these tests are to test production config setups of the system. This involves using the online preferences server when fetching preferences sets, so there are extended requirements for these tests.
The purpose of these tests are to test production config setups of the system. This involves using the online
preferences server when fetching preferences sets, so there are extended requirements for these tests.

These tests are a supplement to the `all-tests.js` (and hence not part of that test suite) and should be run separately when testing the system and having the below requirements available.
These tests are a supplement to the `all-tests.js` (and hence not part of that test suite) and should be run separately
when testing the system and having the below requirements available.

Requirements:
* an internet connection
* a preferences server running at `http://preferences.gpii.net` containing at least the following (unmodified) NP set: `MikelVargas`

The tests are run using the following command:

node tests/ProductionConfigTests.js
`node tests/ProductionConfigTests.js`


Building Docker Images
----------------------

The Dockerfile can be used to build a containerized version of GPII Universal, at this time primarily for use by downstream containers running components such the Preferences Server and Flow Manager in standalone cloud configuration.
The Dockerfile can be used to build a containerized version of GPII Universal, at this time primarily for use by
downstream containers running components such the Preferences Server and Flow Manager in standalone cloud configuration.

The following command can be used to build an image locally as long as it is run relative to the repository's Dockerfile:
The following command can be used to build an image locally as long as it is run relative to the repository's
`Dockerfile`:

`docker build --rm -t gpii/universal:$(git rev-parse --short HEAD) .`

That will use the Git repository's current abbreviated commit hash as a [Docker tag](https://docs.docker.com/reference/commandline/cli/#tag). If you would like to download the latest public Universal image you can use this command:
That will use the Git repository's current abbreviated commit hash as a
[Docker tag](https://docs.docker.com/reference/commandline/cli/#tag). If you would like to download the latest public
Universal image you can use this command:

`docker pull gpii/universal`

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.