kaya 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45359e9ff9bad0618df21686ea9caddc36cda396
4
- data.tar.gz: edf1cc2eb78c5329fd8c7d5ee1ee969362152940
3
+ metadata.gz: 033bb61efdc7cdbf0cb553692f82de5866d0f9ee
4
+ data.tar.gz: 0e3de5b65873b4dc50c8fff6507b491104b68933
5
5
  SHA512:
6
- metadata.gz: b99f3101952241a2f6dffc3d9d32f63f4a31a92a4338d0dcbb55fddb2c5f1e618473bcf04e23f8c9181cec88396247c4b8157c8163322ce54b715a7160fdee80
7
- data.tar.gz: fd96a85d144aba666260257ff6246bf14167f4df18caae840edd03033e8b2a49a54c4e8b82d75dd6057f5b93fd35965399c360d07e6d1861ba1a4f9f61d15567
6
+ metadata.gz: dcf6ebc5803f43e80141a161dfee26fe2f98b200de5088ffbf873cf17d77f75113fa1ef5f98c6e759db9fb94faa4c2f11be2eb3b16b643014902ea703735db51
7
+ data.tar.gz: 2bce3a33e7a01606acbba42641aeef6de7a398ba1225a17b1fb72137fdd606784a03cb5809e7003bdf3444ae5cdcb22789fb0d72ab62725acfb1b5b9974adeda
data/README.md CHANGED
@@ -10,23 +10,28 @@ Kaya
10
10
 
11
11
  Before installing Kaya you should have installed:
12
12
 
13
- - MongoDb (version >= 2.6) See http://www.mongodb.org/downloads
13
+ - MongoDb (version >= 2.6) See http://www.mongodb.org/downloads
14
14
 
15
15
  $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
16
16
  $ sudo apt-get update
17
- $ sudo apt-get install mongodb-org
17
+ $ sudo apt-get install mongodb
18
18
  $ sudo service mongodb start
19
19
 
20
- - Redis (http://tosbourn.com/install-latest-version-redis-ubuntu/)
20
+ - Redis (http://tosbourn.com/install-latest-version-redis-ubuntu/)
21
21
 
22
22
  $ sudo apt-get install -y python-software-properties
23
23
  $ sudo add-apt-repository -y ppa:rwky/redis
24
24
  $ sudo apt-get update
25
25
  $ sudo apt-get install -y redis-server
26
26
 
27
- - xvfb (if you want to run WebDriver in headless mode.)
27
+ - If you want to run GUI tests using WebDriver in headless mode you should install xvfb package
28
28
  $sudo apt-get intall xvfb
29
29
 
30
+ - While running in headless mode you may face an error like:
31
+ LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Error spawning command line `dbus-launch --autolaunch
32
+ This coulb be solved by installing dbus-x11 package
33
+ $apt-get install dbus-x11
34
+
30
35
 
31
36
 
32
37
  ## Kaya Installation
@@ -238,7 +243,7 @@ Returns the data you've added to result from execution
238
243
  Contributing
239
244
  ---------------------
240
245
 
241
- 1. Fork it (http://github.com/`<my-github-username>`/kaya/fork)
246
+ 1. Fork it (http://github.com/romgrod/kaya/fork)
242
247
  2. Create your feature branch (`git checkout -b my-new-feature`)
243
248
  3. Commit your changes (`git commit -am 'Add some feature'`)
244
249
  4. Push to the branch (`git push origin my-new-feature`)
@@ -41,21 +41,17 @@ module Kaya
41
41
  "git_log" => git_log
42
42
  }
43
43
 
44
-
45
44
  suite.last_result = Kaya::Execution.run!(execution_request_data) # Returns result_id
46
45
 
47
46
  suite.set_running!
48
47
 
49
- $K_LOG.debug "Suite #{suite_name} setted as running" if $K_LOG
50
-
51
48
  suite.save!
52
49
 
50
+ $K_LOG.debug "Suite #{suite_name} setted as running" if $K_LOG
51
+
53
52
  # Starts workers
54
53
  Kaya::Workers::ExecutionChecker.perform_async(suite.id) # Work until execution finish
55
54
 
56
- # Kaya::Workers::GarbageCleaner.perform_async # Clean all zombies files
57
-
58
- # suite_id = suite.id
59
55
  execution_id = suite.last_result
60
56
  started = true
61
57
  message = "Suite%20#{suite.name}%20started"
@@ -73,7 +69,6 @@ module Kaya
73
69
 
74
70
  else # No suite for suite_name
75
71
  $K_LOG.error "Suite not found for name #{suite_name}" if $K_LOG
76
- # suite_id = nil
77
72
  started = false
78
73
  execution_id = nil
79
74
  status = 404
@@ -23,10 +23,10 @@ module Kaya
23
23
  if suites.size.zero?
24
24
  response["message"] = options[:running] ? "No running suites found" : "No suites found"
25
25
  else
26
- suites.each do |suite_id|
27
- suite = Kaya::Suites::Suite.get(suite_id)
28
- response["suites"] << suite.api_response
29
- end
26
+ start = Time.now.to_f
27
+ response["suites"] = suites.map{|suite_id| Kaya::Suites::Suite.get(suite_id).api_response}
28
+ $K_LOG.debug "#{suites.size} retrieved in (#{Time.now.to_f - start} s)" if $K_LOG
29
+
30
30
  response["size"] = suites.size
31
31
  end
32
32
  response
@@ -3,11 +3,22 @@ module Kaya
3
3
  def self.help
4
4
  $K_LOG.debug "#{self}:#{__method__}" if $K_LOG
5
5
  puts "
6
- If you shutdown kaya and then you want to get it up and the port you are using is already in use you could use the following commands (Ubunutu OS):
7
6
 
8
- $sudo netstat -tapen | grep :8080
7
+ Kaya has some commands:
9
8
 
10
- In this example we use the port 8080. This command will give you the app that is using the port. Then you could kill it getting its PID previously."
9
+ - install
10
+ - start
11
+ - stop
12
+ - restart
13
+ - reset
14
+
15
+ Note: If you stop kaya and then you want to get it up and the port you are using is already in use
16
+ you could use the following commands (Ubunutu OS):
17
+
18
+ $sudo netstat -tapen | grep :8080
19
+
20
+ In this example we use the port 8080. This command will give you the app that is using the port.
21
+ Then you could kill it getting its PID previously."
11
22
  end
12
23
  end
13
24
  end
@@ -80,7 +80,7 @@ or set HEADLESS active value as false if you do not use browser in your tests."
80
80
 
81
81
  # Start kaya app
82
82
  $K_LOG.debug "Starting Kaya" if $K_LOG
83
- kaya_start_output = Kaya::Support::Console.execute "unicorn -c #{Dir.pwd}/kaya/unicorn.rb -p #{Kaya::Support::Configuration.port} #{kaya_arg} kaya/config.ru"
83
+ Kaya::Support::Console.execute "unicorn -c #{Dir.pwd}/kaya/unicorn.rb -p #{Kaya::Support::Configuration.port} #{kaya_arg} kaya/config.ru"
84
84
 
85
85
  $K_LOG.debug "Kaya started" if $K_LOG
86
86
 
data/lib/kaya/cuba.rb CHANGED
@@ -194,7 +194,7 @@ Cuba.define do
194
194
 
195
195
  on "#{HOSTNAME}/kaya/api/suites/running" do
196
196
  output = Kaya::API::Suites.list({running:true})
197
- res.write output
197
+ res.write output.to_json
198
198
  end
199
199
 
200
200
  on "#{HOSTNAME}/kaya/api/suites/active" do
@@ -16,48 +16,41 @@ module Kaya
16
16
  rescue
17
17
  end
18
18
 
19
- bundle_output = Kaya::Support::Console.execute "bundle install"
20
- $K_LOG.debug "[result:#{result.id}] Bundle install performed" if $K_LOG
21
-
22
- result.save_to_bundle_output bundle_output
23
-
24
- unless bundle_output.include? "Could not find"
25
-
26
- # Adding _id=result.id to use inside execution the posiibility to add information to the result
27
- result.kaya_command= "#{Kaya::Support::Configuration.headless?} bundle exec cucumber #{result.command} -f pretty -f html -o kaya/temp/#{result.kaya_report_file_name} #{result.custom_params_values} _id=#{result.id} "
28
-
29
- result.console_output_file_name= "kaya_co_#{result.id}.out"
30
-
31
- result.save!
32
-
33
- command = "#{result.kaya_command} 2>&1 | tee -a kaya/temp/#{result.console_output_file_name}"
34
-
35
- $K_LOG.debug "[result:#{result.id}] Running in headless mode" if $K_LOG and Kaya::Support::Configuration.headless?
36
-
37
- Dir.mkdir "#{Dir.pwd}/kaya/temp" unless Dir.exist? "#{Dir.pwd}/kaya/temp"
19
+ if Kaya::Support::ChangeInspector.is_there_a_change? or not Kaya::Support::ChangeInspector.is_there_gemfile_lock?
20
+ bundle_output = Kaya::Support::Console.execute "bundle install"
21
+ $K_LOG.debug "[result:#{result.id}] Bundle install performed" if $K_LOG
22
+ result.save_to_bundle_output bundle_output
23
+ raise "An error ocurred installing gem" if bundle_output.include? "Could not find"
24
+ end
38
25
 
39
26
 
40
- $K_LOG.debug "[result:#{result.id}] Creating process" if $K_LOG
41
- result.pid= Kaya::Support::Processes.fork_this command
42
- $K_LOG.debug "[result:#{result.id}] Process (#{result.pid}) exec'in" if $K_LOG
43
27
 
44
- $K_LOG.debug "[result:#{result.id}] Running saved command}" if $K_LOG
28
+ # Adding _id=result.id to use inside execution the posiibility to add information to the result
29
+ result.kaya_command= "#{Kaya::Support::Configuration.headless?} bundle exec cucumber #{result.command} -f pretty -f html -o kaya/temp/#{result.kaya_report_file_name} #{result.custom_params_values} _id=#{result.id} "
45
30
 
46
- result.running!
31
+ result.console_output_file_name= "kaya_co_#{result.id}.out"
47
32
 
48
- $K_LOG.debug "[result:#{result.id}] Result setted as running" if $K_LOG
33
+ result.save!
49
34
 
50
- result.append_result_to_console_output!
35
+ command = "#{result.kaya_command} 2>&1 | tee -a kaya/temp/#{result.console_output_file_name}"
51
36
 
52
- result.save_report!
37
+ $K_LOG.debug "[result:#{result.id}] Running in headless mode" if $K_LOG and Kaya::Support::Configuration.headless?
53
38
 
54
- result.save!
39
+ Dir.mkdir "#{Dir.pwd}/kaya/temp" unless Dir.exist? "#{Dir.pwd}/kaya/temp"
55
40
 
56
- result.append_result_to_console_output!
41
+ $K_LOG.debug "[result:#{result.id}] Creating process" if $K_LOG
42
+ result.pid= Kaya::Support::Processes.fork_this command
43
+ result.running!
44
+ result.save!
45
+ $K_LOG.debug "[result:#{result.id}] Process => #{result.pid}(PID) | command => saved | result as => running" if $K_LOG
57
46
 
58
- end # unless
47
+ # Following actions are performed by background job
59
48
 
60
- end # end self.run
49
+ # result.append_result_to_console_output!
50
+ # result.save_report!
51
+ # result.save!
52
+ # result.append_result_to_console_output!
53
+ end # end self.run
61
54
 
62
55
  end #end Task class
63
56
  end # enc Cucumber module
@@ -149,58 +149,6 @@ module Kaya
149
149
  ##################################
150
150
  # SUITES
151
151
  #
152
- #
153
-
154
- # # Update suites collection with suites that comes from cucumber.yml file
155
- # # All given suites will be active. Others will be deactivated
156
- # # @param [Hash] cucumber_yml_suites
157
- # def self.update_suites cucumber_yml_suites
158
-
159
- # existing_suites = self.suites
160
-
161
- # existing_suites_name_list = existing_suites.map{|suite| suite["name"]}
162
-
163
- # cucumber_yml_suites.each_with_index do |cucumber_suite, index|
164
-
165
- # suite_data = existing_suites.select{|suite| suite["name"]==cucumber_suite["name"]}.first
166
-
167
- # # if exist, so update it, else creates a new one
168
- # if suite_data
169
- # #Delete it from list and update it
170
- # existing_suites.delete(suite_data)
171
- # suite_data["command"] = cucumber_suite["command"]
172
- # suite_data["custom"] = cucumber_suite["custom"]
173
- # suite_data["active"] = true
174
- # suite_data["index"] = index
175
-
176
- # # Updates register with new data
177
- # self.update_suite(suite_data)
178
- # print "UPDATED: #{suite_data['_id']}\n\n"
179
- # else
180
- # # Creates a new one
181
- # suite_data = self.suite_data_structure
182
- # suite_data["name"] = cucumber_suite["name"]
183
- # suite_data["command"] = cucumber_suite["command"]
184
- # suite_data["custom"] = cucumber_suite["custom"]
185
- # suite_data["branch"] = Kaya::Support::Git.actual_branch
186
-
187
- # # Saves register with new data
188
- # id = self.insert_suite(suite_data)
189
-
190
- # print "INSERTED: #{id}\n\n"
191
- # end
192
- # end
193
-
194
- # # If at least one existing suite isn't con cucumber yml file, so deactivate them
195
- # unless existing_suites.empty?
196
- # existing_suites.each do |suite|
197
-
198
- # print "DEACTIVATED: #{suite['_id']}\n\n"
199
- # deactivate_suite(suite["_id"])
200
- # end
201
- # end
202
- # end
203
-
204
152
 
205
153
  # Inserts a suite in suites collection
206
154
  # @param [Hash] suite_data (see suite_data_structure method)
@@ -336,11 +284,6 @@ module Kaya
336
284
  end.map{|result| result["_id"]}
337
285
  end
338
286
  end
339
-
340
- def self.find_by criteria={}
341
- search_criteria = {}
342
- end
343
-
344
287
  end
345
288
  end
346
289
  end
@@ -24,18 +24,19 @@ module Kaya
24
24
  $K_LOG.debug "Task started" if $K_LOG
25
25
 
26
26
 
27
- if result = Results::Result.get(result_id)
27
+ # Performed by background job
28
+ # if result = Results::Result.get(result_id)
28
29
 
29
- result.append_result_to_console_output!
30
+ # result.append_result_to_console_output!
30
31
 
31
- result.save_report!
32
+ # result.save_report!
32
33
 
33
- result.get_summary!
34
+ # result.get_summary!
34
35
 
35
- result.get_status!
36
+ # result.get_status!
36
37
 
37
- result = nil
38
- end
38
+ # result = nil
39
+ # end
39
40
 
40
41
  result_id
41
42
 
@@ -52,20 +52,18 @@ module Kaya
52
52
 
53
53
  def self.update_suites
54
54
 
55
- if Kaya::Support::Configuration.use_git?
56
- last_saved_commit = Kaya::Database::MongoConnector.last_commit
57
- last_repo_commit = Kaya::Support::Git.last_commit
58
- if last_saved_commit.nil? or (last_saved_commit != last_repo_commit)
59
- Kaya::Support::Git.reset_hard
60
- Kaya::Support::Git.pull
61
- self.update!
62
- Kaya::Database::MongoConnector.insert_commit(last_repo_commit)
63
- else
64
- $K_LOG.debug "No git changes!"
65
- end
66
- else
67
- self.update!
68
- end
55
+ # if Kaya::Support::Configuration.use_git?
56
+ # if Kaya::Database::MongoConnector.last_commit != (last_repo_commit = Kaya::Support::Git.last_commit)
57
+ # Kaya::Support::Git.reset_hard_and_pull
58
+ # self.update!
59
+ # Kaya::Database::MongoConnector.insert_commit(last_repo_commit)
60
+ # else
61
+ # $K_LOG.debug "No git changes!"
62
+ # end
63
+ # else
64
+ # self.update!
65
+ # end
66
+ self.update! if Kaya::Support::ChangeInspector.is_there_a_change?
69
67
  end
70
68
 
71
69
  def self.update!
@@ -0,0 +1,37 @@
1
+ module Kaya
2
+ module Support
3
+ module ChangeInspector
4
+
5
+ # Evaluates if code has been changed. If yes, performs a git reset hard and git pull
6
+ # Update commit log into Database and return true
7
+ # Returns true if there is a change in code.
8
+ # Consider true if git usage is false
9
+ # @return [Boolean]
10
+
11
+ def self.is_there_a_change?
12
+ if Kaya::Support::Configuration.use_git?
13
+ if Kaya::Database::MongoConnector.last_commit != (last_repo_commit = Kaya::Support::Git.last_commit)
14
+ $K_LOG.debug "Git has been changed. Perform code update" if $K_LOG
15
+ Kaya::Support::Git.reset_hard_and_pull
16
+ Kaya::Database::MongoConnector.insert_commit(last_repo_commit)
17
+ $K_LOG.debug "Commit log updated on database" if $K_LOG
18
+ true
19
+ else
20
+ $K_LOG.debug "No git changes" if $K_LOG
21
+ false
22
+ end
23
+ else
24
+ true
25
+ end
26
+ end
27
+
28
+ def self.is_there_gemfile_lock?
29
+ begin
30
+ IO.read("#{Dir.pwd}/Gemfile.lock")
31
+ rescue
32
+ false
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -56,6 +56,10 @@ module Kaya
56
56
  Kaya::Support::Console.execute("git reset --hard")
57
57
  end
58
58
 
59
+ def self.reset_hard_and_pull
60
+ self.reset_hard and self.pull
61
+ end
62
+
59
63
  def self.git_push_origin_to_actual_branch
60
64
  branch_name = self.branch
61
65
  self.git_push_origin_to branch_name
@@ -140,52 +144,6 @@ module Kaya
140
144
  self.commits.first
141
145
  end
142
146
 
143
- # # Returns information about commit
144
- # # @return [Hash]
145
- # # {
146
- # # "_id":Fixnum,
147
- # # "commit_id":Fixnum,
148
- # # "author":String,
149
- # # "date":String,
150
- # # "message":String
151
- # # }
152
- # def self.last_commit_info
153
- # commits = self.log
154
- # last_commit_raw = commits.split("\n\ncommit ").first.split("\n")
155
- # {
156
- # "_id" => self.generate_id,
157
- # "commit_id" => self.extract_id(last_commit_raw),
158
- # "author" => self.extract_author(last_commit_raw),
159
- # "date" => self.extract_date(last_commit_raw),
160
- # "message" => self.extract_message(last_commit_raw)
161
- # }
162
- # end
163
-
164
- # def self.last_commit_id
165
- # self.last_commit_info["commit_id"]
166
- # end
167
-
168
- # # returns commit id
169
- # # @return [String] commit
170
- # def self.extract_id commit_info
171
- # commit_id = commit_info.select{|line| line.start_with? "commit "}.first
172
- # commit_id.split(" ").last
173
- # end
174
-
175
- # def self.extract_author commit_info
176
- # author = commit_info.select{|line| line.start_with? "Author: " }
177
- # author.first.split("Author: ").last
178
- # end
179
-
180
- # def self.extract_date commit_info
181
- # date = commit_info.select{|line| line.start_with? "Date: "}.first
182
- # date.split(" ").last
183
- # end
184
-
185
- # def self.extract_message commit_info
186
- # info = commit_info.last
187
- # end
188
-
189
147
  def self.is_there_commit_id_diff? obtained_commit
190
148
  obtained_commit != self.last_commit_id
191
149
  end
@@ -0,0 +1,10 @@
1
+ require 'selenium-webdriver'
2
+
3
+ def buscar_en_google palabra
4
+ @browser = Selenium::WebDriver.for :firefox
5
+ @browser.get "http://google.com"
6
+ campo_de_busqueda = @browser.find_element(:id, "q")
7
+ campo_de_busqueda.send_keys("#{palabra}\n")
8
+ end
9
+
10
+ buscar_en_google "curso de automatizacion de pruebas"
data/lib/kaya/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaya
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -22,7 +22,7 @@
22
22
  Last result:&nbsp;{{Kaya::View.label_color_for_result_id suite["last_result"]}}
23
23
  </li>
24
24
  <li class='list-group-item'>
25
- Started on:&nbsp;{{Kaya::Support::TimeHelper.formatted_time_for suite["last_result"]}}
25
+ Started on:&nbsp;{{Kaya::Support::TimeHelper.formatted_time_for(Kaya::Results::Result.get(suite["last_result"]).started_at)}}
26
26
  </li>
27
27
  % end
28
28
  % end
data/lib/kaya.rb CHANGED
@@ -84,6 +84,7 @@ require_relative "kaya/support/query_string"
84
84
  require_relative "kaya/support/if_config"
85
85
  require_relative "kaya/support/time_helper"
86
86
  require_relative "kaya/support/logs"
87
+ require_relative "kaya/support/change_inspector"
87
88
 
88
89
 
89
90
  # Background jobs
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -299,6 +299,7 @@ files:
299
299
  - lib/kaya/suites/custom/params.rb
300
300
  - lib/kaya/suites/suite.rb
301
301
  - lib/kaya/suites/suites.rb
302
+ - lib/kaya/support/change_inspector.rb
302
303
  - lib/kaya/support/clean.rb
303
304
  - lib/kaya/support/configuration.rb
304
305
  - lib/kaya/support/console.rb
@@ -313,6 +314,7 @@ files:
313
314
  - lib/kaya/support/processes.rb
314
315
  - lib/kaya/support/query_string.rb
315
316
  - lib/kaya/support/request.rb
317
+ - lib/kaya/support/ricardo.rb
316
318
  - lib/kaya/support/risk.rb
317
319
  - lib/kaya/support/time_helper.rb
318
320
  - lib/kaya/support/update.rb