Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT/DO NOT MERGE] [SELENIUM 4] 3.0 #311

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6a03040
feature: selenium 4
akamarouski Mar 6, 2024
e8780fe
change selenium version to 4.18.1
akamarouski Mar 2, 2024
622ea9c
modify agent
akamarouski Mar 2, 2024
47a6123
change selenium version to 4.17.0
akamarouski Mar 2, 2024
9e90404
change localhost to host.docker.internal
akamarouski Mar 5, 2024
70436af
minimize number of layers
akamarouski Mar 6, 2024
befa51c
experiment(entrypoint): add java.security.egd to the java command
akamarouski Mar 5, 2024
dc4fb65
add -XX:InitialRAMPercentage=50.0
akamarouski Mar 5, 2024
95747d1
add -XX:+UseG1GC -XX:+UseStringDeduplication
akamarouski Mar 5, 2024
c0c2d71
add -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10
akamarouski Mar 5, 2024
0c1a3ec
add &&
akamarouski Mar 5, 2024
45f0203
fix for ENTRYPOINT_DIR env variable
akamarouski Mar 5, 2024
a17ecd0
Revert "change localhost to host.docker.internal"
akamarouski Mar 5, 2024
d9174f0
change GC to -XX:+UseParallelGC
akamarouski Mar 5, 2024
473617e
feature: add slotCapabilities to the default caps generator
akamarouski Mar 6, 2024
54db680
add slotCapabilities to the android
akamarouski Mar 8, 2024
6956382
minimize shade jar
akamarouski Mar 8, 2024
90a9037
minimize shade jar
akamarouski Mar 8, 2024
711f4f6
disable minimize jar
akamarouski Mar 8, 2024
b3663e7
remove GC parameters
akamarouski Mar 8, 2024
f92f503
change GC to Serial
akamarouski Mar 8, 2024
979e826
feature: stf support (without manual reserve)
akamarouski Mar 8, 2024
b3c6384
changes
akamarouski Mar 9, 2024
e59dfa6
changes
akamarouski Mar 9, 2024
0d18285
changes
akamarouski Mar 9, 2024
594b6cc
changes
akamarouski Mar 9, 2024
cfa1f14
changes
akamarouski Mar 9, 2024
ca48b14
changes
akamarouski Mar 9, 2024
0dc5460
changes
akamarouski Mar 9, 2024
3a489c8
changes
akamarouski Mar 9, 2024
c412313
changes
akamarouski Mar 9, 2024
251a00a
change appium version for opencv
akamarouski Mar 9, 2024
6e83705
minimize layers amount for opencv
akamarouski Mar 9, 2024
a636c95
Revert "minimize layers amount for opencv"
akamarouski Mar 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
.idea/
target/
.project
target
bin
.classpath
/test-output
/.settings
**/.settings
/com
/application.log
/sql.log
*.checkstyle
.idea
*.iml
test-output
*.log
/reports
/out
dependency-reduced-pom.xml
.DS_Store
95 changes: 51 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM appium/appium:v2.2.2-p2

# Default appium 2.0 ueser:
# uid=1300(androidusr) gid=1301(androidusr) groups=1301(androidusr)
USER root

ENV PLATFORM_NAME=ANDROID
ENV DEVICE_UDID=

Expand All @@ -12,19 +17,9 @@ ENV APPIUM_APPS_DIR=/opt/appium-storage
ENV APPIUM_APP_WAITING_TIMEOUT=600
ENV APPIUM_MAX_LOCK_FILE_LIFETIME=1800
ENV APPIUM_APP_FETCH_RETRIES=0
ENV APPIUM_CLI=

ENV APPIUM_APP_SIZE_DISABLE=false

ENV APPIUM_PLUGINS=

# Default appium 2.0 ueser:
# uid=1300(androidusr) gid=1301(androidusr) groups=1301(androidusr)

USER root
RUN mkdir -p $APPIUM_APPS_DIR && \
chown androidusr:androidusr $APPIUM_APPS_DIR

################################################
######## APPIUM CONFIGURATION VARIABLES ########
# Android envs
ENV ADB_PORT=5037
ENV ANDROID_DEVICE=
Expand Down Expand Up @@ -70,48 +65,60 @@ ENV DEBUG=false
ENV DEBUG_TIMEOUT=3600
ENV VERBOSE=false

