<commit_before>/* jshint strict: false, sub: true */
/* global print */
'use strict';

// //////////////////////////////////////////////////////////////////////////////
// / DISCLAIMER
// /
// / Copyright 2016 ArangoDB GmbH, Cologne, Germany
// / Copyright 2014 triagens GmbH, Cologne, Germany
// /
// / Licensed under the Apache License, Version 2.0 (the "License")
// / you may not use this file except in compliance with the License.
// / You may obtain a copy of the License at
// /
// /     http://www.apache.org/licenses/LICENSE-2.0
// /
// / Unless required by applicable law or agreed to in writing, software
// / distributed under the License is distributed on an "AS IS" BASIS,
// / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// / See the License for the specific language governing permissions and
// / limitations under the License.
// /
// / Copyright holder is ArangoDB GmbH, Cologne, Germany
// /
// / @author <NAME>
// //////////////////////////////////////////////////////////////////////////////

const functionsDocumentation = {
  'dump': 'dump tests',
  'dump_encrypted': 'encrypted dump tests',
  'dump_authentication': 'dump tests with authentication'
};
const optionsDocumentation = [
  '   - `skipEncrypted` : if set to true the encryption tests are skipped'
];

const pu = require('@arangodb/process-utils');
const tu = require('@arangodb/test-utils');
const fs = require('fs');
const _ = require('lodash');

// const BLUE = require('internal').COLORS.COLOR_BLUE;
const CYAN = require('internal').COLORS.COLOR_CYAN;
// const GREEN = require('internal').COLORS.COLOR_GREEN;
// const RED = require('internal').COLORS.COLOR_RED;
const RESET = require('internal').COLORS.COLOR_RESET;
// const YELLOW = require('internal').COLORS.COLOR_YELLOW;

const testPaths = {
  'dump': [tu.pathForTesting('server/dump')],
  'dump_encrypted': [tu.pathForTesting('server/dump')],
  'dump_authentication': [tu.pathForTesting('server/dump')]
};

class DumpRestoreHelper {
  constructor(instanceInfo, options, clientAuth, dumpOptions, which, afterServerStart) {
    this.instanceInfo = instanceInfo;
    this.options = options;
    this.clientAuth = clientAuth;
    this.dumpOptions = dumpOptions;
    this.which = which;
    this.fn = afterServerStart(instanceInfo);
    this.results = {failed: 1};
    this.arangosh = tu.runInArangosh.bind(this, this.options, this.instanceInfo);
    this.dumpConfig = pu.createBaseConfig('dump', this.dumpOptions, this.instanceInfo);
    this.dumpConfig.setOutputDirectory('dump');
    this.dumpConfig.setIncludeSystem(true);

    this.restoreConfig = pu.createBaseConfig('restore', this.dumpOptions, this.instanceInfo);
    this.restoreConfig.setInputDirectory('dump', true);
    this.restoreConfig.setIncludeSystem(true);

    this.restoreOldConfig = pu.createBaseConfig('restore', this.dumpOptions, this.instanceInfo);
    this.restoreOldConfig.setInputDirectory('dump', true);
    this.restoreOldConfig.setIncludeSystem(true);
    this.restoreOldConfig.setDatabase('_system');
    this.restoreOldConfig.setRootDir(pu.TOP_DIR);

    if (options.encrypted) {
      this.dumpConfig.activateEncryption();
      this.restoreOldConfig.activateEncryption();
    }

    this.arangorestore = pu.run.arangoDumpRestoreWithConfig.bind(this, this.restoreConfig, this.dumpOptions);
    this.arangorestoreOld = pu.run.arangoDumpRestoreWithConfig.bind(this, this.restoreOldConfig, this.dumpOptions);
    this.arangodump = pu.run.arangoDumpRestoreWithConfig.bind(this, this.dumpConfig, this.dumpOptions);
  }

  print (s) {
    print(CYAN + Date() + ': ' + this.which + ' and Restore - ' + s + RESET);
  }

  isAlive() {
    return pu.arangod.check.instanceAlive(this.instanceInfo, this.options);
  }

