mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-16 03:45:43 +00:00
[CI]Chaostest suite initiation (#5793)
* Initiate chaostest cli test suite: singlenodeheight on one dev node
Added chaostest stages in CI
Added new docker/k8s resources and environments to CI
Added new chaos-only tag to gitlab-ci.yml
* Update .maintain/chaostest/src/commands/singlenodeheight/index.js
Co-authored-by: Max Inden <mail@max-inden.de>
* change nameSpace to namespace(one word)
* update chaos ci job to match template
* rename build-pr ci stage to docker [chaos:basic]
* test gitlab-ci [chaos:basic]
* Update .gitlab-ci.yml
* add new build-chaos-only condition
* add *default-vars to singlenodeheight [chaos:basic]
* change build-only to build-rules on substrate jobs [chaos:basic]
* test and change when:on_success to when:always [chaos:basic]
* resolve conflicts and test [chaos:basic]
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Denis Pisarev <denis.pisarev@parity.io>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const logger = require('../utils/logger')
|
||||
|
||||
const succeedExit = function () {
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const errorExit = function (msg, err) {
|
||||
logger.error(msg, err)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
module.exports = { succeedExit, errorExit }
|
||||
@@ -0,0 +1,9 @@
|
||||
const getBootNodeUrl = (bootnode) => {
|
||||
return `/dns4/${bootnode.ip}/tcp/30333/p2p/${bootnode.peerId}`
|
||||
}
|
||||
|
||||
const isFunction = (obj) => {
|
||||
return !!(obj && obj.constructor && obj.call && obj.apply)
|
||||
}
|
||||
|
||||
module.exports = { getBootNodeUrl, isFunction }
|
||||
@@ -0,0 +1,50 @@
|
||||
const winston = require('winston')
|
||||
const fs = require('fs')
|
||||
const logDir = 'log' // Or read from a configuration
|
||||
const { format, transports } = winston
|
||||
const env = process.env.NODE_ENV || 'development'
|
||||
const util = require('util')
|
||||
|
||||
if (!fs.existsSync(logDir)) {
|
||||
// Create the directory if it does not exist
|
||||
fs.mkdirSync(logDir)
|
||||
}
|
||||
|
||||
const logFormat = format.printf(info => {
|
||||
info.message = util.format(info.message)
|
||||
if (info.metadata && Object.keys(info.metadata).length) {
|
||||
info.message = util.format(info.message, info.metadata)
|
||||
}
|
||||
return `${info.timestamp} ${info.level}: ${info.message}`
|
||||
})
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: env === 'development' ? 'debug' : 'info',
|
||||
transports: [
|
||||
new transports.Console({
|
||||
format: format.combine(
|
||||
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
||||
// Format the metadata object
|
||||
format.metadata({ fillExcept: ['message', 'level', 'timestamp', 'label'] }),
|
||||
format.colorize(),
|
||||
logFormat
|
||||
)
|
||||
}),
|
||||
new winston.transports.File({
|
||||
level: env === 'development' ? 'debug' : 'info',
|
||||
filename: logDir + '/logs.log',
|
||||
format: format.combine(
|
||||
format.timestamp(),
|
||||
format.json()
|
||||
),
|
||||
maxsize: 1024 * 1024 * 10 // 10MB
|
||||
})
|
||||
],
|
||||
exceptionHandlers: [
|
||||
new winston.transports.File({
|
||||
filename: 'log/exceptions.log'
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
module.exports = logger
|
||||
@@ -0,0 +1,32 @@
|
||||
const logger = require('./logger')
|
||||
/**
|
||||
* Wait n milliseconds
|
||||
*
|
||||
* @param n - In milliseconds
|
||||
*/
|
||||
function waitNMilliseconds (n) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, n)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a function until that function correctly resolves
|
||||
*
|
||||
* @param fn - The function to run
|
||||
*/
|
||||
async function pollUntil (fn) {
|
||||
try {
|
||||
const result = await fn()
|
||||
|
||||
return result
|
||||
} catch (_error) {
|
||||
logger.error('Error polling', _error)
|
||||
logger.debug('awaiting...')
|
||||
await waitNMilliseconds(5000) // FIXME We can add exponential delay here
|
||||
|
||||
return pollUntil(fn)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { pollUntil, waitNMilliseconds }
|
||||
Reference in New Issue
Block a user