#Setup libimobile device, usbmuxd and some tools
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y install iputils-ping nano jq telnet netcat curl ffmpeg libimobiledevice-utils libimobiledevice6 usbmuxd socat
################################################
######### NODE CONFIGURATION VARIABLES #########
# Hub hostname or IP address
ENV SELENIUM_HOST localhost
# Hub port
ENV SELENIUM_PORT 4444
# How often, in seconds, the Node will try to register itself for the first time to the Distributor.
ENV REGISTER_CYCLE 300
# How long, in seconds, will the Node try to register to the Distributor for the first time.
# After this period is completed, the Node will not attempt to register again.
ENV REGISTER_PERIOD 1000
# How often, in seconds, will the Node send heartbeat events to the Distributor to inform it that the Node is up.
ENV HEARTBEAT_PERIOD 5
# Let X be the session-timeout in seconds.
# The Node will automatically kill a session that has not had any activity in the last X seconds.
# This will release the slot for other tests.
ENV GRID_BROWSER_TIMEOUT 180
#todo add description
ENV PUBLISH_EVENTS_PORT 4442
#todo add description
ENV SUBSCRIBE_EVENTS_PORT 4443
# Log level. Default logging level is INFO. Log levels are described here
# https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html
ENV NODE_LOG_LEVEL INFO
ENV HTTP_LOGS false
################################################
ENV ENTRYPOINT_DIR=/opt/entrypoint/

RUN mkdir -p $APPIUM_APPS_DIR && \
chown androidusr:androidusr $APPIUM_APPS_DIR && \
#Setup libimobile device, usbmuxd and some tools
export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y install iputils-ping nano jq telnet netcat curl ffmpeg libimobiledevice-utils libimobiledevice6 usbmuxd socat && \
#Grab gidevice from github and extract it in a folder
RUN wget https://github.com/danielpaulus/go-ios/releases/download/v1.0.120/go-ios-linux.zip
wget https://github.com/danielpaulus/go-ios/releases/download/v1.0.120/go-ios-linux.zip && \
# https://github.com/danielpaulus/go-ios/releases/latest/download/go-ios-linux.zip
RUN unzip go-ios-linux.zip -d /usr/local/bin

COPY files/start-capture-artifacts.sh /opt
unzip go-ios-linux.zip -d /usr/local/bin && \
mkdir -p ${ENTRYPOINT_DIR} && \
#TODO: migrate everything to androiduser
#USER androidusr
appium driver list && \
appium plugin list && \
#TODO:/ think about different images per each device platform
appium driver install uiautomator2 && \
appium driver install xcuitest@5.7.0

# Zebrunner MCloud node config generator
COPY files/debug.sh /opt
COPY files/android.sh /opt
COPY files/ios.sh /opt
COPY files/start-wda.sh /opt
COPY files/check-wda.sh /opt
COPY files/zbr-config-gen.sh /opt
COPY files/zbr-default-caps-gen.sh /opt

ENV ENTRYPOINT_DIR=/opt/entrypoint
RUN mkdir -p ${ENTRYPOINT_DIR}
COPY entrypoint.sh ${ENTRYPOINT_DIR}
COPY device_connect.sh ${ENTRYPOINT_DIR}
COPY files/debug.sh files/start-capture-artifacts.sh files/android.sh files/ios.sh files/start-wda.sh files/check-wda.sh files/zbr-config-gen.sh files/zbr-default-caps-gen.sh target/mcloud-node-1.0.jar target/mcloud-node.jar agent/target/mcloud-node-agent-1.0.jar agent/target/mcloud-node-agent.jar /opt/
COPY entrypoint.sh device_connect.sh ${ENTRYPOINT_DIR}

#TODO: think about entrypoint container usage to apply permission fixes
#RUN chown -R androidusr:androidusr $ENTRYPOINT_DIR

# Healthcheck
COPY files/healthcheck /usr/local/bin
COPY files/usbreset /usr/local/bin

#TODO: migrate everything to androiduser
#USER androidusr


RUN appium driver list && \
appium plugin list

#TODO:/ think about different images per each device platform
RUN appium driver install uiautomator2 && \
appium driver install xcuitest@5.7.0

COPY files/healthcheck files/usbreset /usr/local/bin/
# Custom mcloud patches
COPY files/mcloud/ /opt/mcloud
# do not make backups because unpatched js files in the same folder might be used by Appium
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-opencv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/zebrunner/appium:2.0.11
FROM public.ecr.aws/zebrunner/appium:3.0-beta39

