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
347 stars 104 forks source link

Remote sessions do not display on hub #695

Open skidnight opened 1 year ago

skidnight commented 1 year ago

I have a hub setup with currently a single node connected that is running a variety of phones. I can run tests against the hub and it will run them on the devices connected to the node. If I look at the node's dashboard the session exists and is being captured as expected but none of that information is sent to the hub. The hub does recognize if a device is busy and in the logs it recognizes that sessions are being created.

Command to run the hub and node are both the same currently: appium server -ka 800 --use-plugins=device-farm,appium-dashboard --allow-cors --relaxed-security --config hub-config.json -pa /wd/hub

Only difference in the above between the hub and node is the config used which are just the example configurations from the wiki. Is there a configuration step I am missing to get the sessions to appear on the hub for inspection?

hub-config.json:

{
    "server": {
        "port":31337,
        "plugin": {
            "device-farm" : {
                "platform": "both"
            }
        }   
    }
}

node-config.json

{
    "server": {
      "port": 4723,
      "plugin": {
        "device-farm": {
          "platform": "both",
          "hub": "http://<HUBIP>:31337" 
        }
      }
    }
  }
saikrishna321 commented 1 year ago

@skidnight can you please share full logs

skidnight commented 1 year ago

These are the hub/node logs from a run of one of my tests across two devices. It's probably worth noting the hub is running in a docker container without access to device connections, if that makes a difference. appium-hub.log appium-node.log

saikrishna321 commented 1 year ago

Please attach logs as gist. Hard to read as file

skidnight commented 1 year ago

@saikrishna321 https://gist.github.com/skidnight/fe5833fe9ea257510c2c8a6db5931874

saikrishna321 commented 1 year ago

@sudharsan-selvaraj Can you check this please? Error is from appium-dashboard

fwany21 commented 11 months ago

I am also experiencing the same issue with device-farm@8.4.6. Can you please let me know how to display the dashboard data for the devices connected to the node using what method?

To fix this problem arbitrarily, I applied the following method.

diff --git a/src/app/routers/grid.ts b/src/app/routers/grid.ts
index 2c46c0f..ec82816 100644
--- a/src/app/routers/grid.ts
+++ b/src/app/routers/grid.ts
@@ -35,8 +35,10 @@ async function getDevices(request: Request, response: Response) {
       deviceSessionMap[session.udid].push(session);
     });
     devices = devices.map((d) => {
-      d.dashboard_link = `${dashboardPluginUrl}?device_udid=${d.udid}&start_time=${SERVER_UP_TIME}`;
-      d.total_session_count = deviceSessionMap[d.udid]?.length || 0;
+      if (d.dashboard_link === null) {
+        d.dashboard_link = `${dashboardPluginUrl}?device_udid=${d.udid}&start_time=${SERVER_UP_TIME}`;
+      }
+      d.total_session_count = deviceSessionMap[d.udid]?.length || d.total_session_count;
       return d;
     });
   }
diff --git a/src/data-service/device-service.ts b/src/data-service/device-service.ts
index e9b80e9..b35c722 100644
--- a/src/data-service/device-service.ts
+++ b/src/data-service/device-service.ts
@@ -53,6 +53,14 @@ export async function addNewDevice(devices: IDevice[], host?: string): Promise<I
       }
     } else {
       log.debug(`Device "${device.udid}" already exists in database`);
+      (await ADTDatabase.DeviceModel)
+         .chain()
+         .find({ udid: device.udid })
+         .update(function (d: IDevice) {
+            d.host = device.host;
+            d.dashboard_link = device.dashboard_link;
+            d.total_session_count = device.total_session_count;
+          });
     }
   });

Using the data delivered by node on "/device-farm/api/register?type=add", we update the dashboard_link and total_session_count of the devices connected to the node. And when taking the data about devices from the dashboard, I pass the dashboard_link and total_session_count as they are.

In this way, I solved the problem arbitrarily.

sudharsan-selvaraj commented 11 months ago

Currently appium-dashboard plugin doesn't work well with HUB+NODE setup. All the session related data can only be views from the same appium process. Even with the above changes i'm not sure if the dashboard will still show the node details in the hub.

fwany21 commented 11 months ago

@sudharsan-selvaraj I am also not sure that it displays the information of Nodes perfectly on the hub. Also, I don't know what problems it will cause. However, I have confirmed that it operates at the level required in the environment I tested.

In this regard, I would like to inquire about something. Will you support the Dashboard in HUB + NODE environment? If you plan to apply, how would you like to display the Node's information? There seems to be a way to receive and store all data from the Node in the Hub and then display it in the Hub or connect it to the Node's dashboard.

Muratoi commented 6 months ago

any update on this? @sudharsan-selvaraj