我設立一個連續傳遞管道其中,執行[等待tomcat7]動作來看,
- 創建一個新的AWS實例,
- 安裝所有必要的軟件來運行Web應用程序,
- 部署web應用到tomcat和
- 運行從GitHub的測試回購部署了一些耙測試。
所有的已經很不錯了。我已經建立了詹金斯用下面的命令來執行shell腳本,
sudo knife ec2 server create -r 'recipe[apt],recipe[java],recipe[mysql_install],recipe[tomcat],recipe[deploy_tests_from_github],recipe[configure_db],recipe[deploy-app],recipe[start_tests]' -V
的部署去罰款。唯一的問題是,當測試開始時,Chef似乎關閉了tomcat,因此Watir無法瀏覽到Web應用程序。
大多數的食譜是由廚師超市直克隆,我使用這個食譜爲Tomcat https://supermarket.chef.io/cookbooks/tomcat
和我start_test食譜很簡單
execute "start_test" do
command '/usr/local/bin/rake'
cwd '/Watir_tests/test'
end
這裏是我的輸出的一部分,
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0mRecipe: Deploy_App
::default[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com * service[tomcat7] action stop
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- stop service service[tomcat7][0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m * execute[wait for tomcat7] action run
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- execute sleep 5[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m * remote_file[MyApp.war] action create
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- create new file /var/lib/tomcat7/webapps/MyApp.war[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- update content in file /var/lib/tomcat7/webapps/MyApp.war from none to cd2ac4[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [37m(file sizes exceed 10000000 bytes, diff output suppressed)[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m * service[tomcat7] action start
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- start service service[tomcat7][0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m * execute[wait for tomcat7] action run
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [32m- execute sleep 5[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0mRecipe: start_tests::default[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com * execute[start_test] action run
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com ================================================================================[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [31mError executing action `run` on resource 'execute[start_test]'[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com ================================================================================[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m Mixlib::ShellOut::ShellCommandFailed[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com ------------------------------------[0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com Expected process to exit with [0], but received '1'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m ---- Begin output of /usr/local/bin/rake ----
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m STDOUT: Run options: --seed 62510
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m # Running:
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m EEEEEE
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m Finished in 330.793031s, 0.0181 runs/s, 0.0000 assertions/s.
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
Error:
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m LogInWithWrongPasswordTest#test_log_in_with_wrong_credentials:
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m **Watir::Exception::UnknownObjectException: unable to locate element, using {:id=>"logInform:userName", :tag_name=>"input or textarea", :type=>"(any text type)"}**
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /var/lib/gems/1.9.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:533:in `assert_element_found'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /var/lib/gems/1.9.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:505:in `assert_exists'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /var/lib/gems/1.9.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/user_editable.rb:32:in `clear'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /var/lib/gems/1.9.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/user_editable.rb:11:in `set'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /Watir_tests/Pages/LogInPage.rb:14:in `login'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m /Watrit_tests/test/log_in_with_wrong_password_test.rb:15:in `test_log_in_with_wrong_credentials'
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
ec2-52-88-49-226.us-west-2.compute.amazonaws.com [0m
正如你可以看到,的Watir不能因爲Tomcat是不是在那一刻運行找到網頁元素。
有任何人遇到這樣的事情?有解決方案嗎?
也請告知,如果調用刀EC2服務器從詹金斯創建命令是可取的。
謝謝。
這難道不是你的Tomcat啓動時等待,但web應用程序啓動/部署尚未完成? ('睡眠5'不是很長,服務啓動是異步IIRC,我會更好地在catalina.out的尾部循環選擇'服務器啓動',睡眠1米,如果5分鐘後服務器未啓動,可能會失敗) – Tensibai