// Taken from parse_config.js, but removed the validation code.
|
function parseConfig(config) {
|
config = Object.extend({}, config, true); // defensive deep copy
|
|
config.startState = config.startState || 'init';
|
config.setup = config.setup || Function.prototype;
|
config.teardown = config.teardown || Function.prototype;
|
config.data = config.data || {};
|
|
return config;
|
}
|
|
// Taken from extend_workload.js, but removed the validation code.
|
function extendWorkload($config, callback) {
|
var parsedSuperConfig = parseConfig($config);
|
var childConfig = Object.extend({}, parsedSuperConfig, true);
|
return callback(childConfig, parsedSuperConfig);
|
}
|
|
var $config = {}; // Normally would be defined by doing some load() call.
|
|
(function() {
|
var extend1 = extendWorkload($config, function($config, $super) {
|
$config.data.test = 'original';
|
|
$config.setup = function setup(db, collName, cluster) {
|
$super.setup.apply(this, arguments);
|
print('using $config.data: ' + $config.data.test);
|
|
};
|
|
return $config;
|
});
|
|
var extend2 = extendWorkload(extend1, function($config, $super) {
|
$config.data.test = 'changed';
|
|
return $config;
|
});
|
|
extend2.setup.call(extend2.data); // See setupWorkload() in runner.js
|
})();
|
|
(function() {
|
var extend1 = extendWorkload($config, function($config, $super) {
|
$config.data.test = 'original';
|
|
$config.setup = function setup(db, collName, cluster) {
|
$super.setup.apply(this, arguments);
|
print('using this: ' + this.test);
|
|
};
|
|
return $config;
|
});
|
|
var extend2 = extendWorkload(extend1, function($config, $super) {
|
$config.data.test = 'changed';
|
|
return $config;
|
});
|
|
extend2.setup.call(extend2.data); // See setupWorkload() in runner.js
|
})();
|