How to use logStub method in stryker-parent

Best JavaScript code snippet using stryker-parent

error_handling_spec.js

Source:error_handling_spec.js Github

copy

Full Screen

1/*globals describe, before, beforeEach, afterEach, it*/2/*jshint expr:true*/3var should = require('should'),4 Promise = require('bluebird'),5 sinon = require('sinon'),6 express = require('express'),7 rewire = require('rewire'),8 _ = require('lodash'),9 // Stuff we are testing10 chalk = require('chalk'),11 config = rewire('../../server/config'),12 errors = rewire('../../server/errors'),13 // storing current environment14 currentEnv = process.env.NODE_ENV;15describe('Error handling', function () {16 // Just getting rid of jslint unused error17 should.exist(errors);18 describe('Throwing', function () {19 it('throws error objects', function () {20 var toThrow = new Error('test1'),21 runThrowError = function () {22 errors.throwError(toThrow);23 };24 runThrowError.should['throw']('test1');25 });26 it('throws error strings', function () {27 var toThrow = 'test2',28 runThrowError = function () {29 errors.throwError(toThrow);30 };31 runThrowError.should['throw']('test2');32 });33 it('throws error even if nothing passed', function () {34 var runThrowError = function () {35 errors.throwError();36 };37 runThrowError.should['throw']('An error occurred');38 });39 });40 describe('Warn Logging', function () {41 var logStub,42 // Can't use afterEach here, because mocha uses console.log to output the checkboxes43 // which we've just stubbed, so we need to restore it before the test ends to see ticks.44 resetEnvironment = function () {45 logStub.restore();46 process.env.NODE_ENV = currentEnv;47 };48 beforeEach(function () {49 logStub = sinon.stub(console, 'log');50 process.env.NODE_ENV = 'development';51 });52 afterEach(function () {53 logStub.restore();54 });55 it('logs default warn with no message supplied', function () {56 errors.logWarn();57 logStub.calledOnce.should.be.true;58 logStub.calledWith(59 chalk.yellow('\nWarning: no message supplied'), '\n');60 // Future tests: This is important here!61 resetEnvironment();62 });63 it('logs warn with only message', function () {64 var errorText = 'Error1';65 errors.logWarn(errorText);66 logStub.calledOnce.should.be.true;67 logStub.calledWith(chalk.yellow('\nWarning: ' + errorText), '\n');68 // Future tests: This is important here!69 resetEnvironment();70 });71 it('logs warn with message and context', function () {72 var errorText = 'Error1',73 contextText = 'Context1';74 errors.logWarn(errorText, contextText);75 logStub.calledOnce.should.be.true;76 logStub.calledWith(77 chalk.yellow('\nWarning: ' + errorText), '\n', chalk.white(contextText), '\n'78 );79 // Future tests: This is important here!80 resetEnvironment();81 });82 it('logs warn with message and context and help', function () {83 var errorText = 'Error1',84 contextText = 'Context1',85 helpText = 'Help1';86 errors.logWarn(errorText, contextText, helpText);87 logStub.calledOnce.should.be.true;88 logStub.calledWith(89 chalk.yellow('\nWarning: ' + errorText), '\n', chalk.white(contextText), '\n', chalk.green(helpText), '\n'90 );91 // Future tests: This is important here!92 resetEnvironment();93 });94 });95 describe('Error Logging', function () {96 var logStub;97 beforeEach(function () {98 logStub = sinon.stub(console, 'error');99 // give environment a value that will console log100 process.env.NODE_ENV = 'development';101 });102 afterEach(function () {103 logStub.restore();104 // reset the environment105 process.env.NODE_ENV = currentEnv;106 });107 it('logs errors from error objects', function () {108 var err = new Error('test1');109 errors.logError(err);110 // Calls log with message on Error objects111 logStub.calledOnce.should.be.true;112 logStub.calledWith(chalk.red('\nERROR:', err.message), '\n', '\n', err.stack, '\n').should.be.true;113 });114 it('logs errors from strings', function () {115 var err = 'test2';116 errors.logError(err);117 // Calls log with string on strings118 logStub.calledOnce.should.be.true;119 logStub.calledWith(chalk.red('\nERROR:', err), '\n').should.be.true;120 });121 it('logs errors from an error object and two string arguments', function () {122 var err = new Error('test1'),123 message = 'Testing';124 errors.logError(err, message, message);125 // Calls log with message on Error objects126 logStub.calledOnce.should.be.true;127 logStub.calledWith(128 chalk.red('\nERROR:', err.message), '\n', chalk.white(message), '\n', chalk.green(message), '\n', err.stack, '\n'129 );130 });131 it('logs errors from three string arguments', function () {132 var message = 'Testing';133 errors.logError(message, message, message);134 // Calls log with message on Error objects135 logStub.calledOnce.should.be.true;136 logStub.calledWith(137 chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n', chalk.green(message), '\n'138 ).should.be.true;139 });140 it('logs errors from an undefined error argument', function () {141 var message = 'Testing';142 errors.logError(undefined, message, message);143 // Calls log with message on Error objects144 logStub.calledOnce.should.be.true;145 logStub.calledWith(146 chalk.red('\nERROR:', 'An unknown error occurred.'), '\n', chalk.white(message), '\n', chalk.green(message), '\n'147 ).should.be.true;148 });149 it('logs errors from an undefined context argument', function () {150 var message = 'Testing';151 errors.logError(message, undefined, message);152 // Calls log with message on Error objects153 logStub.calledOnce.should.be.true;154 logStub.calledWith(chalk.red('\nERROR:', message), '\n', chalk.green(message), '\n').should.be.true;155 });156 it('logs errors from an undefined help argument', function () {157 var message = 'Testing';158 errors.logError(message, message, undefined);159 // Calls log with message on Error objects160 logStub.calledOnce.should.be.true;161 logStub.calledWith(chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n').should.be.true;162 });163 it('logs errors from a null error argument', function () {164 var message = 'Testing';165 errors.logError(null, message, message);166 // Calls log with message on Error objects167 logStub.calledOnce.should.be.true;168 logStub.calledWith(169 chalk.red('\nERROR:', 'An unknown error occurred.'), '\n', chalk.white(message), '\n', chalk.green(message), '\n'170 ).should.be.true;171 });172 it('logs errors from a null context argument', function () {173 var message = 'Testing';174 errors.logError(message, null, message);175 // Calls log with message on Error objects176 logStub.calledOnce.should.be.true;177 logStub.firstCall.calledWith(chalk.red('\nERROR:', message), '\n', chalk.green(message), '\n').should.be.true;178 });179 it('logs errors from a null help argument', function () {180 var message = 'Testing';181 errors.logError(message, message, null);182 // Calls log with message on Error objects183 logStub.calledOnce.should.be.true;184 logStub.firstCall.calledWith(chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n').should.be.true;185 });186 it('logs promise errors and redirects', function (done) {187 var req = null,188 res = {189 redirect: function () {190 return;191 }192 },193 redirectStub = sinon.stub(res, 'redirect');194 // give environment a value that will console log195 Promise.reject().then(function () {196 throw new Error('Ran success handler');197 }, errors.logErrorWithRedirect('test1', null, null, '/testurl', req, res));198 Promise.reject().catch(function () {199 logStub.calledWith(chalk.red('\nERROR:', 'test1')).should.equal(true);200 logStub.restore();201 redirectStub.calledWith('/testurl').should.equal(true);202 redirectStub.restore();203 done();204 });205 });206 });207 describe('Rendering', function () {208 var sandbox,209 originalConfig;210 before(function () {211 originalConfig = _.cloneDeep(config._config);212 errors.__set__('getConfigModule', sinon.stub().returns(_.merge({}, originalConfig, {213 paths: {214 themePath: '/content/themes',215 availableThemes: {216 casper: {217 assets: null,218 'default.hbs': '/content/themes/casper/default.hbs',219 'index.hbs': '/content/themes/casper/index.hbs',220 'page.hbs': '/content/themes/casper/page.hbs',221 'tag.hbs': '/content/themes/casper/tag.hbs'222 },223 'theme-with-error': {224 'error.hbs': ''225 }226 }227 }228 })));229 errors.updateActiveTheme('casper');230 });231 beforeEach(function () {232 sandbox = sinon.sandbox.create();233 });234 afterEach(function () {235 sandbox.restore();236 });237 it('Renders end-of-middleware 404 errors correctly', function (done) {238 var req = {method: 'GET'},239 res = express.response;240 sandbox.stub(express.response, 'render', function (view, options, fn) {241 /*jshint unused:false */242 view.should.match(/user-error\.hbs/);243 // Test that the message is correct244 options.message.should.equal('Page not found');245 options.code.should.equal(404);246 this.statusCode.should.equal(404);247 done();248 });249 sandbox.stub(express.response, 'status', function (status) {250 res.statusCode = status;251 return res;252 });253 sandbox.stub(res, 'set', function (value) {254 // Test that the headers are correct255 value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');256 return res;257 });258 errors.error404(req, res, done);259 });260 it('Renders thrown 404 errors correctly', function (done) {261 var err = new Error('A thing was not found'),262 req = {method: 'GET'},263 res = express.response;264 sandbox.stub(express.response, 'render', function (view, options, fn) {265 /*jshint unused:false */266 view.should.match(/user-error\.hbs/);267 // Test that the message is correct268 options.message.should.equal('Page not found');269 options.code.should.equal(404);270 this.statusCode.should.equal(404);271 done();272 });273 sandbox.stub(express.response, 'status', function (status) {274 res.statusCode = status;275 return res;276 });277 sandbox.stub(res, 'set', function (value) {278 // Test that the headers are correct279 value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');280 return res;281 });282 err.status = 404;283 errors.error500(err, req, res, null);284 });285 it('Renders thrown errors correctly', function (done) {286 var err = new Error('I am a big bad error'),287 req = {method: 'GET'},288 res = express.response;289 sandbox.stub(express.response, 'render', function (view, options, fn) {290 /*jshint unused:false */291 view.should.match(/user-error\.hbs/);292 // Test that the message is correct293 options.message.should.equal('I am a big bad error');294 options.code.should.equal(500);295 this.statusCode.should.equal(500);296 done();297 });298 sandbox.stub(res, 'set', function (value) {299 // Test that the headers are correct300 value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');301 return res;302 });303 sandbox.stub(express.response, 'status', function (status) {304 res.statusCode = status;305 return res;306 });307 errors.error500(err, req, res, null);308 });309 it('Renders 500 errors correctly', function (done) {310 var err = new Error('I am a big bad error'),311 req = {method: 'GET'},312 res = express.response;313 sandbox.stub(express.response, 'render', function (view, options, fn) {314 /*jshint unused:false */315 view.should.match(/user-error\.hbs/);316 // Test that the message is correct317 options.message.should.equal('I am a big bad error');318 options.code.should.equal(500);319 this.statusCode.should.equal(500);320 done();321 });322 sandbox.stub(express.response, 'status', function (status) {323 res.statusCode = status;324 return res;325 });326 sandbox.stub(res, 'set', function (value) {327 // Test that the headers are correct328 value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');329 return res;330 });331 err.code = 500;332 errors.error500(err, req, res, null);333 });334 it('Renders custom error template if one exists', function (done) {335 var code = 404,336 error = {message: 'Custom view test'},337 req = {338 session: null339 },340 res = {341 status: function (code) {342 /*jshint unused:false*/343 return this;344 },345 render: function (view, model, fn) {346 /*jshint unused:false*/347 view.should.eql('error');348 errors.updateActiveTheme('casper');349 done();350 }351 },352 next = null;353 errors.updateActiveTheme('theme-with-error');354 errors.renderErrorPage(code, error, req, res, next);355 });356 });...