ENV APPIUM_PLUGINS=images

Expand Down
140 changes: 140 additions & 0 deletions agent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zebrunner</groupId>
<artifactId>mcloud-node-agent</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Zebrunner Device Farm (Selenium Grid Node Agent)</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<selenium.version>4.13.0</selenium.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<jackson-databind.version>2.16.0</jackson-databind.version>
<httpclient.version>5.2.2</httpclient.version>
<genson.version>1.6</genson.version>
<jersey-bundle.version>1.19.4</jersey-bundle.version>
<lombok.version>1.18.30</lombok.version>
<maven-shade-plugin.version>3.5.0</maven-shade-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-grid</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<!--we need it to reuse benefits of zebrunner testng agent for webdriver
sesssion(s) declaration -->
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>${genson.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>${jersey-bundle.version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>3.0.0-M1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<transformers>
<!-- Don't do this: Avoid adding anything that makes shade create or modify a manifest file.
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.mypackage.MyMainClass</mainClass>
</transformer>
-->
<!-- Add a transformer to exclude any other manifest files (possibly from dependencies). -->
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>MANIFEST.MF</resource>
</transformer>

<!-- Add a transformer to include your custom manifest file. -->
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>META-INF/MANIFEST.MF</resource>
<file>src/main/resources/META-INF/MANIFEST.MF</file>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<finalName>mcloud-node-agent</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright 2018-2021 Zebrunner (https://zebrunner.com/).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.zebrunner.mcloud.grid.agent;

import com.zebrunner.mcloud.grid.agent.validator.DeviceNameValidator;
import com.zebrunner.mcloud.grid.agent.validator.DeviceTypeValidator;
import com.zebrunner.mcloud.grid.agent.validator.MobilePlatformValidator;
import com.zebrunner.mcloud.grid.agent.validator.PlatformVersionValidator;
import com.zebrunner.mcloud.grid.agent.validator.UDIDValidator;
import com.zebrunner.mcloud.grid.agent.validator.Validator;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.grid.data.DefaultSlotMatcher;
import org.openqa.selenium.remote.CapabilityType;

import java.util.List;
import java.util.logging.Logger;

import static com.zebrunner.mcloud.grid.agent.util.CapabilityUtils.getAppiumCapability;

@SuppressWarnings("unused")
public final class MobileCapabilityMatcher extends DefaultSlotMatcher {
private static final Logger LOGGER = Logger.getLogger(MobileCapabilityMatcher.class.getName());
private final List<Validator> validators = List.of(
new MobilePlatformValidator(),
new PlatformVersionValidator(),
new DeviceNameValidator(),
new DeviceTypeValidator(),
new UDIDValidator());

@Override
public boolean matches(Capabilities stereotype, Capabilities capabilities) {
LOGGER.info(() -> "Requested capabilities: " + capabilities);
LOGGER.info(() -> "Stereotype capabilities: " + stereotype);
if (capabilities.getCapability(CapabilityType.PLATFORM_NAME) != null ||
getAppiumCapability(capabilities, "platformVersion", Object.class) != null ||
getAppiumCapability(capabilities, "deviceName", Object.class) != null ||
getAppiumCapability(capabilities, "udid", Object.class) != null) {
// Mobile-based capabilities
LOGGER.info("Using extensionCapabilityCheck matcher.");
return extensionCapabilityCheck(stereotype, capabilities);
} else {
// Browser-based capabilities
LOGGER.info("Using default browser-based capabilities matcher.");
return super.matches(stereotype, capabilities);
}
}

/**
* Verifies matching between requested and actual node capabilities.
*
* @param stereotype node capabilities
* @param capabilities capabilities requested by client
* @return match results
*/
private boolean extensionCapabilityCheck(Capabilities stereotype, Capabilities capabilities) {
if (stereotype == null) {
LOGGER.info("stereotype - NULL");
}
if (capabilities == null) {
LOGGER.info("capabilities - NULL");
}
boolean matches = stereotype != null &&
capabilities != null &&
validators.stream()
.allMatch(v -> v.apply(stereotype, capabilities));
LOGGER.info(() -> "[MATCHES]" + matches);
return matches;
}
}
Loading