<commit_before>from .common import *  # NOQA
import ast

AGENT_REG_CMD = os.environ.get('RANCHER_AGENT_REG_CMD', "")
HOST_COUNT = int(os.environ.get('RANCHER_HOST_COUNT', 1))
HOST_NAME = os.environ.get('RANCHER_HOST_NAME', "testsa")
RANCHER_SERVER_VERSION = os.environ.get('RANCHER_SERVER_VERSION',
                                        "master-head")
rke_config = {"authentication": {"type": "authnConfig", "strategy": "x509"},
              "ignoreDockerVersion": False,
              "network": {"type": "networkConfig", "plugin": "canal"},
              "type": "rancherKubernetesEngineConfig"
              }
AUTO_DEPLOY_CUSTOM_CLUSTER = ast.literal_eval(
    os.environ.get('RANCHER_AUTO_DEPLOY_CUSTOM_CLUSTER', "True"))
KEYPAIR_NAME_PREFIX = os.environ.get('RANCHER_KEYPAIR_NAME_PREFIX', "")
RANCHER_CLUSTER_NAME = os.environ.get('RANCHER_CLUSTER_NAME',"")
RANCHER_ELASTIC_SEARCH_ENDPOINT = os.environ.get('RANCHER_ELASTIC_SEARCH_ENDPOINT',"")

def test_add_custom_host():
    aws_nodes = AmazonWebServices().create_multiple_nodes(
        HOST_COUNT, random_test_name(HOST_NAME))
    if AGENT_REG_CMD != "":
        for aws_node in aws_nodes:
            additional_options = " --address " + aws_node.public_ip_address + \
                                 " --internal-address " + \
                                 aws_node.private_ip_address
            agent_cmd = AGENT_REG_CMD + additional_options
            aws_node.execute_command(agent_cmd)


def test_delete_keypair():
    AmazonWebServices().delete_keypairs(KEYPAIR_NAME_PREFIX)


def test_deploy_rancher_server():
    RANCHER_SERVER_CMD = \
        'sudo docker run -d --name="rancher-server" ' \
        '--restart=unless-stopped -p 80:80 -p 443:443  ' \
        'rancher/rancher'
    RANCHER_SERVER_CMD += ":" + RANCHER_SERVER_VERSION
    aws_nodes = AmazonWebServices().create_multiple_nodes(
        1, random_test_name("testsa"+HOST_NAME))
    aws_nodes[0].execute_command(RANCHER_SERVER_CMD)
    time.sleep(120)
    RANCHER_SERVER_URL = "https://" + aws_nodes[0].public_ip_address
    print(RANCHER_SERVER_URL)
    wait_until_active(RANCHER_SERVER_URL)

    RANCHER_SET_DEBUG_CMD = \
        "sudo docker exec rancher-server loglevel --set debug"
    aws_nodes[0].execute_command(RANCHER_SET_DEBUG_CMD)

    token = set_url_password_token(RANCHER_SERVER_URL)
    admin_client = rancher.Client(url=RANCHER_SERVER_URL + "/v3",
                                  token=token, verify=False)
    AUTH_URL = RANCHER_SERVER_URL + \<commit_msg>Increase wait time for rancher server to become available<commit_after>from .common import *  # NOQA
import ast

AGENT_REG_CMD = os.environ.get('RANCHER_AGENT_REG_CMD', "")
HOST_COUNT = int(os.environ.get('RANCHER_HOST_COUNT', 1))
HOST_NAME = os.environ.get('RANCHER_HOST_NAME', "testsa")
RANCHER_SERVER_VERSION = os.environ.get('RANCHER_SERVER_VERSION',
                                        "master-head")
rke_config = {"authentication": {"type": "authnConfig", "strategy": "x509"},
              "ignoreDockerVersion": False,
              "network": {"type": "networkConfig", "plugin": "canal"},
              "type": "rancherKubernetesEngineConfig"
              }
AUTO_DEPLOY_CUSTOM_CLUSTER = ast.literal_eval(
    os.environ.get('RANCHER_AUTO_DEPLOY_CUSTOM_CLUSTER', "True"))
KEYPAIR_NAME_PREFIX = os.environ.get('RANCHER_KEYPAIR_NAME_PREFIX', "")
RANCHER_CLUSTER_NAME = os.environ.get('RANCHER_CLUSTER_NAME',"")
RANCHER_ELASTIC_SEARCH_ENDPOINT = os.environ.get('RANCHER_ELASTIC_SEARCH_ENDPOINT',"")

def test_add_custom_host():
    aws_nodes = AmazonWebServices().create_multiple_nodes(
        HOST_COUNT, random_test_name(HOST_NAME))
    if AGENT_REG_CMD != "":
        for aws_node in aws_nodes:
            additional_options = " --address " + aws_node.public_ip_address + \
                                 " --internal-address " + \
                                 aws_node.private_ip_address
            agent_cmd = AGENT_REG_CMD + additional_options
            aws_node.execute_command(agent_cmd)


def test_delete_keypair():
    AmazonWebServices().delete_keypairs(KEYPAIR_NAME_PREFIX)


def test_deploy_rancher_server():
    RANCHER_SERVER_CMD = \
        'sudo docker run -d --name="rancher-server" ' \
        '--restart=unless-stopped -p 80:80 -p 443:443  ' \
        'rancher/rancher'
    RANCHER_SERVER_CMD += ":" + RANCHER_SERVER_VERSION
    aws_nodes = AmazonWebServices().create_multiple_nodes(
        1, random_test_name("testsa"+HOST_NAME))
    aws_nodes[0].execute_command(RANCHER_SERVER_CMD)
    time.sleep(120)
    RANCHER_SERVER_URL = "https://" + aws_nodes[0].public_ip_address
    print(RANCHER_SERVER_URL)
    wait_until_active(RANCHER_SERVER_URL, timeout=300)

    RANCHER_SET_DEBUG_CMD = \
        "sudo docker exec rancher-server loglevel --set debug"
    aws_nodes[0].execute_command(RANCHER_SET_DEBUG_CMD)

    token = set_url_password_token(RANCHER_SERVER_URL)
    admin_client = rancher.Client(url=RANCHER_SERVER_URL + "/v3",
                                  token=token, verify=False)
    AUTH_URL = RANCHER_SERVER_URL + \
{'fraction_non_alphanumeric': 0.11209439528023599, 'fraction_numerical': 0.009242871189773844, 'mean_word_length': 3.324829931972789, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5996132', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1775, 'n_words': 231}