appium-device-farm icon indicating copy to clipboard operation
appium-device-farm copied to clipboard

Remote sessions do not display on hub

Open skidnight opened this issue 2 years ago • 9 comments

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" 
        }
      }
    }
  }

skidnight avatar Mar 30 '23 16:03 skidnight

@skidnight can you please share full logs

saikrishna321 avatar Mar 30 '23 17:03 saikrishna321

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

skidnight avatar Mar 30 '23 17:03 skidnight

Please attach logs as gist. Hard to read as file

saikrishna321 avatar Mar 31 '23 07:03 saikrishna321

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

skidnight avatar Mar 31 '23 12:03 skidnight

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

saikrishna321 avatar Mar 31 '23 14:03 saikrishna321

I am also experiencing the same issue with [email protected]. 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.

fwany21 avatar Jan 05 '24 06:01 fwany21

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.

sudharsan-selvaraj avatar Jan 05 '24 08:01 sudharsan-selvaraj

@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.

fwany21 avatar Jan 08 '24 00:01 fwany21

any update on this? @sudharsan-selvaraj

Muratoi avatar May 13 '24 21:05 Muratoi