Esempio n. 1
0
def test_neg_permission_denied(prep_for_test):
    execute_command(prep_for_test.ssh_client,
                    cmd.SUDO_MKDIR.format(prep_for_test.path_dir),
                    True,
                    ignore_error=True)
    execute_list_of_commands(
        prep_for_test.ssh_client,
        [
            # change rights - all rights(rwx) for owner only
            cmd.SUDO_CHMOD.format(700, prep_for_test.path_dir),
            # change owner - root
            cmd.SUDO_CHOWN.format('root', prep_for_test.path_dir)
        ])
    with pytest.raises(PermissionDenied) as exc:
        try:
            prep_for_test.do_capture_frames()
        finally:
            execute_list_of_commands(
                prep_for_test.ssh_client,
                [
                    # change owner - nvidia
                    cmd.SUDO_CHOWN.format('nvidia', prep_for_test.path_dir),
                    # change rights - all rights(rwx) for owner and group of owner
                    cmd.SUDO_CHMOD.format(770, prep_for_test.path_dir)
                ])
    logging.exception(exc)
Esempio n. 2
0
def test_permission_denied(client):
    execute_command(
        client,
        'sudo chown root {}'.format('/'.join([default_folder,
                                              folder_name])), True)
    with pytest.raises(PermissionDenied):
        get_screenshot(file_name, folder_name)
 def disable(self):
     if not self.is_enable():
         return
     disable_gpio_cmd = r'echo {} | sudo tee {}/unexport > /dev/null'.format(
         self._gpio_pin, self._gpio_path)
     execute_command(self._client, disable_gpio_cmd, passwd_required=True)
     # gpio availability is read only once as server init, restart needed
     self.restart_ate_server()
Esempio n. 4
0
def create_zero_size_file(create_temporary_folder):
    client = create_temporary_folder
    # create file zero_size_file.png in screenshots folder, size file = 0
    ssh_connect.execute_command(
        client, 'cd {}/{}; touch {}'.format(default_folder, folder_name,
                                            zero_size_file), True)

    yield "/".join([folder_name, zero_size_file])
Esempio n. 5
0
def test_nested_folder(client):
    nested_folder = folder_name + '/nested'
    execute_command(client, 'cd {}; mkdir {}'.format(default_folder,
                                                     nested_folder), True)
    assert get_screenshot(file_name, nested_folder)
    path = "/".join([default_folder, nested_folder])
    check_content(client, path, file_name)
    check_size(client, path, file_name)
 def delete_dir(self):
     if self.dir_name == '' or self.path_dir.rstrip('/') == DIR_PREFIX:
         logging.warning('Trying to remove init folder! SKIPPED')
     else:
         execute_command(self.ssh_client,
                         cmd.SUDO_RM.format(self.path_dir),
                         True,
                         ignore_error=True)
Esempio n. 7
0
def find_process_on_port_and_kill(client):
    ports = ssh_connect.execute_command(client, FIND_PORT)
    data = ports.read().split('\n')
    processes = [pid[8:13] for pid in data[1:-1]]
    for process in processes:
        ssh_connect.execute_command(client,
                                    KILL_PID.format(process),
                                    passwd_required=True)
Esempio n. 8
0
def create_unsupport_file(create_temporary_folder):
    client = create_temporary_folder
    # create file .txt type
    path_unsupport_type_file = "/".join(
        [default_folder, folder_name, unsupport_type_file])
    ssh_connect.execute_command(
        client, 'echo "Test file for verify insupport type" > {}'.format(
            path_unsupport_type_file), True, True)

    yield "/".join([folder_name, unsupport_type_file])
Esempio n. 9
0
def test_spaces(client):
    file_name_with_spaces = 'my ' + file_name
    folder_with_spaces = folder_name + '/my screen shots'
    execute_command(
        client, 'cd {}; mkdir "{}"'.format(default_folder, folder_with_spaces),
        True)
    assert get_screenshot(file_name_with_spaces, folder_with_spaces)
    path = "/".join([default_folder, folder_with_spaces])
    check_content(client, path, file_name_with_spaces)
    check_size(client, path, file_name_with_spaces)
Esempio n. 10
0
def test_stop_media_server():
    attach_to_application()
    client = ssh_connect.start()
    ssh_connect.execute_command(client, STOP_MEDIASERVER, passwd_required=True)
    with pytest.raises(VideoStreamingError):
        waitForObject('Settings')
    ssh_connect.execute_command(client,
                                START_MEDIASERVER,
                                passwd_required=True)
    time.sleep(10)
    waitForObject('Settings')
Esempio n. 11
0
def get_current_sync_build_version(app_connector):
    # get version sync from config file
    client = ssh_connect.start()
    stdin, stdout, stderr = client.exec_command(CURRENT_SYNC_VERSION)
    sync = stdout.read()[:-1]
    stdin, stdout, stderr = client.exec_command(CURRENT_BUILD_VERSION)
    build = stdout.read()[:-1]
    yield sync, build
    ssh_connect.execute_command(client,
                                cmd.VDP_ATE_SERVER_RESTART,
                                passwd_required=True)
    def start(self):
        if self.is_started():
            return
        direction_path = r'{}/direction'.format(self._video_path)
        set_direction_cmd = r'echo in | sudo tee {}  > /dev/null'.format(
            direction_path)
        edge_path = r'{}/edge'.format(self._video_path)
        set_edge_cmd = r'echo both | sudo tee {}  > /dev/null'.format(
            edge_path)

        execute_command(self._client, set_direction_cmd, passwd_required=True)
        execute_command(self._client, set_edge_cmd, passwd_required=True)
