Browse Source

test8

master
ganesh 4 years ago
parent
commit
d917c989dd
22 changed files with 110573 additions and 1 deletions
  1. 2
      Jenkinsfile
  2. 66
      loadtests/k6-script.js
  3. 7189
      loadtests/libs/ajv.js
  4. 31217
      loadtests/libs/aws4.js
  5. 10991
      loadtests/libs/chai.js
  6. 19763
      loadtests/libs/cheerio.js
  7. 6614
      loadtests/libs/crypto-js.js
  8. 17215
      loadtests/libs/lodash.js
  9. 381
      loadtests/libs/oauth-1.0a.js
  10. 10
      loadtests/libs/papaparse.js
  11. 7
      loadtests/libs/shim/cheerio.js
  12. 1327
      loadtests/libs/shim/core.js
  13. 7
      loadtests/libs/shim/crypto-js.js
  14. 13
      loadtests/libs/shim/expect.js
  15. 7
      loadtests/libs/shim/full.js
  16. 19
      loadtests/libs/shim/jsonSchema.js
  17. 7
      loadtests/libs/shim/lodash.js
  18. 7
      loadtests/libs/shim/urijs.js
  19. 14
      loadtests/libs/shim/xml2Json.js
  20. 72
      loadtests/libs/spo-gpo.js
  21. 3320
      loadtests/libs/urijs.js
  22. 12326
      loadtests/libs/xml2js.js

2
Jenkinsfile

@ -7,7 +7,7 @@ pipeline {
sh 'sudo chmod +x setup_k6.sh'
sh 'sudo ./setup_k6.sh'
echo 'Running K6 performance tests...'
sh 'k6 run loadtests/performance-test.js'
sh 'k6 run loadtests/k6-script.js'
}
}
}

66
loadtests/k6-script.js

@ -0,0 +1,66 @@
// Auto-generated by the postman-to-k6 converter
import "./libs/shim/core.js";
export let options = { maxRedirects: 4 };
const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
options
});
export default function() {
postman[Request]({
name: "https://gorest.co.in/public-api/users",
id: "982b440c-6b22-4400-94b6-1dc143c2a124",
method: "GET",
address: "https://gorest.co.in/public-api/users",
auth(config, Var) {
config.headers.Authorization =
"Bearer 290e6507ff790f15419eae0e336f2d4b03a634558d1f2580676b8b218f205a9a";
}
});
postman[Request]({
name: "https://gorest.co.in/public-api/users",
id: "537ed25f-720e-48fe-97a7-bb9600ce6ba3",
method: "POST",
address: "https://gorest.co.in/public-api/users",
data:
'{"name":"Robert Redford", "gender":"Male", "email":"robert.redford@nextera.com", "status":"Active"}',
headers: {
"Content-Type": "application/json"
},
auth(config, Var) {
config.headers.Authorization =
"Bearer 290e6507ff790f15419eae0e336f2d4b03a634558d1f2580676b8b218f205a9a";
}
});
postman[Request]({
name: "https://gorest.co.in/public-api/users/123",
id: "d2ca7741-d192-4b9e-b518-29005cd0f6de",
method: "PUT",
address: "https://gorest.co.in/public-api/users/10091",
data:
'{"name":"Bobby Redford", "email":"bobby.redford@nextera.com", "status":"Active"}',
headers: {
"Content-Type": "application/json"
},
auth(config, Var) {
config.headers.Authorization =
"Bearer 290e6507ff790f15419eae0e336f2d4b03a634558d1f2580676b8b218f205a9a";
}
});
postman[Request]({
name: "https://gorest.co.in/public-api/users/10091",
id: "90dd8dd1-29b1-42ee-a0dc-22527a8c3f8e",
method: "DELETE",
address: "https://gorest.co.in/public-api/users/10091",
auth(config, Var) {
config.headers.Authorization =
"Bearer 290e6507ff790f15419eae0e336f2d4b03a634558d1f2580676b8b218f205a9a";
}
});
}

7189
loadtests/libs/ajv.js
File diff suppressed because it is too large
View File

31217
loadtests/libs/aws4.js
File diff suppressed because it is too large
View File

10991
loadtests/libs/chai.js
File diff suppressed because it is too large
View File

19763
loadtests/libs/cheerio.js
File diff suppressed because it is too large
View File

6614
loadtests/libs/crypto-js.js
File diff suppressed because it is too large
View File

17215
loadtests/libs/lodash.js
File diff suppressed because it is too large
View File

381
loadtests/libs/oauth-1.0a.js