  validate(phaseInfo) {
    phaseInfo.failed = (phaseInfo.status !== true || !this.isAlive() ? 1 : 0);
    return phaseInfo.failed === 0;
  };<commit_msg>add missing rootDir parameter (#7546)<commit_after>/* jshint strict: false, sub: true */
/* global print */
'use strict';

// //////////////////////////////////////////////////////////////////////////////
// / DISCLAIMER
// /
// / Copyright 2016 ArangoDB GmbH, Cologne, Germany
// / Copyright 2014 triagens GmbH, Cologne, Germany
// /
// / Licensed under the Apache License, Version 2.0 (the "License")
// / you may not use this file except in compliance with the License.
// / You may obtain a copy of the License at
// /
// /     http://www.apache.org/licenses/LICENSE-2.0
// /
// / Unless required by applicable law or agreed to in writing, software
// / distributed under the License is distributed on an "AS IS" BASIS,
// / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// / See the License for the specific language governing permissions and
// / limitations under the License.
// /
// / Copyright holder is ArangoDB GmbH, Cologne, Germany
// /
// / @author <NAME>
// //////////////////////////////////////////////////////////////////////////////

const functionsDocumentation = {
  'dump': 'dump tests',
  'dump_encrypted': 'encrypted dump tests',
  'dump_authentication': 'dump tests with authentication'
};
const optionsDocumentation = [
  '   - `skipEncrypted` : if set to true the encryption tests are skipped'
];

const pu = require('@arangodb/process-utils');
const tu = require('@arangodb/test-utils');
const fs = require('fs');
const _ = require('lodash');

// const BLUE = require('internal').COLORS.COLOR_BLUE;
const CYAN = require('internal').COLORS.COLOR_CYAN;
// const GREEN = require('internal').COLORS.COLOR_GREEN;
// const RED = require('internal').COLORS.COLOR_RED;
const RESET = require('internal').COLORS.COLOR_RESET;
// const YELLOW = require('internal').COLORS.COLOR_YELLOW;

const testPaths = {
  'dump': [tu.pathForTesting('server/dump')],
  'dump_encrypted': [tu.pathForTesting('server/dump')],
  'dump_authentication': [tu.pathForTesting('server/dump')]
};

class DumpRestoreHelper {
  constructor(instanceInfo, options, clientAuth, dumpOptions, which, afterServerStart) {
    this.instanceInfo = instanceInfo;
    this.options = options;
    this.clientAuth = clientAuth;
    this.dumpOptions = dumpOptions;
    this.which = which;
    this.fn = afterServerStart(instanceInfo);
    this.results = {failed: 1};
    this.arangosh = tu.runInArangosh.bind(this, this.options, this.instanceInfo);
    this.dumpConfig = pu.createBaseConfig('dump', this.dumpOptions, this.instanceInfo);
    this.dumpConfig.setOutputDirectory('dump');
    this.dumpConfig.setIncludeSystem(true);

    this.restoreConfig = pu.createBaseConfig('restore', this.dumpOptions, this.instanceInfo);
    this.restoreConfig.setInputDirectory('dump', true);
    this.restoreConfig.setIncludeSystem(true);

    this.restoreOldConfig = pu.createBaseConfig('restore', this.dumpOptions, this.instanceInfo);
    this.restoreOldConfig.setInputDirectory('dump', true);
    this.restoreOldConfig.setIncludeSystem(true);
    this.restoreOldConfig.setDatabase('_system');
    this.restoreOldConfig.setRootDir(pu.TOP_DIR);

    if (options.encrypted) {
      this.dumpConfig.activateEncryption();
      this.restoreOldConfig.activateEncryption();
    }

    this.arangorestore = pu.run.arangoDumpRestoreWithConfig.bind(this, this.restoreConfig, this.dumpOptions, this.instanceInfo.rootDir);
    this.arangorestoreOld = pu.run.arangoDumpRestoreWithConfig.bind(this, this.restoreOldConfig, this.dumpOptions, this.instanceInfo.rootDir);
    this.arangodump = pu.run.arangoDumpRestoreWithConfig.bind(this, this.dumpConfig, this.dumpOptions, this.instanceInfo.rootDir);
  }

  print (s) {
    print(CYAN + Date() + ': ' + this.which + ' and Restore - ' + s + RESET);
  }

  isAlive() {
    return pu.arangod.check.instanceAlive(this.instanceInfo, this.options);
  }

  validate(phaseInfo) {
    phaseInfo.failed = (phaseInfo.status !== true || !this.isAlive() ? 1 : 0);
    return phaseInfo.failed === 0;
  };
{'fraction_non_alphanumeric': 0.1709746564115496, 'fraction_numerical': 0.004539150170218132, 'mean_word_length': 3.4164810690423164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3512337', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2301, 'n_words': 529}