def new_run(cls, app, testcase: TestCase): run_id = namesgenerator.get_random_name() fs.ensure_dir_exists(cls._runs_dir(app)) temp_dir = tempfile.mkdtemp(prefix='_{}'.format(run_id), dir=cls._runs_dir(app)) cls._save_meta(temp_dir, testcase) # make a copy to make sure any alterations of the source won't affect us testcase.save(fs.join(temp_dir, 'testcase.yml')) # TODO prevent collisions os.rename(temp_dir, fs.join(cls._runs_dir(app), run_id)) return cls(app, run_id)
def _make_env(self) -> Dict: fs.ensure_dir_exists(self._tf_data_dir) fs.ensure_dir_exists(self._log_dir) env = self._app.app_env env["TF_LOG_PATH"] = fs.join(self._log_dir, 'terraform.log') env["TF_DATA_DIR"] = self._tf_data_dir env["TF_VAR_state_path"] = self._tf_state_file env["TF_VAR_blockchain_name"] = self._testcase.binding.replace( '_', '-')[:10] env["TF_VAR_setup_id"] = self._meta['setup_id'] for k, v in self._app.cloud_settings.provider_vars.items(): env["TF_VAR_{}".format(k)] = v env["ANSIBLE_ROLES_PATH"] = self._roles_path env["ANSIBLE_CONFIG"] = resource_path('ansible', 'ansible.cfg') return env
def list_runs(cls, app): fs.ensure_dir_exists(cls._runs_dir(app)) return [ cls(app, run_id) for run_id in grep_dir( cls._runs_dir(app), '^[a-zA-Z0-9][a-zA-Z_0-9]*$', isdir=True) ]