コード例 #1
0
def create_build_object_with_mock(mocker, build_object_type):
    args = ['-u', "$USERNAME", '-p', "$PASSWORD", '-c', "$CONF_PATH", '-s', "$SECRET_CONF_PATH",
            '--tests_to_run', "$ARTIFACTS_FOLDER/filter_file.txt",
            '--pack_ids_to_install', "$ARTIFACTS_FOLDER/content_packs_to_install.txt",
            '-g', "$GIT_SHA1", '--ami_env', "$1", '-n', 'false', '--branch', "$CI_COMMIT_BRANCH",
            '--build-number', "$CI_PIPELINE_ID", '-sa', "$GCS_MARKET_KEY", '--build_object_type', build_object_type,
            '--xsiam_machine', "qa2-test-111111", '--xsiam_servers_path', '$XSIAM_SERVERS_PATH']
    options = options_handler(args=args)
    json_data = {
        'tests': [],
        'skipped_integrations': [],
        'unmockable_integrations': [],
    }
    json_data.update(**XSIAM_SERVERS)
    mocker.patch('Tests.configure_and_test_integration_instances.get_json_file',
                 return_value=json_data)
    mocker.patch('Tests.configure_and_test_integration_instances.Build.fetch_tests_list',
                 return_value=[])
    mocker.patch('Tests.configure_and_test_integration_instances.Build.fetch_pack_ids_to_install',
                 return_value=[])
    mocker.patch('Tests.configure_and_test_integration_instances.options_handler',
                 return_value=options)
    mocker.patch('Tests.configure_and_test_integration_instances.XSOARBuild.get_servers',
                 return_value=({'1.1.1.1': '7000'}, '6.5.0'))
    build = create_build_object()
    return build
def main():
    build = Build(options_handler())
    prints_manager = ParallelPrintsManager(1)

    configure_servers_and_restart(build, prints_manager)
    #  Get a list of the test we need to run.
    tests_for_iteration = get_tests(build.server_numeric_version,
                                    prints_manager, build.tests)
    #  Installing the packs.
    installed_content_packs_successfully = install_packs_private(
        build, prints_manager)
    #  Get a list of the integrations that have changed.
    new_integrations, modified_integrations = get_changed_integrations(
        build, prints_manager)
    #  Configuring the instances which are used in testing.
    all_module_instances, brand_new_integrations = \
        configure_server_instances(build, tests_for_iteration, new_integrations,
                                   modified_integrations, prints_manager)

    #  Running the instance tests (pushing the test button)
    successful_tests_pre, failed_tests_pre = instance_testing(
        build, all_module_instances, prints_manager, pre_update=True)
    #  Adding the new integrations to the instance test list and testing them.
    all_module_instances.extend(brand_new_integrations)
    successful_tests_post, failed_tests_post = instance_testing(
        build, all_module_instances, prints_manager, pre_update=False)
    #  Done running tests so we are disabling the instances.
    disable_instances(build, all_module_instances, prints_manager)
    #  Gather tests to add to test pack
    test_playbooks_from_id_set = build.id_set.get('TestPlaybooks', [])
    tests_to_add_to_test_pack = find_needed_test_playbook_paths(
        test_playbooks=test_playbooks_from_id_set,
        tests_to_run=build.tests_to_run,
        path_to_content=build.content_root)
    #  Write the test pack
    private_content_test_zip = write_test_pack_zip(
        zip_destination_dir=build.test_pack_path,
        tests_file_paths=tests_to_add_to_test_pack,
        path_to_content=build.content_root)
    # Create and install private test pack
    install_private_testing_pack(build, prints_manager,
                                 private_content_test_zip)

    success = report_tests_status(failed_tests_pre, failed_tests_post,
                                  successful_tests_pre, successful_tests_post,
                                  new_integrations, prints_manager)
    sleep(30)
    if not success or not installed_content_packs_successfully:
        sys.exit(2)
コード例 #3
0
def main():
    install_logging('Install Content And Configure Integrations On Server.log')
    build = XSOARBuild(options_handler())

    build.configure_servers_and_restart()

    build.disable_instances()
    #  Get a list of the test we need to run.
    tests_for_iteration = build.get_tests()
    #  Installing the packs.
    installed_content_packs_successfully = install_packs_private(build)
    #  Get a list of the integrations that have changed.
    new_integrations, modified_integrations = build.get_changed_integrations()
    #  Configuring the instances which are used in testing.
    all_module_instances, brand_new_integrations = \
        build.configure_server_instances(tests_for_iteration, new_integrations, modified_integrations)

    #  Running the instance tests (pushing the test button)
    successful_tests_pre, failed_tests_pre = build.instance_testing(
        all_module_instances, pre_update=True, use_mock=False)
    #  Adding the new integrations to the instance test list and testing them.
    all_module_instances.extend(brand_new_integrations)
    successful_tests_post, failed_tests_post = build.instance_testing(
        all_module_instances, pre_update=False, use_mock=False)
    #  Gather tests to add to test pack
    test_playbooks_from_id_set = build.id_set.get('TestPlaybooks',
                                                  []) if build.id_set else None
    tests_to_add_to_test_pack = find_needed_test_playbook_paths(
        test_playbooks=test_playbooks_from_id_set,
        tests_to_run=build.tests_to_run,
        path_to_content=build.content_root)
    #  Write the test pack
    private_content_test_zip = write_test_pack_zip(
        zip_destination_dir=build.test_pack_path,
        tests_file_paths=tests_to_add_to_test_pack,
        path_to_content=build.content_root)
    # Create and install private test pack
    install_private_testing_pack(build, private_content_test_zip)

    success = report_tests_status(failed_tests_pre, failed_tests_post,
                                  successful_tests_pre, successful_tests_post,
                                  new_integrations, build)
    sleep(30)
    if not success or not installed_content_packs_successfully:
        sys.exit(2)