Appium tests on Amazon device farm getting stuck in custom test environment stuck at npm install *.tgz - appium

I have android tests written in webdriverIO, appium. Running fine on my local machine. But on Amazon device farm execution getting stuck in custom test environment at npm install *.tgz.
Tech stack selected on amazon device farm: node 14.19.1 appium 1.22.2
# Phases are collection of commands that get executed on Device Farm.
phases:
# The install phase includes commands that install dependencies that your tests use.
# Default dependencies for testing frameworks supported on Device Farm are already installed.
install:
commands:
# By default the Node.js version installed is 11.4.0, however we enable you to change it
# using the Node version manager (nvm). An example "nvm" command below changes the version to 14.19.1
- export NVM_DIR=$HOME/.nvm
- . $NVM_DIR/nvm.sh
- nvm install 14.19.1
# Unpackage and install the node modules that you uploaded in the test phase.
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- npm install *.tgz
# This test execution environment uses Appium version 1.9.1 by default, however we enable you to change it using
# the Appium version manager (avm). An example "avm" command below changes the version to 1.22.2.
# For your convenience, we have preinstalled the following versions: 1.22.2, 1.19.0, 1.18.3, 1.18.1, 1.18.0, 1.17.1, 1.16.0, 1.15.1, 1.14.2, 1.14.1, and 1.13.0.
# To use one of these Appium versions, change the version number in the "avm" command below to your desired version:
- export APPIUM_VERSION=1.22.2
- avm $APPIUM_VERSION
- ln -s /usr/local/avm/versions/$APPIUM_VERSION/node_modules/.bin/appium /usr/local/avm/versions/$APPIUM_VERSION/node_modules/appium/bin/appium.js
# The pre-test phase includes commands that setup your test environment.
pre_test:
commands:
# We recommend starting appium server process in the background using the command below.
# Appium server log will go to $DEVICEFARM_LOG_DIR directory.
# The environment variables below will be auto-populated during run time.
- echo "Start appium server"
- >-
appium --log-timestamp
--default-capabilities "{\"deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \"platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\",
\"app\":\"$DEVICEFARM_APP_PATH\", \"udid\":\"$DEVICEFARM_DEVICE_UDID\", \"platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\",
\"chromedriverExecutable\":\"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE\"}"
>> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &
- >-
start_appium_timeout=0;
while [ true ];
do
if [ $start_appium_timeout -gt 60 ];
then
echo "appium server never started in 60 seconds. Exiting";
exit 1;
fi;
grep -i "Appium REST http interface listener started on 0.0.0.0:4723" $DEVICEFARM_LOG_DIR/appiumlog.txt >> /dev/null 2>&1;
if [ $? -eq 0 ];
then
echo "Appium REST http interface listener started on 0.0.0.0:4723";
break;
else
echo "Waiting for appium server to start. Sleeping for 1 second";
sleep 1;
start_appium_timeout=$((start_appium_timeout+1));
fi;
done;
# The test phase includes commands that start your test suite execution.
test:
commands:
# Go into the root folder containing your source code and node_modules
- echo "Navigate to test source code"
# Change the directory to node_modules folder as it has your test code and the dependency node modules.
- cd $DEVICEFARM_TEST_PACKAGE_PATH/node_modules/*
- echo "Start Appium Node test"
# Enter the command below to start the tests . The comamnd should be similar to what you use to run the tests locally.
# For e.g. assuming you run your tests locally using command "node YOUR_TEST_FILENAME.js.", enter the same command below:
- npm run test:adf:android
# The post test phase includes are commands that are run after your tests are executed.
post_test:
commands:
# The artifacts phase lets you specify the location where your tests logs, device logs will be stored.
# And also let you specify the location of your test logs and artifacts which you want to be collected by Device Farm.
# These logs and artifacts will be available through ListArtifacts API in Device Farm.
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_LOG_DIR
I followed this blog to setup amazon device farm set up amazon device farm

Related

How to generate and display coverage when running tests with Pongo for custom Kong API Gateway plugins written in Lua

I am writing a few kong custom plugins in Lua. I am using Kong 2.3.3 and Lua 5.1.
I have some test cases (unit tests + integration tests) and i am running them with pongo run -coverage option. I have already installed luacov (and also cluacov, both with luarocks install) and all my tests are passing but no luacov files are being generated with coverage data. I am not running pongo from Docker, i have installed and configured it in my local machine (which is Linux Ubuntu 20.04).
I have already tried a few things as follows:
my .busted file is setting coverage = true, verbose = true and output = "gtest" (already tried utfTerminal, tap and json too)
tried adding luacov as a dependency to my rockspec file... the build does not fail but no coverage file is generated
i even tried running the tests without pongo, using busted directly but this is a very bad option because things like spec.helpers, or the cjson lib are not set in my LUAPATH
A quick way to do this is to modify pongo
Edit your pongo.sh file to:
add coverage flag to busted --coverage
call luacov to generate the report luacov
display the report cat luacov.report.out
locate where busted is called, line 959 for me:
"/bin/sh" "-c" "bin/busted --coverage --helper=bin/busted_helper.lua ${busted_params[*]} ${busted_files[*]};luacov;cat luacov.report.out"
Install luacov, edit assets/Dockerfile
after busted installation add luacov:
&& luarocks install busted-htest \
&& luarocks install luacov \
pongo run will give you
[...]
==============================================================================
Summary
==============================================================================
File Hits Missed Coverage
-------------------------------------------------------------------------------------------------------
/kong-plugin/kong/plugins/myplugin/schema.lua 105 1 99.06%
/kong-plugin/spec/myplugin/01-schema_spec.lua 199 5 97.55%
[...]
You can create a docker image based on pongo
spec/unit/docker/Dockerfile
FROM kong-pongo-test:2.3.2
USER root
RUN luarocks install luacov
WORKDIR /kong-plugin
COPY . .
spec/unit/docker/run.sh
#!/bin/sh
busted --coverage spec/unit
luacov
cat luacov.report.out
Run
docker build -f spec/unit/docker/Dockerfile -t my-coverage .
docker run my-coverage sh spec/unit/docker/run.sh
Pongo gained some support for this (still a PR). Note that it only covers unit tests, not integration ones.
See https://github.com/Kong/kong-pongo/pull/184
btw: the other anwers are too complex imo, you can add .pongo/pongo-setup.sh to install LuaCov, and move the .luacov file from /kong-plugin to /kong. That should be all that is necessary.
Running tests with coverage can be simply done by passing the flag, without any need to edit pongo or the dockerfile. Try pongo run -- --coverage for example.

Jenkins/Robot Framework - looking for chromedriver but I think it's in PATH

Hey in Jenkins I'm trying to run robot framework tests:
with command python3 robot -d results mytestsuite.robot, and it has some line to open chrome browser, but the message in log shows me typical: WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see...
Everything works ok locally, and I'm not sure which PATH jenkins wants to use so my questions are:
why do I have to input python3 instead of python (with just python in command it tells me that robot is not found)
why chromedriver is not found, and how to set it up (in what PATH and how) to make it work
Is it possible to set jenkins up to use other drivers ex. geckodriver?
My jenkins job env looks like this:
#!/bin/bash
echo $JENKINS_HOME
which python3
echo $PATH
outputs:
/Users/MYUSER/.jenkins
/usr/bin/python3
/Users/MYUSER/.jenkins/tools/chromedriver:/usr/bin:/bin:/usr/sbin:/sbin
Ok so I've fixed it with:
export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin/:$PATH
this is the location where I have chromedriver locally.
in the build shell execute but is there a way to make it more permanent (I mean not to use it every time it runs build?)

How to setup a Travis/Rails project to submit to Coverity Scan?

I'm looking for a std travis coverity setup for a rails application.
My current .travis.yml file looks like this:
# environment settings
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "<SECURE>"
# project language
language: ruby
rvm:
- 2.3.1
# branches to build (whitelist)
branches:
only:
- master
- coverity_scan
- testing
# command to run before install
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
# arguments for the bundler
bundler_args: --without production development
# addons
addons:
coverity_scan:
project:
name: "<PROJECT_NAME>"
description: "Build submitted via Travis CI"
notification_email: <MY_EMAIL>
build_command_prepend: ""
build_command: "--no-command"
branch_pattern: coverity_scan
# script
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
- bundle exec cucumber
# run before script
before_script:
- mysql -e 'create database my_app_test'
- psql -c 'create database my_app_test' -U postgres
I'm not sure what to put in the build_command part of addons.coverity_scan. I already tried leaving it empty, --no-command, bundle install, and bundle install --jobs=3 --retry=3, but none of them worked. --no_command, for example, gives me the following message:
Coverity Scan analysis selected for branch coverity_scan.
Coverity Scan analysis authorized per quota.
$ curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | COVERITY_SCAN_PROJECT_NAME="$PROJECT_NAME" COVERITY_SCAN_NOTIFICATION_EMAIL="<MY_EMAIL>" COVERITY_SCAN_BUILD_COMMAND="--no-command" COVERITY_SCAN_BUILD_COMMAND_PREPEND="" COVERITY_SCAN_BRANCH_PATTERN=coverity_scan bash
Note: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com
Coverity Scan configured to run on branch coverity_scan
Coverity Scan analysis authorized per quota.
Downloading Coverity Scan Analysis Tool...
2016-09-13 23:26:36 URL:https://scan.coverity.com/download/Linux [449455458/449455458] -> "/tmp/cov-analysis-Linux.tgz" [1]
Extracting Coverity Scan Analysis Tool...
/tmp/coverity-scan-analysis ~/build/<PROJECT_NAME>
~/build/<PROJECT_NAME>
Running Coverity Scan Analysis Tool...
Coverity Build Capture (64-bit) version 8.5.0.3 on Linux 3.13.0-92-generic x86_64
Internal version numbers: db70178643 p-kent-push-26368.949
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
/home/travis/build/<PROJECT_NAME>/cov-int/build-log.txt
Extracting SCM data for 0 files...
Please see the log file '/home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt' for warnings and SCM command issues.
[WARNING] Unable to gather all SCM data - see log at /home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt for details.
Successfully added SCM data for 0 files
Tarring Coverity Scan Analysis results...
Uploading Coverity Scan Analysis results...
And because I'm using travis I'm not able to look into the log files...
When the command is empty it fails with the error, that a command needs to be given and it does nothing.
Can someone help me with some kind of a std setup for a rails app?
Thanks in advance!
Instructions for using Coverity SCAN the new languages supported by 8.5 are found here : https://scan.coverity.com/download?tab=other . We assume that users first read these instructions prior to attempting TravisCI integration. It is also highly recommended that local integration is tested to ensure clean captures before attempting any CI.
Ruby is supported in Coverity 8.5. Debugging this is difficult without the log. It's possible the SCAN kit is missing a config for Ruby, which can be fixed by running cov-configure --ruby.
The more likely problem, however, is that Ruby is what Coverity considers a "non-compiled" language (meaning you don't usually have a build that compiles them before they can be used). So this means you need to inform cov-build about where your Ruby files are. Looking at your travis config, I expect you need to add this to your build_command: --fs-capture-search /path/to/your/ruby/files
It seems that it is not possible to analyse rails (interpreted ones in general) projects (correct me if I'm wrong). I deleted my project from coverity.

Compass compile on Jenkins CI

I have the following execute script on my CI environment
cd /var/www/html
php vendor/bin/phpunit app/tests --log-junit /var/lib/jenkins/jobs/Closecall/workspace/tests/reports/junit.xml
php vendor/bin/phinx migrate -e development
sudo compass compile
SSHing onto the CI and compiling myself works fine, however when the CI executes this on build I get the following error
+ sudo compass compile
sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
Recording test results
Finished: FAILURE
Any ideas?
sudo by default tries to open /dev/tty for read-write. You might not have /dev/tty available on the machine you use to build. The need for tty is configured in the /etc/sudoers file.
sudo has an option -S to read the password from standard input instead of /dev/tty. You should be able to compile using sudo -S.
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
http://linux.die.net/man/8/sudo

Xcode Build script after compile

I'm developing for jailbroken devices, and have gotten Xcode building and debugging workin on device with a self signed certificate and some edits to Xcode.
But the app I'm developing requires being able to call setuid(0), thus it needs to have chmod +s in order to run properly.
Apart from this iOS apps that needs to run as root need a bash script to invoke it like such:
#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/App\ Binary_ "$#"
So, I need this build script to run on building my app:
cd ${BUILT_PRODUCTS_DIR}/My\ App.app/
mv App_Binary App_Binary_
cp /Users/john/Shellscript Binary_App
chmod +s Binary_App_
chmod +x Binary_App
I've tried adding this as a normal build script, and as a part of the scheme as both a Build post-action or a Run Pre-action. Neither which has worked. For example a post-action script on build returns that code signing failed, since it tries to codesign App Binary that is now the shell script. If I do it as a pre-action script on Run it displays "Xcode cannot run using the selected device.Choose a destination with a supported architecture in order to run on this device."
What should I do?
I use a post-action script to build my jailbreak apps. Although they don't need an additional chmod or bash script to run, you could use a script like mine to install your app (as a system app, not a normal App Store app) using ssh, then perform the chmod command and swapping the binary with a bash script on device via the post-action script.
You could try something along these lines (I tried to use the details from your script, but there may be one or two mistakes):
# copy binary
scp -P $PORT -r $BUILT_PRODUCTS_DIR/${WRAPPER_NAME} root#$IPOD://private/var/stash/Applications/${WRAPPER_NAME}/App_Binary_
# copy script
scp -P $PORT /Users/john/Shellscript root#$IPOD://private/var/stash/Applications/${WRAPPER_NAME}/Binary_App
# set special permissions
ssh -p $PORT root#$IPOD "chmod +s /private/var/stash/Applications/${WRAPPER_NAME}/Binary_App_"
ssh -p $PORT root#$IPOD "chmod +x /private/var/stash/Applications/${WRAPPER_NAME}/Binary_App"
Set IPOD and PORT as appropriate. ${WRAPPER_NAME} is the name of the app as saved on disk, with the .app extension.
Actually, this could be done if you need your app to be installed as a normal App Store app as well, you'd just need to find out where it's been installed to and adjust the paths as appropriate.
You'll obviously need to have SSH installed and activated on your device (available on Cydia).

Resources