Added integration with Genymotion in AWS
This commit is contained in:
parent
d7c9730712
commit
dd7ef41590
|
@ -103,6 +103,16 @@ RUN wget -nv -O genymotion.bin "https://dl.genymotion.com/releases/genymotion-${
|
||||||
&& rm genymotion.bin
|
&& rm genymotion.bin
|
||||||
COPY genymotion/generate_config.sh genymotion/geny_start.sh /root/
|
COPY genymotion/generate_config.sh genymotion/geny_start.sh /root/
|
||||||
|
|
||||||
|
#===================
|
||||||
|
# Install Terraform
|
||||||
|
#===================
|
||||||
|
ARG TERRAFORM_VERSION=0.11.7
|
||||||
|
|
||||||
|
ENV TERRAFORM_VERSION=$TERRAFORM_VERSION
|
||||||
|
RUN wget -nv -O terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
||||||
|
&& unzip -x terraform.zip \
|
||||||
|
&& rm terraform.zip
|
||||||
|
|
||||||
#===============
|
#===============
|
||||||
# Expose Ports
|
# Expose Ports
|
||||||
#---------------
|
#---------------
|
||||||
|
|
|
@ -11,10 +11,11 @@ services:
|
||||||
- 4444:4444
|
- 4444:4444
|
||||||
|
|
||||||
# Please stop this container by using docker stop instead of docker-compose stop
|
# Please stop this container by using docker stop instead of docker-compose stop
|
||||||
genymotion:
|
cloud:
|
||||||
image: butomo1989/docker-android-genymotion
|
image: butomo1989/docker-android-genymotion
|
||||||
depends_on:
|
depends_on:
|
||||||
- selenium_hub
|
- selenium_hub
|
||||||
|
privileged: true
|
||||||
ports:
|
ports:
|
||||||
- 6080:6080
|
- 6080:6080
|
||||||
- 4723:4723
|
- 4723:4723
|
||||||
|
@ -22,8 +23,28 @@ services:
|
||||||
- $PWD/sample_apk:/root/tmp/sample_apk
|
- $PWD/sample_apk:/root/tmp/sample_apk
|
||||||
- $PWD/sample_devices:/root/tmp
|
- $PWD/sample_devices:/root/tmp
|
||||||
environment:
|
environment:
|
||||||
- GENY_TEMPLATE=/root/tmp/devices.json
|
- TYPE=genycloud
|
||||||
- USER=xxx
|
- TEMPLATE=/root/tmp/devices.json
|
||||||
- PASS=xxx
|
- USER=$USER
|
||||||
- LICENSE=xxx
|
- PASS=$PASS
|
||||||
|
- LICENSE=$LICENSE
|
||||||
- CONNECT_TO_GRID=true
|
- CONNECT_TO_GRID=true
|
||||||
|
|
||||||
|
# Please stop this container by using docker stop instead of docker-compose stop
|
||||||
|
# The implementation still in progress
|
||||||
|
aws:
|
||||||
|
image: butomo1989/docker-android-genymotion
|
||||||
|
depends_on:
|
||||||
|
- selenium_hub
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 6080:6080
|
||||||
|
- 4723:4723
|
||||||
|
volumes:
|
||||||
|
- ~/.aws:/root/.aws
|
||||||
|
- $PWD/sample_apk:/root/tmp/sample_apk
|
||||||
|
- $PWD/sample_devices:/root/tmp
|
||||||
|
environment:
|
||||||
|
- TYPE=aws
|
||||||
|
- TEMPLATE=/root/tmp/aws.json
|
||||||
|
#TODO - CONNECT_TO_GRID=true
|
||||||
|
|
12
genymotion/example/sample_devices/aws.json
Executable file
12
genymotion/example/sample_devices/aws.json
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"region": "eu-west-1",
|
||||||
|
"ami": "ami-861125ff",
|
||||||
|
"instance": "t2.small"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"region": "eu-west-1",
|
||||||
|
"ami": "ami-861125ff",
|
||||||
|
"instance": "t2.small"
|
||||||
|
}
|
||||||
|
]
|
3
genymotion/example/start_compose.sh
Executable file
3
genymotion/example/start_compose.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
(export USER=$USER && export PASS=$PASS && export LICENSE=$LICENSE && docker-compose -f geny.yml up -d)
|
|
@ -1,18 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This script is needed because of https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
|
# This script is needed because of https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
|
||||||
|
|
||||||
if [ -z "$GENY_TEMPLATE" ]; then
|
types=(genycloud aws)
|
||||||
GENY_TEMPLATE="/root/tmp/devices.json"
|
|
||||||
|
if [ -z "$TYPE" ]; then
|
||||||
|
echo "Please specify one of following types: ${types[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TYPE=$(echo "$TYPE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
if [ -z "$TEMPLATE" ]; then
|
||||||
|
case $TYPE in
|
||||||
|
"${types[0]}" )
|
||||||
|
TEMPLATE="/root/tmp/devices.json"
|
||||||
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
TEMPLATE="/root/tmp/aws.json"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
"Type $TYPE is not supported! Valid types: ${types[@]}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$GENY_TEMPLATE" ]; then
|
if [ ! -f "$TEMPLATE" ]; then
|
||||||
echo "File not found! Nothing to do!"
|
echo "File not found! Nothing to do!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[geny_start] Available types: ${types[@]}"
|
||||||
|
echo "[geny_start] Selected type of deployment: $TYPE, Template file: $TEMPLATE"
|
||||||
|
export TYPE=$TYPE
|
||||||
|
export TEMPLATE=$TEMPLATE
|
||||||
|
export TYPES=${types[@]}
|
||||||
|
|
||||||
getAbort() {
|
getAbort() {
|
||||||
if [ "$GENYMOTION" = true ]; then
|
case $TYPE in
|
||||||
contents=$(cat $GENY_TEMPLATE)
|
"${types[0]}" )
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
echo "ABORT SIGNAL detected! Stopping all created emulators..."
|
echo "ABORT SIGNAL detected! Stopping all created emulators..."
|
||||||
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
||||||
get_value() {
|
get_value() {
|
||||||
|
@ -22,7 +48,13 @@ getAbort() {
|
||||||
gmtool --cloud admin stopdisposable $(get_value '.device')
|
gmtool --cloud admin stopdisposable $(get_value '.device')
|
||||||
done
|
done
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
|
echo "ABORT SIGNAL detected! Detroy all EC2 instance(s)..."
|
||||||
|
./terraform destroy -auto-approve
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
trap 'getAbort; exit' EXIT
|
trap 'getAbort; exit' EXIT
|
||||||
|
|
||||||
|
|
109
src/appium.sh
109
src/appium.sh
|
@ -1,13 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$GENY_TEMPLATE" ]; then
|
types=($TYPES)
|
||||||
GENY_TEMPLATE="/root/tmp/devices.json"
|
echo "Available types: ${types[@]}"
|
||||||
fi
|
echo "Selected type of deployment: $TYPE, Template file: $TEMPLATE"
|
||||||
|
|
||||||
function prepare_geny_cloud() {
|
function prepare_geny_cloud() {
|
||||||
contents=$(cat $GENY_TEMPLATE)
|
contents=$(cat $TEMPLATE)
|
||||||
|
|
||||||
# Register
|
# Register
|
||||||
|
echo "Register user"
|
||||||
gmtool config username="${USER}" password="${PASS}"
|
gmtool config username="${USER}" password="${PASS}"
|
||||||
gmtool license register "${LICENSE}"
|
gmtool license register "${LICENSE}"
|
||||||
|
|
||||||
|
@ -32,6 +33,95 @@ function prepare_geny_cloud() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepare_geny_aws() {
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
|
|
||||||
|
# Creating aws tf file(s)
|
||||||
|
echo "Creating tf file(s)"
|
||||||
|
index=1
|
||||||
|
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
||||||
|
get_value() {
|
||||||
|
echo ${row} | base64 --decode | jq -r ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
region=$(get_value '.region')
|
||||||
|
ami=$(get_value '.ami')
|
||||||
|
instance=$(get_value '.instance')
|
||||||
|
|
||||||
|
|
||||||
|
echo $region
|
||||||
|
echo $ami
|
||||||
|
echo $instance
|
||||||
|
|
||||||
|
aws_tf_content=$(cat <<_EOF
|
||||||
|
variable "aws_region_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$region"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ami_id_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$ami"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "instance_type_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$instance"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "aws" {
|
||||||
|
alias = "provider_$index"
|
||||||
|
region = "\${var.aws_region_$index}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "geny_sg_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
name = "geny_sg_$index"
|
||||||
|
description = "Security group for EC2 instance of Genymotion"
|
||||||
|
ingress {
|
||||||
|
from_port = 0
|
||||||
|
to_port = 65535
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "geny_aws_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
ami = "\${var.ami_id_$index}"
|
||||||
|
instance_type = "\${var.instance_type_$index}"
|
||||||
|
|
||||||
|
vpc_security_group_ids = ["\${aws_security_group.geny_sg_$index.name}"]
|
||||||
|
|
||||||
|
tags {
|
||||||
|
Name = "EK-\${var.ami_id_$index}"
|
||||||
|
}
|
||||||
|
count = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
output "instance_id_$index" {
|
||||||
|
value = "\${aws_instance.geny_aws_$index.*.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "public_dns_$index" {
|
||||||
|
value = "\${aws_instance.geny_aws_$index.*.public_dns}"
|
||||||
|
}
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
echo "$aws_tf_content" > /root/aws_tf_$index.tf
|
||||||
|
((index++))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Deploy EC2 instance(s)
|
||||||
|
echo "Deploy EC2 instance(s) on AWS with Genymotion image based on given json file..."
|
||||||
|
./terraform init
|
||||||
|
./terraform plan
|
||||||
|
./terraform apply -auto-approve
|
||||||
|
|
||||||
|
# Connect with adb
|
||||||
|
# TODO
|
||||||
|
}
|
||||||
|
|
||||||
function run_appium() {
|
function run_appium() {
|
||||||
echo "Preparing appium-server..."
|
echo "Preparing appium-server..."
|
||||||
CMD="appium --log $APPIUM_LOG"
|
CMD="appium --log $APPIUM_LOG"
|
||||||
|
@ -54,8 +144,19 @@ if [ "$REAL_DEVICE" = true ]; then
|
||||||
run_appium
|
run_appium
|
||||||
elif [ "$GENYMOTION" = true ]; then
|
elif [ "$GENYMOTION" = true ]; then
|
||||||
echo "Using Genymotion"
|
echo "Using Genymotion"
|
||||||
|
echo "${types[@]}"
|
||||||
|
case $TYPE in
|
||||||
|
"${types[0]}" )
|
||||||
|
echo "Using Genymotion-Cloud"
|
||||||
prepare_geny_cloud
|
prepare_geny_cloud
|
||||||
run_appium
|
run_appium
|
||||||
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
echo "Using Genymotion-AWS"
|
||||||
|
prepare_geny_aws
|
||||||
|
# TODO: please activate this: run_appium
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo "Using Emulator"
|
echo "Using Emulator"
|
||||||
python3 -m src.app
|
python3 -m src.app
|
||||||
|
|
Loading…
Reference in a new issue