def initialize_interactive_test_suite()

in testSuite/scripts/utility.py [0:0]


def initialize_interactive_test_suite(test_dir_path, container_oauth, container_oauth_validate, 
    filesystem_url, oauth_tenant_id, oauth_aad_endpoint, azcopy_exec_location, test_suite_exec_location):
    # test_directory_path is global variable holding the location of test directory to execute all the test cases.
    # contents are created, copied, uploaded and downloaded to and from this test directory only
    global test_directory_path

    # test_oauth_container_url is a global variable used in the entire testSuite holding the user given container for oAuth testing.
    # all files / directory are uploaded and downloaded to and from this container.
    global test_oauth_container_url

    # test_container_oauth_validate_sas_url is same container as test_oauth_container_url, while for validation purpose. 
    global test_oauth_container_validate_sas_url

    # holds the name of the azcopy executable
    global azcopy_executable_name

    # holds the name of the test suite executable
    global test_suite_executable_name

    # holds the filesystem url to perform the operations for blob fs service
    global test_bfs_account_url

    # holds the oauth tenant id
    global test_oauth_tenant_id

    # holds the oauth aad encpoint
    global test_oauth_aad_endpoint

    # creating a test_directory in the location given by user.
    # this directory will be used to created and download all the test files.
    new_dir_path = os.path.join(test_dir_path, "test_data")
    # todo finally
    try:
        # removing the directory and its contents, if directory exists
        shutil.rmtree(new_dir_path)
        os.mkdir(new_dir_path)
    except:
        os.mkdir(new_dir_path)

    # copying the azcopy executable to the newly created test directory.
    # this copying is done to avoid using the executables at location which might be used by the user
    # while test suite is running.
    if os.path.isfile(azcopy_exec_location):
        shutil.copy2(azcopy_exec_location, new_dir_path)
        azcopy_executable_name = parse_out_executable_name(azcopy_exec_location)
    else:
        print("please verify the azcopy executable location")
        return False

    # copying the test executable to the newly created test directory.
    # this copying is done to avoid using the executables at location which might be used by the user
    # while test suite is running.
    if os.path.isfile(test_suite_exec_location):
        shutil.copy2(test_suite_exec_location, new_dir_path)
        test_suite_executable_name = parse_out_executable_name(test_suite_exec_location)
    else:
        print("please verify the test suite executable location")
        return False

    test_directory_path = new_dir_path

    test_oauth_tenant_id = oauth_tenant_id
    test_oauth_aad_endpoint = oauth_aad_endpoint

    # set the filesystem url
    test_bfs_account_url = filesystem_url
    if not clean_test_filesystem(test_bfs_account_url):
        return False
    if not (test_bfs_account_url.endswith("/") and test_bfs_account_url.endwith("\\")):
        test_bfs_account_url = test_bfs_account_url + "/"

    test_oauth_container_url = container_oauth
    if not (test_oauth_container_url.endswith("/") and test_oauth_container_url.endwith("\\")):
        test_oauth_container_url = test_oauth_container_url + "/"
    
    # as validate container URL point to same URL as oauth container URL, do clean up with validate container URL
    test_oauth_container_validate_sas_url = container_oauth_validate
    if not clean_test_container(test_oauth_container_validate_sas_url):
        return False

    return True