コード例 #1
0
ファイル: tf.py プロジェクト: w3f-community/tank
    def __init__(self, app, testcase: TestCase):
        self._app = app
        self.testcase = testcase

        if not isdir(self._provider_templates):
            raise TankError(
                'Failed to find Terraform templates for cloud provider {} at {}'
                .format(self._app.cloud_settings.provider.value,
                        self._provider_templates))
コード例 #2
0
ファイル: cluster.py プロジェクト: w3f-community/tank
    def _show_hosts(self, run_inspect_data):
        if 'cluster' not in run_inspect_data:
            raise TankError(
                'There are no information about hosts. Have you performed provision/deploy?'
            )

        rows = sorted([[ip, i['hostname']]
                       for ip, i in run_inspect_data['cluster'].items()],
                      key=second)
        print(tabulate(list(rows), headers=['IP', 'HOSTNAME']))

        for ip, info in run_inspect_data['cluster'].items():
            if info['hostname'].endswith('-monitoring'):
                print('\nMonitoring: http://{}/'.format(ip))
                break
コード例 #3
0
 def _check_terraform_inventory_availability(self):
     try:
         sh.Command(self.terraform_inventory_run_command, "-version")
     except Exception:
         raise TankError("Error calling Terraform Inventory at '{}'".format(
             self.terraform_inventory_run_command))
コード例 #4
0
ファイル: run.py プロジェクト: LordGenry/tank
    def bench(self, load_profile: str, tps: int, total_tx: int):
        bench_command = 'bench --common-config=/tool/bench.config.json ' \
                        '--module-config=/tool/polkadot.bench.config.json'
        if tps is not None:
            # It's assumed, that every node is capable of running the bench.
            per_node_tps = max(int(tps / self._testcase.total_instances), 1)
            bench_command += ' --common.tps {}'.format(per_node_tps)

        if total_tx is not None:
            # It's assumed, that every node is capable of running the bench.
            per_node_tx = max(int(total_tx / self._testcase.total_instances),
                              1)
            bench_command += ' --common.stopOn.processedTransactions {}'.format(
                per_node_tx)

        # FIXME extract hostnames from inventory, but ignore monitoring
        ips = [
            ip for ip, i in self._cluster_report().items()
            if i['bench_present']
        ]
        if not ips:
            raise TankError(
                'There are no nodes capable of running the bench util')
        host_patterns = ','.join(ips)

        with self._lock:
            # send the load_profile to the cluster
            extra_vars = {'load_profile_local_file': fs.abspath(load_profile)}

            sh.Command("ansible-playbook")(
                "-f",
                "30",
                "-u",
                "root",
                "-i",
                self._app.terraform_inventory_run_command,
                "--extra-vars",
                self._ansible_extra_vars(extra_vars),
                "--private-key={}".format(
                    self._app.cloud_settings.provider_vars['pvt_key']),
                "-t",
                "send_load_profile",
                fs.join(self._roles_path, AnsibleBinding.BLOCKCHAIN_ROLE_NAME,
                        'tank', 'send_load_profile.yml'),
                _env=self._make_env(),
                _out=sys.stdout,
                _err=sys.stderr,
                _cwd=self._tf_plan_dir)

            # run the bench
            sh.Command("ansible")(
                '-f',
                '150',
                '-B',
                '3600',
                '-P',
                '10',
                '-u',
                'root',
                '-i',
                self._app.terraform_inventory_run_command,
                '--private-key={}'.format(
                    self._app.cloud_settings.provider_vars['pvt_key']),
                host_patterns,
                '-a',
                bench_command,
                _env=self._make_env(),
                _out=sys.stdout,
                _err=sys.stderr,
                _cwd=self._tf_plan_dir)
コード例 #5
0
ファイル: cluster.py プロジェクト: LordGenry/tank
    def _show_hosts(self, run_inspect_data):
        if 'cluster' not in run_inspect_data:
            raise TankError('There are no information about hosts. Have you performed provision/deploy?')

        rows = sorted([[ip, i['hostname']] for ip, i in run_inspect_data['cluster'].items()], key=second)
        print(tabulate(list(rows), headers=['IP', 'HOSTNAME']))