Esempio n. 13
0
def test_replaced(client):
    assert get_screenshot(file_name, folder_name)
    path = "/".join([default_folder, folder_name, file_name])
    modified_time_command = 'date -r {} +%s'.format(path)
    modified_time_old = int(
        execute_command(client, modified_time_command).read().strip())
    # sleep for time changed event
    time.sleep(1)
    assert get_screenshot(file_name, folder_name)
    modified_time_new = int(
        execute_command(client, modified_time_command).read().strip())
    assert modified_time_new > modified_time_old
    def is_enable(self):

        check_dir_cmd = r'[ -d {} ] && echo yes || echo no'.format(
            self._video_path)
        is_dir_exist = execute_command(self._client,
                                       check_dir_cmd,
                                       ignore_error=True).read().strip()
        return is_dir_exist == 'yes'
    def is_started(self):

        edge_path = r'{}/edge'.format(self._video_path)
        get_edge_cmd = r'[ -f {} ] && cat {}'.format(edge_path, edge_path)
        gpio_edge = execute_command(self._client,
                                    get_edge_cmd,
                                    ignore_error=True).read().strip()

        return gpio_edge == 'both'
Esempio n. 16
0
    def get_ate_server_ini(self, file_path=_config_path, raw_data=False):

        tmp_info = execute_command(self.client,
                                   _cmd_get_data.format(file_path)).read()

        raw_list_params = tmp_info.strip().split('\r\n')
        if raw_data:
            return raw_list_params
        else:
            return {
                item.split('=')[0].strip(): item.split('=')[1].strip()
                for item in raw_list_params
            }
Esempio n. 17
0
def test_port_busy_another_process():
    client = ssh_connect.start()
    ssh_connect.execute_command(client, STOP, passwd_required=True)
    output = ssh_connect.execute_command(client, CURRENT_DATE)
    curr_time = output.read()[:-2]
    client.exec_command(START_TCP, get_pty=False)
    ssh_connect.execute_command(client, START, passwd_required=True)
    time.sleep(SLEEP)
    logs = ssh_connect.execute_command(client, RETRIEVE_LOG)
    process_time = logs.read().split('\n')[-2][0:12]
    find_process_on_port_and_kill(client)
    time.sleep(SLEEP)
    ssh_connect.execute_command(client, START, passwd_required=True)
    attach_to_application()
    assert curr_time == process_time
    def check_picture_resolution(self):
        picture_resolution = None
        for image_file in self.result_of_capture_frames:
            path = r"{}/{}".format(self.path_dir, image_file)
            output = execute_command(
                self.ssh_client, 'identify "{}"'.format(path)).read().strip()
            picture_data = output[output.lower().index(').png'):]
            picture_resolution = picture_data.split(' ')[2]
            # check resolution of picture
            assert picture_resolution == self.expected_resolution

        logging.info(
            'actual picture resolution is [{}]'.format(picture_resolution))
        return self
Esempio n. 19
0
def create_temporary_folder(app_connector):
    client = ssh_connect.start()
    ssh_connect.execute_command(client,
                                'rm -r "{}"'.format(folder_path),
                                ignore_error=True)
    ssh_connect.execute_command(client, 'mkdir {}'.format(folder_path))
    yield client
    ssh_connect.execute_command(client,
                                'rm -r "{}"'.format(folder_path),
                                ignore_error=True)
Esempio n. 20
0
def client(attach_to_app):
    client = start()
    execute_command(
        client, 'cd {}; sudo rm -r "{}"'.format(default_folder, folder_name),
        True, True)
    execute_command(client, 'cd {}; mkdir {}'.format(default_folder,
                                                     folder_name), True)
    yield client
    execute_command(client,
                    'cd {}; sudo rm -r {}'.format(default_folder,
                                                  folder_name), True, True)
Esempio n. 21
0
def check_content(client, path, name):
    content_command = 'ls "{}"'.format(path)
    content = execute_command(client, content_command).read().strip()
    assert content == name
Esempio n. 22
0
def prep_for_neg_test_no_video(prep_for_neg_test):
    execute_command(prep_for_neg_test, cmd.VDP_MEDIA_SERVER_STOP, True)
    yield
    execute_command(prep_for_neg_test, cmd.VDP_MEDIA_SERVER_START, True)
Esempio n. 23
0
def check_size(client, path, name):
    size_command = 'cd "{}"; stat -c %s "{}"'.format(path, name)
    size = int(execute_command(client, size_command).read().strip())
    assert size > 0
 def restart_ate_server(self):
     restart_cmd = 'sudo systemctl restart vdp_ate_server'
     execute_command(self._client, restart_cmd, passwd_required=True)
     sleep(1)
Esempio n. 25
0
def test_check_exception_after_stop_vhat():
    client = ssh_connect.start()
    ssh_connect.execute_command(client, STOP, passwd_required=True)
    with pytest.raises(RuntimeError):
        attach_to_application()
    ssh_connect.execute_command(client, START, passwd_required=True)
Esempio n. 26
0
def test_recovery():
    client = ssh_connect.start()
    ssh_connect.execute_command(client, KILLALL, passwd_required=True)
    attach_to_application()
def test_video_stream_streamer_stopped_raise_exception(client_setup):
    execute_command(client_setup, STOP_STREAMER, passwd_required=True)
    with pytest.raises(VideoStreamingError):
        wait_for_object('main_settings_button_active')
    execute_command(client_setup, START_STREAMER, passwd_required=True)
    sleep(.5)