Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Allow magellan to support global resource strategy. (#257)
Browse files Browse the repository at this point in the history
* mv bail into strategy category

* remove buildin reporters from code base

* init commit for resource strategy

* factory to generate strategies

* temp push

* reflow magellan cli

* add more loads/enables in cli

* clean up code base with promise

* move message system to childprocess

* remove unnecessary dependencies

* add missing piece

* apply resource strategy before worker allocation

* add logic to run resource strategy on test suite

* never resource strategy

* complete resource strategy

* fix a bug which magellan hangs

* remove deprecated code

* add test queue to manage tests

* mv mkdir_sync to util

* fix lint

* use jest and add more unit test

* add resource and bail uni test

* add test to resource strategy

* another bunch unit test update

* more unit test

* cli.test.js

* fix bug in listener initialization

* add unit test for cli.js

* add unit test instruction

* test runner test example

* fix false report

* add more test for runner

* more demo

* minor cleanup

* add unit tests

* adding more unit tests

* restructure the tests and adding new unit tests

* finish off unit tests

* add more coverage

* add test step for travis

* fix lint and upload coverage

* fix unit test

* upload test coverage

* add coverage badge
  • Loading branch information
archlichking authored Jul 5, 2018
1 parent b34cee3 commit cb6aca0
Show file tree
Hide file tree
Showing 96 changed files with 4,090 additions and 4,719 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ Session.vim
*~
# auto-generated tag files
tags

.DS_Store
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
node_js:
- v8
- v7
- v6
- v5
- v4
sudo: false
script:
- npm run lint
- npm run test
- npm run upload-coverage
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Magellan: Large-Scale Automated Testing

[![Build Status](https://travis-ci.org/TestArmada/magellan.svg?branch=master)](https://travis-ci.org/TestArmada/magellan)
[![Codecov](https://img.shields.io/codecov/c/github/codecov/example-python.svg)]()
[![codecov](https://codecov.io/gh/TestArmada/magellan/branch/master/graph/badge.svg)](https://codecov.io/gh/TestArmada/magellan)
[![Downloads](http://img.shields.io/npm/dm/testarmada-magellan.svg?style=flat)](https://npmjs.org/package/testarmada-magellan)


![image](https://cloud.githubusercontent.com/assets/12995/9419235/e2fbb4f2-480e-11e5-9de8-c6c4871890b9.png)

Magellan is a tool for massively-scaling your automated test suite, with added reliability. Run large test suites across many environments (multiple browsers or versions, or multiple native iOS or Android devices) at the same time, in parallel, with a friendly command-line workflow that is both local development and continuous-integration friendly. Magellan is compatible with `mocha` (`wd.js`, `webdriver.io`, `appium`) tests ( [example Mocha/wd project](https://github.com/TestArmada/boilerplate-mocha) ) and `Nightwatch.js` tests ( [example Nightwatch project](https://github.com/TestArmada/boilerplate-nightwatch) ), and includes [SauceLabs](http://www.saucelabs.com/) support. Through Magellan's `mocha` support, you can scale regular node.js test suites too.
Magellan is a tool for massively-scaling your automated test suite, with added reliability. Run large test suites across many environments (multiple browsers or versions, or multiple native iOS or Android devices) at the same time, in parallel, with a friendly command-line workflow that is both local development and continuous-integration friendly. Magellan is compatible with `mocha` (`wd.js`, `webdriver.io`, `appium`) tests and `Nightwatch.js` tests ( [example Nightwatch project](https://github.com/TestArmada/boilerplate-nightwatch) ), and includes third party browser provider support such as [SauceLabs](http://www.saucelabs.com/). Through Magellan's `mocha` support, you can scale regular node.js test suites too.

Features
========
Expand Down Expand Up @@ -501,6 +501,23 @@ Where `browser_profiles.json` should have a structure similar to placing `profil
}
```

Magellan's Strategies
==========================================

Since 10.1.0 magellan supports strategies. Strategy is a rule which tells magellan when to do what. There are two strategies that magellan allows for now

## Bail strategy
Bail strategy is a rule which tells magellan when to fail the whole test suite when there are certain failures in your test run, you can tell magellan to terminate your test run early via a certain bail strategy.

Current supported bail strategies: [magellan-early-bail-strategy](https://github.com/TestArmada/magellan-early-bail-strategy) and [magellan-fast-bail-strategy](https://github.com/TestArmada/magellan-fast-bail-strategy).

Please refer to the readme of each repo for more details.

## Resource strategy
Resource strategy tells magellan what to do if required resources are not available for the test.



Setting Up Setup and Teardown Tasks for CI
==========================================

Expand Down
73 changes: 58 additions & 15 deletions bin/magellan
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,66 @@

"use strict";

const yargs = require("yargs");
const co = require("co");
const argv = require("marge").argv;

const logger = require("../src/logger");
const margs = require("marge");
const cli = require("../src/cli");
const settings = require("../src/settings");
const constants = require("../src/constants");

co(function *() {
cli.version();

yield cli.loadFramework({ argv });
yield cli.loadExecutors({ argv });

const profiles = yield cli.detectProfiles({ argv, settings });
const executors = yield cli.enableExecutors({ argv, profiles });
const strategies = yield cli.loadStrategies({ argv });
const listeners = yield cli.loadListeners({ argv });

if (argv.help) {
yield cli.help({ argv });
}
// console.log(profiles)
// console.log(strategies)
// console.log(listeners)
// console.log(executors);

const tests = yield cli.loadTests({ argv });
// console.log(tests);

yield cli.startTestSuite({
argv,
tests,
profiles,
executors,
strategies,
listeners
});

// we exit magellan process by providing code directly
process.exit(0);

const defaultConfigFilePath = "./magellan.json";
const configFilePath = yargs.argv.config;
}).catch((err) => {

if (configFilePath) {
logger.log("Will try to load configuration from " + configFilePath);
} else {
logger.log("Will try to load configuration from default of " + defaultConfigFilePath);
}
switch (err.code) {
case constants.ERROR_CODE.HELP:
// hacky way to exit after help
process.exit(0);
break;

// NOTE: marge can throw an error here if --config points at a file that doesn't exist
// FIXME: handle this error nicely instead of printing an ugly stack trace
margs.init(defaultConfigFilePath, configFilePath);
case constants.ERROR_CODE.TEST_FAILURE:
// test failure
process.exit(1);
break;

require("../src/cli")()
.then(() => process.exit(0))
.catch(() => process.exit(1));
default:
logger.err(`Error while running Magellan: ${err.message}`);
logger.err(err.stack);
// we exit magellan process by providing code directly
process.exit(1);
break;
}
});
1 change: 0 additions & 1 deletion magellan.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"mocha_tests": [
"./integration"
],
"framework": "vanilla-mocha",
"max_workers": 7,
"executors": [],
"profiles": {
Expand Down
37 changes: 26 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testarmada-magellan",
"version": "10.1.1",
"version": "11.0.0",
"description": "Massively parallel automated testing",
"main": "src/main",
"directories": {
Expand All @@ -26,28 +26,25 @@
],
"license": "MIT",
"scripts": {
"test": "eslint src/** bin/** && mocha --recursive && npm run coverage && npm run check-coverage",
"dev-test": "mocha --recursive && eslint src/** bin/**",
"integration": "eslint src/** bin/** && ./bin/magellan",
"test": "jest",
"lint": "eslint src/** bin/**",
"coverage": "istanbul cover _mocha -- --recursive",
"check-coverage": "istanbul check-coverage --statement 95 --function 95 --branch 85"
"upload-coverage": "codecov"
},
"dependencies": {
"async": "^2.1.4",
"cli-color": "^1.1.0",
"co": "^4.6.0",
"glob": "^7.1.1",
"lodash": "^4.6.1",
"marge": "^1.0.1",
"node-slackr": "0.1.4",
"once": "^1.3.1",
"portscanner": "^2.1.1",
"pretty-ms": "^2.1.0",
"q": "1.4.1",
"request": "^2.55.0",
"sanitize-filename": "^1.5.3",
"slugify": "^1.0.2",
"sync-request": "^4.0.1",
"testarmada-magellan-local-executor": "^2.0.0",
"testarmada-tree-kill": "^2.0.0",
"yargs": "6.5.0"
},
Expand All @@ -61,14 +58,32 @@
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"chai": "^3.4.1",
"chai-as-promised": "^6.0.0",
"codecov": "^1.0.1",
"eslint": "^3.12.2",
"eslint-config-walmart": "^1.1.0",
"eslint-plugin-filenames": "^1.1.0",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"jest": "^22.4.3",
"sinon": "^1.17.6",
"testarmada-magellan-mocha-plugin": "^7.0.1"
},
"jest": {
"verbose": true,
"collectCoverage": true,
"coverageDirectory": "./coverage",
"coverageReporters": [
"lcov"
],
"resetMocks": true,
"testMatch": [
"**/test/**/**.test.js"
],
"coverageThreshold": {
"global": {
"statements": 90,
"branches": 80,
"functions": 90
}
}
}
}
Loading

0 comments on commit cb6aca0

Please sign in to comment.