Full Screen

Full Screen

flag_supported_clusters.js

Source:flag_supported_clusters.js Github

copy

Full Screen

1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import expect from '@kbn/expect';7import sinon from 'sinon';8import { flagSupportedClusters } from '../flag_supported_clusters';9const mockReq = (log, queryResult = {}) => {10 return {11 server: {12 config() {13 return {14 get: sinon.stub()15 .withArgs('server.uuid').returns('kibana-1234')16 };17 },18 plugins: {19 elasticsearch: {20 getCluster() {21 return {22 callWithRequest() { return Promise.resolve(queryResult); }23 };24 }25 }26 },27 log28 },29 payload: {30 timeRange: { min: -Infinity, max: Infinity }31 }32 };33};34const goldLicense = () => ({ license: { type: 'gold' } });35const basicLicense = () => ({ license: { type: 'basic' } });36const standaloneCluster = () => ({ cluster_uuid: '__standalone_cluster__' });37describe('Flag Supported Clusters', () => {38 describe('With multiple clusters in the monitoring data', () => {39 it('When all clusters are non-Basic licensed, all are supported', () => {40 const logStub = sinon.stub();41 const req = mockReq(logStub);42 const kbnIndices = [];43 const clusters = [44 goldLicense(),45 { }, // no license46 goldLicense()47 ];48 // pass 2 gold license clusters and check they all become flagged as supported49 return flagSupportedClusters(req, kbnIndices)(clusters)50 .then(resultClusters => {51 expect(resultClusters).to.eql([52 { ...goldLicense(), isSupported: true },53 { }, // no license54 { ...goldLicense(), isSupported: true }55 ]);56 sinon.assert.calledWith(57 logStub,58 ['debug', 'monitoring-ui', 'supported-clusters'],59 'Found all non-basic cluster licenses. All clusters will be supported.'60 );61 });62 });63 it('When all clusters are Basic licensed, admin cluster is supported', () => {64 // uses a an object for callWithRequest query result to match the cluster we want to be supported65 const logStub = sinon.stub();66 const req = mockReq(logStub, {67 hits: {68 hits: [ { _source: { cluster_uuid: 'supported_cluster_uuid' } } ]69 }70 });71 const kbnIndices = [];72 const clusters = [73 { cluster_uuid: 'supported_cluster_uuid', ...basicLicense() },74 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() }75 ];76 // pass 2 basic license clusters and check the intended cluster is flagged as supported77 return flagSupportedClusters(req, kbnIndices)(clusters)78 .then(resultClusters => {79 expect(resultClusters).to.eql([80 {81 cluster_uuid: 'supported_cluster_uuid',82 isSupported: true,83 ...basicLicense()84 },85 {86 cluster_uuid: 'unsupported_cluster_uuid',87 ...basicLicense()88 }89 ]);90 sinon.assert.calledWith(91 logStub,92 ['debug', 'monitoring-ui', 'supported-clusters'],93 'Detected all clusters in monitoring data have basic license. Checking for supported admin cluster UUID for Kibana kibana-1234.'94 );95 sinon.assert.calledWith(96 logStub,97 ['debug', 'monitoring-ui', 'supported-clusters'],98 'Found basic license admin cluster UUID for Monitoring UI support: supported_cluster_uuid.'99 );100 });101 });102 it('When some clusters are Basic licensed, only non-Basic licensed clusters are supported', () => {103 const logStub = sinon.stub();104 const req = mockReq(logStub);105 const kbnIndices = [];106 const clusters = [107 { cluster_uuid: 'supported_cluster_uuid_1', ...goldLicense() },108 { cluster_uuid: 'supported_cluster_uuid_2', ...goldLicense() },109 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() }110 ];111 // pass 2 various-license clusters and check the intended clusters are flagged as supported112 return flagSupportedClusters(req, kbnIndices)(clusters)113 .then(resultClusters => {114 expect(resultClusters).to.eql([115 {116 cluster_uuid: 'supported_cluster_uuid_1',117 isSupported: true,118 ...goldLicense()119 },120 {121 cluster_uuid: 'supported_cluster_uuid_2',122 isSupported: true,123 ...goldLicense()124 },125 {126 cluster_uuid: 'unsupported_cluster_uuid',127 ...basicLicense()128 }129 ]);130 sinon.assert.calledWith(131 logStub,132 ['debug', 'monitoring-ui', 'supported-clusters'],133 'Found some basic license clusters in monitoring data. Only non-basic will be supported.'134 );135 });136 });137 describe('involving an standalone cluster', () => {138 it('should ignore the standalone cluster in calculating supported basic clusters', () => {139 const logStub = sinon.stub();140 const req = mockReq(logStub, {141 hits: {142 hits: [ { _source: { cluster_uuid: 'supported_cluster_uuid' } } ]143 }144 });145 const kbnIndices = [];146 const clusters = [147 { cluster_uuid: 'supported_cluster_uuid', ...basicLicense() },148 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },149 { ...standaloneCluster() }150 ];151 return flagSupportedClusters(req, kbnIndices)(clusters)152 .then(resultClusters => {153 expect(resultClusters).to.eql([154 {155 cluster_uuid: 'supported_cluster_uuid',156 isSupported: true,157 ...basicLicense()158 },159 {160 cluster_uuid: 'unsupported_cluster_uuid',161 ...basicLicense()162 },163 {164 ...standaloneCluster(),165 isSupported: true,166 }167 ]);168 sinon.assert.calledWith(169 logStub,170 ['debug', 'monitoring-ui', 'supported-clusters'],171 'Found basic license admin cluster UUID for Monitoring UI support: supported_cluster_uuid.'172 );173 });174 });175 it('should ignore the standalone cluster in calculating supported mixed license clusters', () => {176 const logStub = sinon.stub();177 const req = mockReq(logStub);178 const kbnIndices = [];179 const clusters = [180 { cluster_uuid: 'supported_cluster_uuid', ...goldLicense() },181 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },182 { ...standaloneCluster() }183 ];184 return flagSupportedClusters(req, kbnIndices)(clusters)185 .then(resultClusters => {186 expect(resultClusters).to.eql([187 {188 cluster_uuid: 'supported_cluster_uuid',189 isSupported: true,190 ...goldLicense()191 },192 {193 cluster_uuid: 'unsupported_cluster_uuid',194 ...basicLicense()195 },196 {197 ...standaloneCluster(),198 isSupported: true,199 }200 ]);201 sinon.assert.calledWith(202 logStub,203 ['debug', 'monitoring-ui', 'supported-clusters'],204 'Found some basic license clusters in monitoring data. Only non-basic will be supported.'205 );206 });207 });208 it('should ignore the standalone cluster in calculating supported non-basic clusters', () => {209 const logStub = sinon.stub();210 const req = mockReq(logStub);211 const kbnIndices = [];212 const clusters = [213 { cluster_uuid: 'supported_cluster_uuid_1', ...goldLicense() },214 { cluster_uuid: 'supported_cluster_uuid_2', ...goldLicense() },215 { ...standaloneCluster() }216 ];217 return flagSupportedClusters(req, kbnIndices)(clusters)218 .then(resultClusters => {219 expect(resultClusters).to.eql([220 {221 cluster_uuid: 'supported_cluster_uuid_1',222 isSupported: true,223 ...goldLicense()224 },225 {226 cluster_uuid: 'supported_cluster_uuid_2',227 isSupported: true,228 ...goldLicense()229 },230 {231 ...standaloneCluster(),232 isSupported: true,233 }234 ]);235 sinon.assert.calledWith(236 logStub,237 ['debug', 'monitoring-ui', 'supported-clusters'],238 'Found all non-basic cluster licenses. All clusters will be supported.'239 );240 });241 });242 });243 });244 describe('With single cluster in the monitoring data', () => {245 let logStub;246 beforeEach(() => logStub = sinon.stub());247 it('When there is a single Basic-licensed cluster in the data, it is supported', () => {248 const req = mockReq(logStub);249 const kbnIndices = [];250 const clusters = [{ ...basicLicense() }];251 return flagSupportedClusters(req, kbnIndices)(clusters)252 .then(result => {253 expect(result).to.eql([254 { isSupported: true, ...basicLicense() }255 ]);256 sinon.assert.calledWith(257 logStub,258 ['debug', 'monitoring-ui', 'supported-clusters'],259 'Found single cluster in monitoring data.'260 );261 });262 });263 it('When there is a single Gold-licensed cluster in the data, it is supported', () => {264 const req = mockReq(logStub);265 const kbnIndices = [];266 const clusters = [{ ...goldLicense() }];267 return flagSupportedClusters(req, kbnIndices)(clusters)268 .then(result => {269 expect(result).to.eql([270 { isSupported: true, ...goldLicense() }271 ]);272 sinon.assert.calledWith(273 logStub,274 ['debug', 'monitoring-ui', 'supported-clusters'],275 'Found single cluster in monitoring data.'276 );277 });278 });279 it('When there is a deleted-license cluster in the data, it is NOT supported', () => {280 const req = mockReq(logStub);281 const kbnIndices = [];282 const deletedLicense = () => ({ license: null });283 const clusters = [{ ...deletedLicense() }];284 return flagSupportedClusters(req, kbnIndices)(clusters)285 .then(result => {286 expect(result).to.eql([287 { ...deletedLicense() }288 ]);289 sinon.assert.calledWith(290 logStub,291 ['debug', 'monitoring-ui', 'supported-clusters'],292 'Found single cluster in monitoring data.'293 );294 });295 });296 describe('involving an standalone cluster', () => {297 it('should ensure it is supported', () => {298 const req = mockReq(logStub);299 const kbnIndices = [];300 const clusters = [{ ...standaloneCluster() }];301 return flagSupportedClusters(req, kbnIndices)(clusters)302 .then(result => {303 expect(result).to.eql([304 { ...standaloneCluster(), isSupported: true, }305 ]);306 sinon.assert.calledWith(307 logStub,308 ['debug', 'monitoring-ui', 'supported-clusters'],309 'Found single cluster in monitoring data.'310 );311 });312 });313 });314 });...

Full Screen

Full Screen

flag_supported_clusters.test.js

Source:flag_supported_clusters.test.js Github

copy

Full Screen

1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import sinon from 'sinon';7import { flagSupportedClusters } from './flag_supported_clusters';8const mockReq = (log, queryResult = {}) => {9 return {10 server: {11 config() {12 return {13 get: sinon.stub().withArgs('server.uuid').returns('kibana-1234'),14 };15 },16 plugins: {17 elasticsearch: {18 getCluster() {19 return {20 callWithRequest() {21 return Promise.resolve(queryResult);22 },23 };24 },25 },26 },27 log,28 },29 payload: {30 timeRange: { min: -Infinity, max: Infinity },31 },32 };33};34const goldLicense = () => ({ license: { type: 'gold' } });35const basicLicense = () => ({ license: { type: 'basic' } });36const standaloneCluster = () => ({ cluster_uuid: '__standalone_cluster__' });37// TODO: tests were not being run and are not up to date38describe.skip('Flag Supported Clusters', () => {39 describe('With multiple clusters in the monitoring data', () => {40 it('When all clusters are non-Basic licensed, all are supported', () => {41 const logStub = sinon.stub();42 const req = mockReq(logStub);43 const kbnIndices = [];44 const clusters = [45 goldLicense(),46 {}, // no license47 goldLicense(),48 ];49 // pass 2 gold license clusters and check they all become flagged as supported50 return flagSupportedClusters(51 req,52 kbnIndices53 )(clusters).then((resultClusters) => {54 expect(resultClusters).toEqual([55 { ...goldLicense(), isSupported: true },56 {}, // no license57 { ...goldLicense(), isSupported: true },58 ]);59 sinon.assert.calledWith(60 logStub,61 ['debug', 'monitoring', 'supported-clusters'],62 'Found all non-basic cluster licenses. All clusters will be supported.'63 );64 });65 });66 it('When all clusters are Basic licensed, admin cluster is supported', () => {67 // uses a an object for callWithRequest query result to match the cluster we want to be supported68 const logStub = sinon.stub();69 const req = mockReq(logStub, {70 hits: {71 hits: [{ _source: { cluster_uuid: 'supported_cluster_uuid' } }],72 },73 });74 const kbnIndices = [];75 const clusters = [76 { cluster_uuid: 'supported_cluster_uuid', ...basicLicense() },77 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },78 ];79 // pass 2 basic license clusters and check the intended cluster is flagged as supported80 return flagSupportedClusters(81 req,82 kbnIndices83 )(clusters).then((resultClusters) => {84 expect(resultClusters).toEqual([85 {86 cluster_uuid: 'supported_cluster_uuid',87 isSupported: true,88 ...basicLicense(),89 },90 {91 cluster_uuid: 'unsupported_cluster_uuid',92 ...basicLicense(),93 },94 ]);95 sinon.assert.calledWith(96 logStub,97 ['debug', 'monitoring', 'supported-clusters'],98 'Detected all clusters in monitoring data have basic license. Checking for supported admin cluster UUID for Kibana kibana-1234.'99 );100 sinon.assert.calledWith(101 logStub,102 ['debug', 'monitoring', 'supported-clusters'],103 'Found basic license admin cluster UUID for Monitoring UI support: supported_cluster_uuid.'104 );105 });106 });107 it('When some clusters are Basic licensed, only non-Basic licensed clusters are supported', () => {108 const logStub = sinon.stub();109 const req = mockReq(logStub);110 const kbnIndices = [];111 const clusters = [112 { cluster_uuid: 'supported_cluster_uuid_1', ...goldLicense() },113 { cluster_uuid: 'supported_cluster_uuid_2', ...goldLicense() },114 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },115 ];116 // pass 2 various-license clusters and check the intended clusters are flagged as supported117 return flagSupportedClusters(118 req,119 kbnIndices120 )(clusters).then((resultClusters) => {121 expect(resultClusters).toEqual([122 {123 cluster_uuid: 'supported_cluster_uuid_1',124 isSupported: true,125 ...goldLicense(),126 },127 {128 cluster_uuid: 'supported_cluster_uuid_2',129 isSupported: true,130 ...goldLicense(),131 },132 {133 cluster_uuid: 'unsupported_cluster_uuid',134 ...basicLicense(),135 },136 ]);137 sinon.assert.calledWith(138 logStub,139 ['debug', 'monitoring', 'supported-clusters'],140 'Found some basic license clusters in monitoring data. Only non-basic will be supported.'141 );142 });143 });144 describe('involving an standalone cluster', () => {145 it('should ignore the standalone cluster in calculating supported basic clusters', () => {146 const logStub = sinon.stub();147 const req = mockReq(logStub, {148 hits: {149 hits: [{ _source: { cluster_uuid: 'supported_cluster_uuid' } }],150 },151 });152 const kbnIndices = [];153 const clusters = [154 { cluster_uuid: 'supported_cluster_uuid', ...basicLicense() },155 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },156 { ...standaloneCluster() },157 ];158 return flagSupportedClusters(159 req,160 kbnIndices161 )(clusters).then((resultClusters) => {162 expect(resultClusters).toEqual([163 {164 cluster_uuid: 'supported_cluster_uuid',165 isSupported: true,166 ...basicLicense(),167 },168 {169 cluster_uuid: 'unsupported_cluster_uuid',170 ...basicLicense(),171 },172 {173 ...standaloneCluster(),174 isSupported: true,175 },176 ]);177 sinon.assert.calledWith(178 logStub,179 ['debug', 'monitoring', 'supported-clusters'],180 'Found basic license admin cluster UUID for Monitoring UI support: supported_cluster_uuid.'181 );182 });183 });184 it('should ignore the standalone cluster in calculating supported mixed license clusters', () => {185 const logStub = sinon.stub();186 const req = mockReq(logStub);187 const kbnIndices = [];188 const clusters = [189 { cluster_uuid: 'supported_cluster_uuid', ...goldLicense() },190 { cluster_uuid: 'unsupported_cluster_uuid', ...basicLicense() },191 { ...standaloneCluster() },192 ];193 return flagSupportedClusters(194 req,195 kbnIndices196 )(clusters).then((resultClusters) => {197 expect(resultClusters).toEqual([198 {199 cluster_uuid: 'supported_cluster_uuid',200 isSupported: true,201 ...goldLicense(),202 },203 {204 cluster_uuid: 'unsupported_cluster_uuid',205 ...basicLicense(),206 },207 {208 ...standaloneCluster(),209 isSupported: true,210 },211 ]);212 sinon.assert.calledWith(213 logStub,214 ['debug', 'monitoring', 'supported-clusters'],215 'Found some basic license clusters in monitoring data. Only non-basic will be supported.'216 );217 });218 });219 it('should ignore the standalone cluster in calculating supported non-basic clusters', () => {220 const logStub = sinon.stub();221 const req = mockReq(logStub);222 const kbnIndices = [];223 const clusters = [224 { cluster_uuid: 'supported_cluster_uuid_1', ...goldLicense() },225 { cluster_uuid: 'supported_cluster_uuid_2', ...goldLicense() },226 { ...standaloneCluster() },227 ];228 return flagSupportedClusters(229 req,230 kbnIndices231 )(clusters).then((resultClusters) => {232 expect(resultClusters).toEqual([233 {234 cluster_uuid: 'supported_cluster_uuid_1',235 isSupported: true,236 ...goldLicense(),237 },238 {239 cluster_uuid: 'supported_cluster_uuid_2',240 isSupported: true,241 ...goldLicense(),242 },243 {244 ...standaloneCluster(),245 isSupported: true,246 },247 ]);248 sinon.assert.calledWith(249 logStub,250 ['debug', 'monitoring', 'supported-clusters'],251 'Found all non-basic cluster licenses. All clusters will be supported.'252 );253 });254 });255 });256 });257 describe('With single cluster in the monitoring data', () => {258 let logStub;259 beforeEach(() => (logStub = sinon.stub()));260 it('When there is a single Basic-licensed cluster in the data, it is supported', () => {261 const req = mockReq(logStub);262 const kbnIndices = [];263 const clusters = [{ ...basicLicense() }];264 return flagSupportedClusters(265 req,266 kbnIndices267 )(clusters).then((result) => {268 expect(result).toEqual([{ isSupported: true, ...basicLicense() }]);269 sinon.assert.calledWith(270 logStub,271 ['debug', 'monitoring', 'supported-clusters'],272 'Found single cluster in monitoring data.'273 );274 });275 });276 it('When there is a single Gold-licensed cluster in the data, it is supported', () => {277 const req = mockReq(logStub);278 const kbnIndices = [];279 const clusters = [{ ...goldLicense() }];280 return flagSupportedClusters(281 req,282 kbnIndices283 )(clusters).then((result) => {284 expect(result).toEqual([{ isSupported: true, ...goldLicense() }]);285 sinon.assert.calledWith(286 logStub,287 ['debug', 'monitoring', 'supported-clusters'],288 'Found single cluster in monitoring data.'289 );290 });291 });292 it('When there is a deleted-license cluster in the data, it is NOT supported', () => {293 const req = mockReq(logStub);294 const kbnIndices = [];295 const deletedLicense = () => ({ license: null });296 const clusters = [{ ...deletedLicense() }];297 return flagSupportedClusters(298 req,299 kbnIndices300 )(clusters).then((result) => {301 expect(result).toEqual([{ ...deletedLicense() }]);302 sinon.assert.calledWith(303 logStub,304 ['debug', 'monitoring', 'supported-clusters'],305 'Found single cluster in monitoring data.'306 );307 });308 });309 describe('involving an standalone cluster', () => {310 it('should ensure it is supported', () => {311 const req = mockReq(logStub);312 const kbnIndices = [];313 const clusters = [{ ...standaloneCluster() }];314 return flagSupportedClusters(315 req,316 kbnIndices317 )(clusters).then((result) => {318 expect(result).toEqual([{ ...standaloneCluster(), isSupported: true }]);319 sinon.assert.calledWith(320 logStub,321 ['debug', 'monitoring', 'supported-clusters'],322 'Found single cluster in monitoring data.'323 );324 });325 });326 });327 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const logStub = require('stryker-parent').logStub;2const logStub = require('stryker-parent').logStub;3const logStub = require('stryker-parent').logStub;4const logStub = require('./lib/logStub');5const logStub = require('./lib/logStub');6const logStub = require('./lib/logStub');7module.exports = {8 debug: () => { },9 info: () => { },10 warn: () => { },11 error: () => { }12};13module.exports = {14 debug: () => { },15 info: () => { },16 warn: () => { },17 error: () => { }18};19module.exports = {20 debug: () => { },21 info: () => { },22 warn: () => { },23 error: () => { }24};

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.logStub('test');3var strykerParent = require('stryker-parent');4strykerParent.logStub('test');5var strykerParent = require('stryker-parent');6strykerParent.logStub('test');7var strykerParent = require('stryker-parent');8strykerParent.logStub('test');9var strykerParent = require('stryker-parent');10strykerParent.logStub('test');11var strykerParent = require('stryker-parent');12strykerParent.logStub('test');13var strykerParent = require('stryker-parent');14strykerParent.logStub('test');15var strykerParent = require('stryker-parent');16strykerParent.logStub('test');17var strykerParent = require('stryker-parent');18strykerParent.logStub('test');19var strykerParent = require('stryker-parent');20strykerParent.logStub('test');21var strykerParent = require('stryker-parent');22strykerParent.logStub('test');23var strykerParent = require('stryker-parent');24strykerParent.logStub('test');25var strykerParent = require('stryker-parent');26strykerParent.logStub('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logStub } from 'stryker-parent';2logStub('test');3import { logStub } from 'stryker-parent';4logStub('test');5import { logStub } from 'stryker-parent';6logStub('test');7import { logStub } from 'stryker-parent';8logStub('test');9import { logStub } from 'stryker-parent';10logStub('test');11import { logStub } from 'stryker-parent';12logStub('test');13import { logStub } from 'stryker-parent';14logStub('test');15import { logStub } from 'stryker-parent';16logStub('test');17import { logStub } from 'stryker-parent';18logStub('test');19import { logStub } from 'stryker-parent';20logStub('test');21import { logStub } from 'stryker-parent';22logStub('test');23import { logStub } from 'stryker-parent';24logStub('test');25import { logStub } from 'stryker-parent';26logStub('test');27import { logStub } from 'stryker-parent';28logStub('test');29import { logStub } from 'stryker

Full Screen

Using AI Code Generation

copy

Full Screen

1const logStub = require('stryker-parent').logStub;2logStub.debug('debug message');3logStub.info('info message');4logStub.warn('warn message');5logStub.error('error message');6const logStub = require('stryker-api').log;7logStub.debug('debug message');8logStub.info('info message');9logStub.warn('warn message');10logStub.error('error message');11const logStub = require('stryker-api').log;12logStub.debug('debug message');13logStub.info('info message');14logStub.warn('warn message');15logStub.error('error message');16const logStub = require('stryker-api').log;17logStub.debug('debug message');18logStub.info('info message');19logStub.warn('warn message');20logStub.error('error message');21const logStub = require('stryker-api').log;22logStub.debug('debug message');23logStub.info('info message');24logStub.warn('warn message');25logStub.error('error message');

Full Screen

Using AI Code Generation

copy

Full Screen

1const logStub = require('stryker-parent').logStub;2logStub.info('test log');3logStub.error('test error');4const logStub = require('stryker-parent').logStub;5logStub.info('test log');6logStub.error('test error');7import { logStub } from 'stryker-parent';8logStub.info('test log');9logStub.error('test error');10import { logStub } from 'stryker-parent';11logStub.info('test log');12logStub.error('test error');13const log4js = require('log4js');14import * as log4js from 'log4js';15const log4js = require('log4js');16const logger = log4js.getLogger('myPlugin');17logger.info('test log');18logger.error('test error');19import * as log4js from 'log4js';20const logger = log4js.getLogger('myPlugin');21logger.info('test log');22logger.error('test error');23Logging in your own plugins (alternative)

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful