Spinning up appium whenever it's needed or keep it alive all the time

Im facing this issue that I can’t find a solution for:
I always keep appium instance alive and waiting for commands. When I run my regression suite at midnight the first test case always fails because it just times out and later it runs fine. So I was debating on how to solve it: either spin up appium every time my test is about to run and then kill the service after or always somehow keep it alive that the first test case does not fail. Could you please share your thoughts about the situation?

By the way my Jenkins job starts at 12 AM every day and that’s how I kick off the jobs.

Hi @lludas:
As you’ll probably hear, there’s many ways to do this.
What I do as part of my jenkins jobs:

  1. Check for any new builds on our build system.
  2. Pull them down/install/sign if needed.
  3. Then check for any existing appium processes.
  4. If so, kill them.
  5. Then start fresh.

There may be a more elegant way, but I always seem to have success with this so far.

@shermaneric thank you for the suggestions. I am trying to implement them, but cannot find a good way of killing and starting Appium processes on the fly. Would you be be able to assist me with that?

Thank you

Hi Liudas,
Basically, I run everything off of this shell script (take off .txt on file extention)run_appium.sh.txt (2.7 KB)

If I’m running this standalone, the syntax is something like this:

../run_appium.sh android device    #for example  ($1=platform;$2=device or simulator)

Then, in another terminal window

rake android_local_device  #This task is defined in my rakefile.  it starts cucumber

I have a Rakefile task whose job is to restart appium:

task :start_appium, [:platform, :hardware] do |t, args|
   sh "../run_appium.sh #{args[:platform]} #{args[:hardware]} &"
end

I have another Rakefile task whose job is to tie all of this together:

task :ci_android, [:public_id] do  |t, args|
  Rake::Task["fetch_latest_build"].invoke("android")
  Rake::Task["start_appium"].invoke("android", "device")
  puts "Waiting for appium to start.  Not an intelligent wait"
  sleep 35
  puts "going to start cucumber"

  ENV['PUBLIC_ID']= args[:public_id]; Rake::Task["android_local_device"].execute
end

Then my jenkins job looks like this:

cd "${HOME}/Documents/git_stash_qa_automation.d/qa-automation/appium-student.d" 
rake ci_android["3A7MYY"]

hope it helps. feel free to ask me if any questions.
thanks!
Eric

1 Like