AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
318 stars 98 forks source link

Getting Error in device farm after starting appium #1237

Closed rakeshkarkare closed 2 months ago

rakeshkarkare commented 2 months ago

Getting Error in device farm after starting appium

self = <appium.webdriver.appium_service.AppiumService object at 0x10d62d5b0> kwargs = {'args': ['--address', 'localhost', '-p', '4723', '--use-plugins=device-farm', '--plugin-device-farm-platform=android']} env = None, node = '/usr/local/bin/node', npm = '/usr/local/bin/npm' main_script = '/usr/local/lib/node_modules/appium/build/lib/main.js' default_std = -1, stdout = -1, stderr = -1

def start(self, **kwargs: Any) -> sp.Popen:
    """Starts Appium service with given arguments.

    If you use the service to start Appium 1.x
    then consider providing ['--base-path', '/wd/hub'] arguments. By default,
    the service assumes Appium server listens on '/' path, which is the default path
    for Appium 2.

    The service will be forcefully restarted if it is already running.

    Keyword Args:
        env (dict): Environment variables mapping. The default system environment,
            which is inherited from the parent process, is assigned by default.
        node (str): The full path to the main NodeJS executable. The service will try
            to retrieve it automatically if not provided.
        npm (str): The full path to the Node Package Manager (npm) script. The service will try
            to retrieve it automatically if not provided.
        stdout (int): Check the documentation for subprocess.Popen for more details.
            The default value is subprocess.DEVNULL on Windows and subprocess.PIPE on other platforms.
        stderr (int): Check the documentation for subprocess.Popen for more details.
            The default value is subprocess.DEVNULL on Windows and subprocess.PIPE on other platforms.
        timeout_ms (int): The maximum time to wait until Appium process starts listening
            for HTTP connections. If set to zero or a negative number then no wait will be applied.
            60000 ms by default.
        main_script (str): The full path to the main Appium executable
            (usually located at build/lib/main.js). If not set
            then the service tries to detect the path automatically.
        args (str): List of Appium arguments (all must be strings). Check
            https://appium.io/docs/en/writing-running-appium/server-args/ for more details
            about possible arguments and their values.

    Returns:
        You can use Popen.communicate interface or stderr/stdout properties
        of the instance (stdout/stderr must not be set to None in such case) in order to retrieve the actual process
        output.
    """
    self.stop()

    env = kwargs['env'] if 'env' in kwargs else None
    node: str = kwargs.get('node') or get_node()
    npm: str = kwargs.get('npm') or get_npm()
    main_script: str = kwargs.get('main_script') or get_main_script(node, npm)
    # A workaround for https://github.com/appium/python-client/issues/534
    default_std = sp.DEVNULL if sys.platform == 'win32' else sp.PIPE
    stdout = kwargs['stdout'] if 'stdout' in kwargs else default_std
    stderr = kwargs['stderr'] if 'stderr' in kwargs else default_std
    timeout_ms = int(kwargs['timeout_ms']) if 'timeout_ms' in kwargs else STARTUP_TIMEOUT_MS
    args: List[str] = [node, main_script]
    if 'args' in kwargs:
        args.extend(kwargs['args'])
    self._cmd = args
    self._process = sp.Popen(args=args, stdout=stdout, stderr=stderr, env=env)
    error_msg: Optional[str] = None
    startup_failure_msg = (
        'Appium server process is unable to start. Make sure proper values have been '
        f'provided to \'node\' ({node}), \'npm\' ({npm}) and \'main_script\' ({main_script}) '
        f'method arguments.'
    )
    if timeout_ms > 0:
        status_url_path = make_status_url(args)
        try:
            if not self._poll_status(parse_host(args), parse_port(args), status_url_path, timeout_ms):
                error_msg = (
                    f'Appium server has started but is not listening on {status_url_path} '
                    f'within {timeout_ms}ms timeout. Make sure proper values have been provided '
                    f'to --base-path, --address and --port process arguments.'
                )
        except AppiumStartupError:
            error_msg = startup_failure_msg
    elif not self.is_running:
        error_msg = startup_failure_msg
    if error_msg is not None:
        if stderr == sp.PIPE and self._process.stderr is not None:
            err_output = self._process.stderr.read()
            if err_output:
                error_msg += f'\nOriginal error: {str(err_output)}'
        self.stop()
      raise AppiumServiceError(error_msg)

E appium.webdriver.appium_service.AppiumServiceError: Appium server process is unable to start. Make sure proper values have been provided to 'node' (/usr/local/bin/node), 'npm' (/usr/local/bin/npm) and 'main_script' (/usr/local/lib/node_modules/appium/build/lib/main.js) method arguments. E Original error: b"(node:5133) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit\n(Use node --trace-warnings ... to show where the warning was created)\n\x1b[38;5;112m[Appium]\x1b[0m Could not configure Appium server. It's possible that a driver or plugin tried to update the server and failed. Original error: EACCES: permission denied, mkdir '/Users/rakeshkarkare/.cache/appium-device-farm/storage'\n"

../../../venv/lib/python3.9/site-packages/appium/webdriver/appium_service.py:222: AppiumServiceError

saikrishna321 commented 2 months ago

Original error: EACCES: permission denied, mkdir '/Users/rakeshkarkare/.cache/appium-device-farm/storage'\n"

