forked from openstf/stf
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fd750d
commit 7f5dc4c
Showing
119 changed files
with
12,491 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 | ||
**/ | ||
|
||
module.exports.command = 'generate-fake-group' | ||
|
||
module.exports.builder = function(yargs) { | ||
return yargs | ||
.strict() | ||
.option('n', { | ||
alias: 'number' | ||
, describe: 'How many groups to create.' | ||
, type: 'number' | ||
, default: 1 | ||
}) | ||
} | ||
|
||
module.exports.handler = function(argv) { | ||
var logger = require('../../util/logger') | ||
var log = logger.createLogger('cli:generate-fake-group') | ||
var fake = require('../../util/fakegroup') | ||
var n = argv.number | ||
|
||
function next() { | ||
return fake.generate().then(function(email) { | ||
log.info('Created fake group "%s"', email) | ||
return --n ? next() : null | ||
}) | ||
} | ||
|
||
return next() | ||
.then(function() { | ||
process.exit(0) | ||
}) | ||
.catch(function(err) { | ||
log.fatal('Fake group creation had an error:', err.stack) | ||
process.exit(1) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 | ||
**/ | ||
|
||
module.exports.command = 'generate-fake-user' | ||
|
||
module.exports.builder = function(yargs) { | ||
return yargs | ||
.strict() | ||
.option('n', { | ||
alias: 'number' | ||
, describe: 'How many users to create.' | ||
, type: 'number' | ||
, default: 1 | ||
}) | ||
} | ||
|
||
module.exports.handler = function(argv) { | ||
var logger = require('../../util/logger') | ||
var log = logger.createLogger('cli:generate-fake-user') | ||
var fake = require('../../util/fakeuser') | ||
var n = argv.number | ||
|
||
function next() { | ||
return fake.generate().then(function(email) { | ||
log.info('Created fake user "%s"', email) | ||
return --n ? next() : null | ||
}) | ||
} | ||
|
||
return next() | ||
.then(function() { | ||
process.exit(0) | ||
}) | ||
.catch(function(err) { | ||
log.fatal('Fake user creation had an error:', err.stack) | ||
process.exit(1) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 | ||
**/ | ||
|
||
module.exports.command = 'groups-engine' | ||
|
||
module.exports.describe = 'Start the groups engine unit.' | ||
|
||
module.exports.builder = function(yargs) { | ||
return yargs | ||
.env('STF_GROUPS_ENGINE') | ||
.strict() | ||
.option('connect-push', { | ||
alias: 'c' | ||
, describe: 'App-side ZeroMQ PULL endpoint to connect to.' | ||
, array: true | ||
, demand: true | ||
}) | ||
.option('connect-sub', { | ||
alias: 'u' | ||
, describe: 'App-side ZeroMQ PUB endpoint to connect to.' | ||
, array: true | ||
, demand: true | ||
}) | ||
.option('connect-push-dev', { | ||
alias: 'pd' | ||
, describe: 'Device-side ZeroMQ PULL endpoint to connect to.' | ||
, array: true | ||
, demand: true | ||
}) | ||
.option('connect-sub-dev', { | ||
alias: 'sd' | ||
, describe: 'Device-side ZeroMQ PUB endpoint to connect to.' | ||
, array: true | ||
, demand: true | ||
}) | ||
.epilog('Each option can be be overwritten with an environment variable ' + | ||
'by converting the option to uppercase, replacing dashes with ' + | ||
'underscores and prefixing it with `STF_GROUPS_ENGINE_` .)') | ||
} | ||
|
||
module.exports.handler = function(argv) { | ||
return require('../../units/groups-engine')({ | ||
endpoints: { | ||
push: argv.connectPush | ||
, sub: argv.connectSub | ||
, pushdev: argv.connectPushDev | ||
, subdev: argv.connectSubDev | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 | ||
**/ | ||
|
||
module.exports.command = 'migrate' | ||
|
||
module.exports.describe = 'Migrates the database to the latest version.' | ||
|
@@ -10,13 +14,44 @@ module.exports.handler = function() { | |
var logger = require('../../util/logger') | ||
var log = logger.createLogger('cli:migrate') | ||
var db = require('../../db') | ||
var dbapi = require('../../db/api') | ||
const apiutil = require('../../util/apiutil') | ||
const Promise = require('bluebird') | ||
|
||
return db.setup() | ||
.then(function() { | ||
process.exit(0) | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(function() { | ||
return dbapi.getGroupByIndex(apiutil.ROOT, 'privilege').then(function(group) { | ||
if (!group) { | ||
const env = { | ||
STF_ROOT_GROUP_NAME: 'Common' | ||
, STF_ADMIN_NAME: 'administrator' | ||
, STF_ADMIN_EMAIL: '[email protected]' | ||
} | ||
for (const i in env) { | ||
if (process.env[i]) { | ||
env[i] = process.env[i] | ||
} | ||
} | ||
return dbapi.createBootStrap(env) | ||
} | ||
return group | ||
}) | ||
.then(function() { | ||
resolve(true) | ||
}) | ||
.catch(function(err) { | ||
reject(err) | ||
}) | ||
}, 1000) | ||
}) | ||
}) | ||
.catch(function(err) { | ||
log.fatal('Migration had an error:', err.stack) | ||
process.exit(1) | ||
}) | ||
.finally(function() { | ||
process.exit(0) | ||
}) | ||
} |
Oops, something went wrong.