@ -0,0 +1,381 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.oauth1 || (g.oauth1 = {})).a = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({"oauth-1.0a":[function(require,module,exports){
if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') {
module.exports = OAuth;
}
/**
* Constructor
* @param {Object} opts consumer key and secret
*/
function OAuth(opts) {
if(!(this instanceof OAuth)) {
return new OAuth(opts);
}
if(!opts) {
opts = {};
}
if(!opts.consumer) {
throw new Error('consumer option is required');
}
this.consumer = opts.consumer;
this.nonce_length = opts.nonce_length || 32;
this.version = opts.version || '1.0';
this.parameter_seperator = opts.parameter_seperator || ', ';
this.realm = opts.realm;
if(typeof opts.last_ampersand === 'undefined') {
this.last_ampersand = true;
} else {
this.last_ampersand = opts.last_ampersand;
}
// default signature_method is 'PLAINTEXT'
this.signature_method = opts.signature_method || 'PLAINTEXT';
if(this.signature_method == 'PLAINTEXT' && !opts.hash_function) {
opts.hash_function = function(base_string, key) {
return key;
}
}
if(!opts.hash_function) {
throw new Error('hash_function option is required');
}
this.hash_function = opts.hash_function;
this.body_hash_function = opts.body_hash_function || this.hash_function;
}
/**
* OAuth request authorize
* @param {Object} request data
* {
* method,
* url,
* data
* }
* @param {Object} key and secret token
* @return {Object} OAuth Authorized data
*/
OAuth.prototype.authorize = function(request, token) {
var oauth_data = {
oauth_consumer_key: this.consumer.key,
oauth_nonce: this.getNonce(),
oauth_signature_method: this.signature_method,
oauth_timestamp: this.getTimeStamp(),
oauth_version: this.version
};
if(!token) {
token = {};
}
if(token.key !== undefined) {
oauth_data.oauth_token = token.key;
}
if(!request.data) {
request.data = {};
}
if(request.includeBodyHash) {
oauth_data.oauth_body_hash = this.getBodyHash(request, token.secret)
}
oauth_data.oauth_signature = this.getSignature(request, token.secret, oauth_data);
return oauth_data;
};
/**
* Create a OAuth Signature
* @param {Object} request data
* @param {Object} token_secret key and secret token
* @param {Object} oauth_data OAuth data
* @return {String} Signature
*/
OAuth.prototype.getSignature = function(request, token_secret, oauth_data) {
return this.hash_function(this.getBaseString(request, oauth_data), this.getSigningKey(token_secret));
};
/**
* Create a OAuth Body Hash
* @param {Object} request data
*/
OAuth.prototype.getBodyHash = function(request, token_secret) {
var body = typeof request.data === 'string' ? request.data : JSON.stringify(request.data)
if (!this.body_hash_function) {
throw new Error('body_hash_function option is required');
}
return this.body_hash_function(body, this.getSigningKey(token_secret))
};
/**
* Base String = Method + Base Url + ParameterString
* @param {Object} request data
* @param {Object} OAuth data
* @return {String} Base String
*/
OAuth.prototype.getBaseString = function(request, oauth_data) {
return request.method.toUpperCase() + '&' + this.percentEncode(this.getBaseUrl(request.url)) + '&' + this.percentEncode(this.getParameterString(request, oauth_data));
};
/**
* Get data from url
* -> merge with oauth data
* -> percent encode key & value
* -> sort
*
* @param {Object} request data
* @param {Object} OAuth data
* @return {Object} Parameter string data
*/
OAuth.prototype.getParameterString = function(request, oauth_data) {
var base_string_data;
if (oauth_data.oauth_body_hash) {
base_string_data = this.sortObject(this.percentEncodeData(this.mergeObject(oauth_data, this.deParamUrl(request.url))));
} else {
base_string_data = this.sortObject(this.percentEncodeData(this.mergeObject(oauth_data, this.mergeObject(request.data, this.deParamUrl(request.url)))));
}
var data_str = '';
//base_string_data to string
for(var i = 0; i < base_string_data.length; i++) {
var key = base_string_data[i].key;
var value = base_string_data[i].value;
// check if the value is an array
// this means that this key has multiple values
if (value && Array.isArray(value)){
// sort the array first
value.sort();
var valString = "";
// serialize all values for this key: e.g. formkey=formvalue1&formkey=formvalue2
value.forEach((function(item, i){
valString += key + '=' + item;
if (i < value.length){
valString += "&";
}
}).bind(this));
data_str += valString;
} else {
data_str += key + '=' + value + '&';
}
}
//remove the last character
data_str = data_str.substr(0, data_str.length - 1);
return data_str;
};
/**
* Create a Signing Key
* @param {String} token_secret Secret Token
* @return {String} Signing Key
*/
OAuth.prototype.getSigningKey = function(token_secret) {
token_secret = token_secret || '';
if(!this.last_ampersand && !token_secret) {
return this.percentEncode(this.consumer.secret);
}
return this.percentEncode(this.consumer.secret) + '&' + this.percentEncode(token_secret);
};
/**
* Get base url
* @param {String} url
* @return {String}
*/
OAuth.prototype.getBaseUrl = function(url) {
return url.split('?')[0];
};
/**
* Get data from String
* @param {String} string
* @return {Object}
*/
OAuth.prototype.deParam = function(string) {
var arr = string.split('&');
var data = {};
for(var i = 0; i < arr.length; i++) {
var item = arr[i].split('=');
// '' value
item[1] = item[1] || '';
// check if the key already exists
// this can occur if the QS part of the url contains duplicate keys like this: ?formkey=formvalue1&formkey=formvalue2
if (data[item[0]]){
// the key exists already
if (!Array.isArray(data[item[0]])) {
// replace the value with an array containing the already present value
data[item[0]] = [data[item[0]]];
}
// and add the new found value to it
data[item[0]].push(decodeURIComponent(item[1]));
} else {
// it doesn't exist, just put the found value in the data object
data[item[0]] = decodeURIComponent(item[1]);
}
}
return data;
};
/**
* Get data from url
* @param {String} url
* @return {Object}
*/
OAuth.prototype.deParamUrl = function(url) {
var tmp = url.split('?');
if (tmp.length === 1)
return {};
return this.deParam(tmp[1]);
};
/**
* Percent Encode
* @param {String} str
* @return {String} percent encoded string
*/
OAuth.prototype.percentEncode = function(str) {
return encodeURIComponent(str)
.replace(/\!/g, "%21")
.replace(/\*/g, "%2A")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29");
};
/**
* Percent Encode Object
* @param {Object} data
* @return {Object} percent encoded data
*/
OAuth.prototype.percentEncodeData = function(data) {
var result = {};
for(var key in data) {
var value = data[key];
// check if the value is an array
if (value && Array.isArray(value)){
var newValue = [];
// percentEncode every value
value.forEach((function(val){
newValue.push(this.percentEncode(val));
}).bind(this));
value = newValue;
} else {
value = this.percentEncode(value);
}
result[this.percentEncode(key)] = value;
}
return result;
};
/**
* Get OAuth data as Header
* @param {Object} oauth_data
* @return {String} Header data key - value
*/
OAuth.prototype.toHeader = function(oauth_data) {
var sorted = this.sortObject(oauth_data);
var header_value = 'OAuth ';
if (this.realm) {
header_value += 'realm="' + this.realm + '"' + this.parameter_seperator;
}
for(var i = 0; i < sorted.length; i++) {
if (sorted[i].key.indexOf('oauth_') !== 0)
continue;
header_value += this.percentEncode(sorted[i].key) + '="' + this.percentEncode(sorted[i].value) + '"' + this.parameter_seperator;
}
return {
Authorization: header_value.substr(0, header_value.length - this.parameter_seperator.length) //cut the last chars
};
};
/**
* Create a random word characters string with input length
* @return {String} a random word characters string
*/
OAuth.prototype.getNonce = function() {
var word_characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var result = '';
for(var i = 0; i < this.nonce_length; i++) {
result += word_characters[parseInt(Math.random() * word_characters.length, 10)];
}
return result;
};
/**
* Get Current Unix TimeStamp
* @return {Int} current unix timestamp
*/
OAuth.prototype.getTimeStamp = function() {
return parseInt(new Date().getTime()/1000, 10);
};
////////////////////// HELPER FUNCTIONS //////////////////////
/**
* Merge object
* @param {Object} obj1
* @param {Object} obj2
* @return {Object}
*/
OAuth.prototype.mergeObject = function(obj1, obj2) {
obj1 = obj1 || {};
obj2 = obj2 || {};
var merged_obj = obj1;
for(var key in obj2) {
merged_obj[key] = obj2[key];
}
return merged_obj;
};
/**
* Sort object by key
* @param {Object} data
* @return {Array} sorted array
*/
OAuth.prototype.sortObject = function(data) {
var keys = Object.keys(data);
var result = [];
keys.sort();
for(var i = 0; i < keys.length; i++) {
var key = keys[i];
result.push({
key: key,
value: data[key],
});
}
return result;
};
},{}]},{},[])("oauth-1.0a")
});

10
loadtests/libs/papaparse.js
File diff suppressed because it is too large
View File

7
loadtests/libs/shim/cheerio.js

@ -0,0 +1,7 @@
/* global postman */
import cheerio from '../cheerio.js';
const Extend = Symbol.for('extend');
postman[Extend].module.cheerio = cheerio;

1327
loadtests/libs/shim/core.js
File diff suppressed because it is too large
View File

7
loadtests/libs/shim/crypto-js.js

@ -0,0 +1,7 @@
/* global postman */
import cryptoJs from '../crypto-js.js';
const Extend = Symbol.for('extend');
postman[Extend].module['crypto-js'] = cryptoJs;

13
loadtests/libs/shim/expect.js

@ -0,0 +1,13 @@
/* global postman */
import chai from '../chai.js';
const Extend = Symbol.for('extend');
Object.assign(postman[Extend], {
AssertionError: chai.AssertionError,
expect(value) {
return chai.expect(value);
},
});

7
loadtests/libs/shim/full.js

@ -0,0 +1,7 @@
import './core';
import './cheerio';
import './crypto-js.js';
import './expect.js';
import './jsonSchema.js';
import './lodash.js';
import './xml2Json';

19
loadtests/libs/shim/jsonSchema.js

@ -0,0 +1,19 @@
/* global postman */
import Ajv from '../ajv.js';
const Extend = Symbol.for('extend');
Object.assign(postman[Extend], {
jsonSchema(store, schema, options) {
const ajv = new Ajv(options);
const validate = ajv.compile(schema);
store.test.push(response => validate(store.response.body.json));
},
jsonSchemaNot(store, schema, options) {
const ajv = new Ajv(options);
const validate = ajv.compile(schema);
store.test.push(response => !validate(store.response.body.json));
},
});

7
loadtests/libs/shim/lodash.js

@ -0,0 +1,7 @@
/* global postman */
import lodash from '../lodash.js';
const Extend = Symbol.for('extend');
postman[Extend].module.lodash = lodash;

7
loadtests/libs/shim/urijs.js

@ -0,0 +1,7 @@
/* global postman */
import URI from '../urijs.js';
const Extend = Symbol.for('extend');
postman[Extend].module.urijs = URI;

14
loadtests/libs/shim/xml2Json.js

@ -0,0 +1,14 @@
import xml2js from '../xml2js.js';
function xml2Json(xml) {
let json;
xml2js.parseString(xml, { async: false }, (err, result) => {
if (err) {
throw err;
}
json = result;
});
return json;
}
global.xml2Json = xml2Json;

72
loadtests/libs/spo-gpo.js

@ -0,0 +1,72 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.spoGpopolyfill = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
var S = 'setPrototypeOf';
var G = 'getPrototypeOf';
var O = Object;
var OP = O.prototype;
var M = 'Cannot convert undefined or null to object';
var gpo = O[G];
var spo = O[S];
if (!spo) {
if ({ __proto__: null } instanceof O) {
var has = function(o, k) {
return OP.hasOwnProperty.call(o, k);
};
var _gpo = gpo;
gpo = function gpo(o) {
if (o == undefined) throw TypeError(M);
o = O(o);
if (has(o, '__proto__')) return o.__proto__;
if (_gpo) return _gpo(o);
if (typeof o.constructor === 'function' && o instanceof o.constructor) {
return o.constructor.prototype;
}
return o instanceof O ? OP : null;
};
spo = function mixinProperties(o, proto) {
O.defineProperty(o, '__proto__', {
value: proto,
enumerable: false,
writable: true,
configurable: true
});
var keys = O.getOwnPropertyNames(proto);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (!has(o, key)) {
var descriptor = O.getOwnPropertyDescriptor(proto, key);
if (descriptor.configurable) {
O.defineProperty(o, key, descriptor);
}
}
}
return o;
};
} else {
spo = function setProtoOf(o, proto) {
o.__proto__ = proto;
return o;
};
}
}
if (!gpo) {
gpo = function(o) {
if (o == undefined) throw TypeError(M);
o = O(o);
return o.__proto__;
};
}
exports[G] = gpo;
exports[S] = spo;
exports.polyfill = function() {
O[G] = gpo;
O[S] = spo;
};
},{}],"spo-gpo/polyfill":[function(require,module,exports){
require('./index').polyfill();
},{"./index":1}]},{},[])("spo-gpo/polyfill")
});

3320
loadtests/libs/urijs.js
File diff suppressed because it is too large
View File

12326
loadtests/libs/xml2js.js
File diff suppressed because it is too large
View File

Loading…
Cancel
Save