Can you please access to this folder.

rakeshkarkare commented 2 months ago

I tried to give access now working

rakeshkarkare commented 2 months ago

Hi @saikrishna321 I am facing issue in device farm dashboard all test after execution in build tab shows fail but it is actually success in script

image

saikrishna321 commented 2 months ago

@rakeshkarkare Can you please share logs.

Also refer this https://devicefarm.org/setup/#dashboard

rakeshkarkare commented 2 months ago

============================= test session starts ============================== platform darwin -- Python 3.12.4, pytest-7.2.2, pluggy-1.5.0 plugins: allure-pytest-2.13.2 collected 1 item mobile/test_mobile_test/test_menu_feature/test_about_feature.py . [100%] ========================= 1 passed in 80.01s (0:01:20) ========================= $ allure generate allure_report -o final_allure_report Report successfully generated to final_allure_report Running after_script 00:00 Running after script... $ zip -r final_allure_report.zip ./final_allure_report adding: final_allure_report/ (stored 0%) adding: final_allure_report/favicon.ico (deflated 62%) adding: final_allure_report/index.html (deflated 54%) adding: final_allure_report/styles.css (deflated 52%) adding: final_allure_report/plugin/ (stored 0%) adding: final_allure_report/plugin/behaviors/ (stored 0%) adding: final_allure_report/plugin/behaviors/index.js (deflated 77%) adding: final_allure_report/plugin/packages/ (stored 0%) adding: final_allure_report/plugin/packages/index.js (deflated 79%) adding: final_allure_report/plugin/screen-diff/ (stored 0%) adding: final_allure_report/plugin/screen-diff/styles.css (deflated 49%) adding: final_allure_report/plugin/screen-diff/index.js (deflated 77%) adding: final_allure_report/history/ (stored 0%) adding: final_allure_report/history/duration-trend.json (stored 0%) adding: final_allure_report/history/retry-trend.json (stored 0%) adding: final_allure_report/history/history.json (deflated 31%) adding: final_allure_report/history/categories-trend.json (stored 0%) adding: final_allure_report/history/history-trend.json (deflated 18%) adding: final_allure_report/export/ (stored 0%) adding: final_allure_report/export/influxDbData.txt (deflated 74%) adding: final_allure_report/export/mail.html (deflated 24%) adding: final_allure_report/export/prometheusData.txt (deflated 60%) adding: final_allure_report/data/ (stored 0%) adding: final_allure_report/data/categories.json (stored 0%) adding: final_allure_report/data/categories.csv (stored 0%) adding: final_allure_report/data/test-cases/ (stored 0%) adding: final_allure_report/data/test-cases/b019708aca06dae4.json (deflated 73%) adding: final_allure_report/data/suites.json (deflated 46%) adding: final_allure_report/data/timeline.json (deflated 42%) adding: final_allure_report/data/packages.json (deflated 47%) adding: final_allure_report/data/suites.csv (deflated 42%) adding: final_allure_report/data/behaviors.json (deflated 40%) adding: final_allure_report/data/attachments/ (stored 0%) adding: final_allure_report/data/attachments/fb222b6c283745f9.txt (deflated 6%) adding: final_allure_report/data/behaviors.csv (deflated 29%) adding: final_allure_report/app.js (deflated 74%) adding: final_allure_report/widgets/ (stored 0%) adding: final_allure_report/widgets/categories.json (stored 0%) adding: final_allure_report/widgets/summary.json (deflated 37%) adding: final_allure_report/widgets/executors.json (stored 0%) adding: final_allure_report/widgets/duration-trend.json (stored 0%) adding: final_allure_report/widgets/status-chart.json (deflated 23%) adding: final_allure_report/widgets/suites.json (deflated 27%) adding: final_allure_report/widgets/retry-trend.json (stored 0%) adding: final_allure_report/widgets/categories-trend.json (stored 0%) adding: final_allure_report/widgets/severity.json (deflated 23%) adding: final_allure_report/widgets/history-trend.json (deflated 18%) adding: final_allure_report/widgets/launch.json (stored 0%) adding: final_allure_report/widgets/behaviors.json (stored 0%) adding: final_allure_report/widgets/duration.json (deflated 23%) adding: final_allure_report/widgets/environment.json (stored 0%) Uploading artifacts for successful job 00:03 Uploading artifacts... Runtime platform arch=arm64 os=darwin pid=[147]67 revision=44feccdf version=17.0.0 ./final_allure_report.zip: found 1 matching artifact files and directories Uploading artifacts as "archive" to coordinator... 201 Created id=7325879273 responseStatus=201 Created token=66 Cleaning up project directory and file based variables 00:00 Job succeeded

rakeshkarkare commented 2 months ago

image

Thanks able to resolve issue by setting

await driver.executeScript('devicefarm: setSessionStatus', [ { status: 'passed', //passed or failed }, ]);

rakeshkarkare commented 2 months ago

Hi @saikrishna321 How can I clear the old runs from device-farm ?

image

saikrishna321 commented 2 months ago

@rakeshkarkare run this command and try

appium plugin run device-farm reset

rakeshkarkare commented 2 months ago

Thanks @saikrishna321 able to clear. Thanks for the all support