Skip to content
Snippets Groups Projects
Unverified Commit ebee4670 authored by Varac's avatar Varac
Browse files

Finish test function

parent ddf66ff2
Branches
Tags
No related merge requests found
......@@ -231,7 +231,6 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo
info_parser = subparsers.add_parser(
'info',
help=("Show information about a cluster"))
info_parser.set_defaults(func=info)
info_parser.add_argument(
'--ip-address',
......@@ -239,6 +238,11 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo
help=('Only output the IP address of the machine')
)
secrets_parser = subparsers.add_parser(
'secrets',
help=("Show OAS cluster secrets"))
secrets_parser.set_defaults(func=secrets)
args = parser.parse_args()
loglevel = logging.DEBUG if args.verbose else logging.INFO
init_logging(log, loglevel)
......@@ -275,6 +279,16 @@ def info(clus, args):
clus.print_info(args)
def secrets(clus, args):
"""
Dumps cluster secrets and then exits
:param cluster.Cluster clus: cluster to show information about
"""
clus.load_data()
clus.dump_secrets(args)
def create(clus, args): # pylint: disable=too-many-branches
"""
Parses arguments for the 'create' subcommand
......@@ -399,15 +413,15 @@ def test(clus, args):
if 'taiko' in run_test:
taiko_path = os.path.join(os.path.dirname(__file__), '..', 'test',
'taiko')
'taiko')
# Run from the taiko directory so taiko automatically loads all the
# necessary files
os.chdir(taiko_path)
clus.load_data()
command = []
command = ['/bin/echo', 'hi']
if args.observe:
command.append('--observe')
for tag in args.brows:
for tag in args.browser_args:
log.info(command)
command.append('-t {tag}'.format(tag=tag))
if args.browser_args:
......@@ -421,8 +435,10 @@ def test(clus, args):
log.info('Running taiko command %s', command)
taiko = Popen(command, stdout=PIPE)
# output = taiko.communicate()[0]
output = taiko.communicate()[0]
return_code = (taiko.returncode)
print(return_code)
print(output)
sys.exit(return_code)
def create_domain_records(domain, droplet_ip, subdomain=None):
......
......@@ -257,76 +257,50 @@ KUBECONFIG={secret_dir}/kube_config_cluster.yml
"""Path where all the passwords for cluster admins are saved"""
return os.path.join(self.cluster_dir, 'secrets')
def write_behave_config(self, config_path):
def dump_secrets(self, args):
"""
Write behave config file for the cluster.
:param str config_path: Configuration is written to config_path (e.g.
/home/you/openappstack/test/behave.ini). If config_path already
exists, the program is aborted.
Shows all OAS cluster secrets.
"""
if os.path.isfile(config_path):
log.error('%s file already exists, not overwriting '
'file! Remove the file if you want to run behave. '
'Program will exit now', config_path)
sys.exit(2)
grafana_admin_password = self.get_password_from_kubernetes(
'kube-prometheus-stack-grafana',
'admin-password',
'oas')
rocketchat_admin_password = self.get_password_from_kubernetes(
'oas-rocketchat-variables',
'rocketchat_admin_password',
'flux-system')
nextcloud_admin_password = self.get_password_from_kubernetes(
'nc-nextcloud',
'nextcloud-password',
'oas-apps')
wordpress_admin_password = self.get_password_from_kubernetes(
'oas-wordpress-variables',
'wordpress_admin_password',
'flux-system')
behave_config = configparser.ConfigParser()
behave_config['behave'] = {}
behave_config['behave']['format'] = 'rerun'
behave_config['behave']['outfiles'] = 'rerun_failing.features'
behave_config['behave']['show_skipped'] = 'false'
behave_config['behave.userdata'] = {}
behave_config['behave.userdata']['nextcloud.url'] = \
'https://files.{}'.format(self.domain)
behave_config['behave.userdata']['nextcloud.username'] = 'admin'
behave_config['behave.userdata']['nextcloud.password'] = \
nextcloud_admin_password
behave_config['behave.userdata']['onlyoffice.url'] = \
'https://office.{}/welcome'.format(self.domain)
behave_config['behave.userdata']['rocketchat.url'] = \
'https://chat.{}'.format(self.domain)
behave_config['behave.userdata']['rocketchat.username'] = 'admin'
behave_config['behave.userdata']['rocketchat.password'] = \
rocketchat_admin_password
behave_config['behave.userdata']['wordpress.url'] = \
'https://www.{}/wp-login.php'.format(self.domain)
behave_config['behave.userdata']['wordpress.username'] = 'admin'
behave_config['behave.userdata']['wordpress.password'] = \
wordpress_admin_password
behave_config['behave.userdata']['grafana.url'] = \
'https://grafana.{}'.format(self.domain)
behave_config['behave.userdata']['grafana.username'] = 'admin'
behave_config['behave.userdata']['grafana.password'] = \
grafana_admin_password
with open(config_path, 'w') as config_file:
behave_config.write(config_file)
all_secrets = {
'flux-system': {
'oas-kube-prometheus-stack-variables': ['grafana_admin_password'],
'oas-nextcloud-variables': [
'nextcloud_mariadb_password',
'nextcloud_mariadb_root_password',
'nextcloud_password',
'onlyoffice_jwt_secret',
'onlyoffice_postgresql_password',
'onlyoffice_rabbitmq_password'],
'oas-rocketchat-variables': [
'rocketchat_admin_password',
'mongodb_root_password',
'mongodb_password' ],
'oas-single-sign-on-variables': [
'userbackend_admin_username',
'userbackend_admin_password',
'userbackend_postgres_password',
'hydra_system_secret' ],
'oas-wordpress-variables': [
'wordpress_admin_password',
'wordpress_mariadb_password',
'wordpress_mariadb_root_password' ]
}
}
for namespace in all_secrets:
sec = all_secrets[namespace]
for name in sec.items():
app = name[0]
app_secrets = sec[app]
for app_secret in app_secrets:
secret = self.get_password_from_kubernetes(
app,
app_secret,
namespace)
# print(namespace, app, app_secret, secret )
print(app_secret + '=' + secret )
def get_password_from_kubernetes(self, secret, key, namespace):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment