qacloud 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qacloud.rb +121 -50
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8211e142bfbd43a2f7fa96d71c3e7eef0df976ed
4
- data.tar.gz: df65cd5b043803219788beba22d5ae044d4768ae
3
+ metadata.gz: 76883711c4ab99be17d4ca2958dfd9e45d2a8b42
4
+ data.tar.gz: 98e14cbfc52aef0914f689231b63b412b1eb7cb1
5
5
  SHA512:
6
- metadata.gz: 011b0d74571f2323fbcf4ee3fd0335f0bc12ad51e6f6e426ec32cb3f8d494461da69cc890893130fd88ae3d832e50e152d626e9cd8cb348ad74829f66261c494
7
- data.tar.gz: 85919d33ecd08b086dd4d151d9280e58f1c68a63a0eb34074b723ead50b2d98c8378b4d08563a2fc48d06f9686a93e855b6b4fdfc524fd948dbecfec5af27c9c
6
+ metadata.gz: 4d99402baef63b0507b4c4718f1b85fd9eb9f7d9dd1ec736bee4a28edc2231698791bb10d7376e44972f52114a038b9203eb7d7a1ece1d586437f5ea59a4139c
7
+ data.tar.gz: c51699393f0d85899e7f59f6705ef88f186f95a3019cc0939caf1ea315661a622c7d591adf03440ac3024bf592cf7c6597225ed083b6c353c43a1aef74def738
data/lib/qacloud.rb CHANGED
@@ -1,53 +1,124 @@
1
- # play framework gem:
2
-
1
+ #!/usr/bin/env ruby
3
2
  require 'rubygems'
4
3
  require 'httparty'
5
-
6
- class Qacloud
7
-
8
-
9
- include HTTParty
10
- format :json
11
- default_params :output => 'json'
12
- base_uri 'http://staging.qacloud.io/api/tests/'
13
-
14
-
15
- def self.GetTaskid(task_id,token_id)
16
-
17
- return post("/#{task_id}" ,
18
-
19
- :headers => { "authToken" => "#{token_id}"})
20
- end
21
-
22
-
23
- def self.GetFirstTask(task_id,token_id)
24
-
25
- return put("/#{task_id}/run" ,
26
-
27
- :headers => { "authToken" => "#{token_id}"})
28
-
29
- end
30
-
31
- def self.GetNextTask(task_id,token_id,status,result,checkpoint,duration)
32
-
33
-
34
-
35
- return put("/#{task_id}/next",
36
-
37
- :headers => { "authToken" => "#{token_id}"},
38
-
39
- :body => {
40
-
41
- 'status' => status,
42
- 'result' => result,
43
- 'checkpoint' => checkpoint,
44
- 'date' => Time.now.to_i * 1000,
45
- 'duration' => duration * 1000
46
-
47
-
48
- })
49
-
50
- end
51
-
52
-
4
+ require 'qacloud'
5
+ require 'watir-webdriver'
6
+
7
+
8
+ # # get playlistID or playlistID CI id from args::
9
+
10
+ # playlistID = ARGV[0]
11
+ # tokenID = "your token id"
12
+
13
+
14
+ def self.playlist(playlistID,tokenID)
15
+
16
+ taskhash = GetFirstTask(playlistID,tokenID)
17
+
18
+ if taskhash.code == 500 then
19
+ puts "Getting Task ID:"
20
+ taskhash = GetTaskid(playlistID,tokenID)
21
+ playlistID = taskhash["body"]["_id"]
22
+ taskhash = GetFirstTask(playlistID,tokenID)
23
+ end
24
+
25
+ # collecting useful variables and values from taskhash:
26
+
27
+ $workflow_name = taskhash["body"]["workflow_name"]
28
+ $workflow_id = taskhash["body"]["workflow_id"]
29
+ $task_name = taskhash["body"]["task_name"]
30
+ task_id = taskhash["body"]["task_id"]
31
+ $var = taskhash["body"]["task_variables"]
32
+ $env = taskhash["body"]["environment"]
33
+ puts "Workflow: #{$workflow_name}"
34
+ $workflow_status = taskhash["body"]["test"]
35
+ puts "Now Starting Task: #{$task_name}"
36
+
37
+ begin
38
+
39
+ if $var.has_key?("path") == true then
40
+ if $var["path"].empty? == false then
41
+ path = $var["path"]
42
+ end
43
+ else
44
+ path = $env["path"]
45
+ end
46
+ require_relative "#{path}"
47
+ dur1 = Time.now
48
+ $task_name()
49
+ dur2 = Time.now
50
+
51
+ rescue Exception => e
52
+
53
+ puts "Exception occured, Checkpoint should have more info."
54
+ @erro_line = e.backtrace[0].split(":")
55
+ @error_line = @erro_line[1]
56
+ @error_message = "#{$!}"
57
+ @error_line = Integer(@error_line) rescue "ErrorImage"
58
+ dur2 = Time.now
59
+ status = "fail"
60
+ result = "Exception occured, Checkpoint should have more info."
61
+ checkpoint = "Error Message: #{@error_message} , Script Line Number: #{@error_line}"
62
+ duration = dur2 - dur1
63
+ taskhash = GetNextTask(task_id,tokenID,status,result,checkpoint,duration)
64
+ $workflow_status = "finished"
65
+ # Take error image:
66
+ # $browser.screenshot.save "#{dirname}/#{@error_line}.png"
67
+ end
68
+
69
+ status = $status
70
+ result = $result
71
+ checkpoint = $checkpoint
72
+ duration = dur2 - dur1
73
+
74
+ while $workflow_status != "finished"
75
+ taskhash = GetNextTask(task_id,token_id,status,result,checkpoint,duration)
76
+ $workflow_name = taskhash["body"]["workflow_name"]
77
+ $workflow_id = taskhash["body"]["workflow_id"]
78
+ $task_name = taskhash["body"]["task_name"]
79
+ task_id = taskhash["body"]["task_id"]
80
+ $var = taskhash["body"]["task_variables"]
81
+ $env = taskhash["body"]["environment"]
82
+ $workflow_status = taskhash["body"]["test"]
83
+
84
+ break if $workflow_status == "finished"
85
+ if $add_variable.empty? == true then
86
+ else
87
+ $get_variable.merge!($add_variable)
88
+ end
89
+ puts "Workflow: #{$workflow_name}"
90
+ puts "Now Starting Task: #{$task_name}"
91
+ begin
92
+ if $var.has_key?("path") == true then
93
+ if $var["path"].empty? == false then
94
+ path = $var["path"]
95
+ end
96
+ else
97
+ path = $env["path"]
98
+ end
99
+ require_relative "#{path}"
100
+ dur1 = Time.now
101
+ $task_name()
102
+ dur2 = Time.now
103
+ rescue Exception => e
104
+ puts "Exception occured, Checkpoint should have more info."
105
+ @erro_line = e.backtrace[0].split(":")
106
+ @error_line = @erro_line[1]
107
+ @error_message = "#{$!}"
108
+ @error_line = Integer(@error_line) rescue "ErrorImage"
109
+ dur2 = Time.now
110
+ status = "fail"
111
+ result = "Exception occured, Checkpoint should have more info."
112
+ checkpoint = "Error Message: #{@error_message} , Script Line Number: #{@error_line}"
113
+ duration = dur2 - dur1
114
+ taskhash = GetNextTask(task_id,tokenID,status,result,checkpoint,duration)
115
+ $workflow_status = "finished"
116
+ # Take error image:
117
+ # $browser.screenshot.save "#{dirname}/#{@error_line}.png"
118
+ end
119
+ tatus = $status
120
+ result = $result
121
+ checkpoint = $checkpoint
122
+ duration = dur2 - dur1
123
+ end
53
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qacloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Trivedi
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-10-30 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: apisatqacloud
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
13
27
  description: Use this gem with playlist automation framework:.
14
28
  email:
15
29
  - testerravit@gmail.com