smqacloud 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/smqacloud.rb +140 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92a3be6f9b6e73481351262f5fda7aa99fba172e
|
4
|
+
data.tar.gz: 1f78ccbe9a78b1e3b62bf4c0a64972350334406e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: efebc9cee55b18f9b46bb53c08a0a12270167e45b6e0e464a4dbbd6cf08d83aee25130d395dc20db307b151c2322d61a6299789b6134bf091ef2f4056535cc9a
|
7
|
+
data.tar.gz: 14ba8a52ed424fafb5b8153d0a85ecf9b6a8ef7422bd33b7fa072c9c9cd97cb86155776b43e2278425b4bcbff76322f8599ce6f4b2043bc450ef6ba0411dd730
|
data/lib/smqacloud.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'httparty'
|
4
|
+
require 'qacloud'
|
5
|
+
require 'smapisatqacloud'
|
6
|
+
# require 'watir-webdriver'
|
7
|
+
|
8
|
+
# get playlistID or playlistID CI id from args::
|
9
|
+
|
10
|
+
# playlistID = ARGV[0]
|
11
|
+
# = "your token id"
|
12
|
+
# $add_variable = Hash.new
|
13
|
+
|
14
|
+
def self.playlist(playlistID)
|
15
|
+
$add_variable = Hash.new
|
16
|
+
taskhash = Qacloud.GetFirstTask(playlistID)
|
17
|
+
if taskhash.code == 500 then
|
18
|
+
#puts "Getting Task ID:"
|
19
|
+
taskhash = Qacloud.GetTaskid(playlistID)
|
20
|
+
playlistID = taskhash["body"]["_id"]
|
21
|
+
taskhash = Qacloud.GetFirstTask(playlistID)
|
22
|
+
end
|
23
|
+
|
24
|
+
# collecting useful variables and values from taskhash:
|
25
|
+
|
26
|
+
$workflow_name = taskhash["body"]["workflow_name"]
|
27
|
+
$workflow_id = taskhash["body"]["workflow_id"]
|
28
|
+
$task_name = taskhash["body"]["task_name"]
|
29
|
+
task_id = taskhash["body"]["task_id"]
|
30
|
+
$var = taskhash["body"]["task_variables"]
|
31
|
+
$env = taskhash["body"]["environment"]
|
32
|
+
puts "Workflow: #{$workflow_name}"
|
33
|
+
$workflow_status = taskhash["body"]["test"]
|
34
|
+
puts "Now Starting Task: #{$task_name}"
|
35
|
+
|
36
|
+
begin
|
37
|
+
|
38
|
+
if $var.has_key?("path") == true then
|
39
|
+
if $var["path"].empty? == false then
|
40
|
+
path = $var["path"]
|
41
|
+
end
|
42
|
+
else
|
43
|
+
path = $env["path"]
|
44
|
+
end
|
45
|
+
require_relative "#{path}"
|
46
|
+
dur1 = Time.now
|
47
|
+
send($task_name)
|
48
|
+
|
49
|
+
rescue Exception => e
|
50
|
+
|
51
|
+
puts "Exception occured, Checkpoint should have more info."
|
52
|
+
@erro_line = e.backtrace[0].split(":")
|
53
|
+
@error_line = @erro_line[1]
|
54
|
+
@error_message = "#{$!}"
|
55
|
+
@error_line = Integer(@error_line) rescue "ErrorImage"
|
56
|
+
dur2 = Time.now
|
57
|
+
status = "fail"
|
58
|
+
result = "Exception occured, Checkpoint should have more info."
|
59
|
+
if ($checkpoint.nil?) == true then
|
60
|
+
checkpoint = "Error Message: #{@error_message} , Script Line Number: #{@error_line}"
|
61
|
+
else
|
62
|
+
checkpoint = $checkpoint
|
63
|
+
end
|
64
|
+
$checkpoint = nil
|
65
|
+
duration = dur2 - dur1
|
66
|
+
# taskhash = Qacloud.GetNextTask(task_id,status,result,checkpoint,duration)
|
67
|
+
# $workflow_status = "finished"
|
68
|
+
# Take error image:
|
69
|
+
# $browser.screenshot.save "#{dirname}/#{@error_line}.png"
|
70
|
+
else
|
71
|
+
dur2 = Time.now
|
72
|
+
status = $status
|
73
|
+
result = $result
|
74
|
+
checkpoint = $checkpoint
|
75
|
+
$checkpoint = nil
|
76
|
+
duration = dur2 - dur1
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
while $workflow_status != "finished"
|
81
|
+
taskhash = Qacloud.GetNextTask(playlistID,status,result,checkpoint,duration)
|
82
|
+
$workflow_name = taskhash["body"]["workflow_name"]
|
83
|
+
$workflow_id = taskhash["body"]["workflow_id"]
|
84
|
+
$task_name = taskhash["body"]["task_name"]
|
85
|
+
task_id = taskhash["body"]["task_id"]
|
86
|
+
$var = taskhash["body"]["task_variables"]
|
87
|
+
$env = taskhash["body"]["environment"]
|
88
|
+
$workflow_status = taskhash["body"]["test"]
|
89
|
+
|
90
|
+
break if $workflow_status == "finished"
|
91
|
+
# if $add_variable.empty? == true then
|
92
|
+
# else
|
93
|
+
# $get_variable.merge!($add_variable)
|
94
|
+
# end
|
95
|
+
puts "Workflow: #{$workflow_name}"
|
96
|
+
puts "Now Starting Task: #{$task_name}"
|
97
|
+
begin
|
98
|
+
if $var.has_key?("path") == true then
|
99
|
+
if $var["path"].empty? == false then
|
100
|
+
path = $var["path"]
|
101
|
+
end
|
102
|
+
else
|
103
|
+
path = $env["path"]
|
104
|
+
end
|
105
|
+
require_relative "#{path}"
|
106
|
+
dur1 = Time.now
|
107
|
+
send($task_name)
|
108
|
+
|
109
|
+
rescue Exception => e
|
110
|
+
puts "Exception occured, Checkpoint should have more info."
|
111
|
+
@erro_line = e.backtrace[0].split(":")
|
112
|
+
@error_line = @erro_line[1]
|
113
|
+
@error_message = "#{$!}"
|
114
|
+
@error_line = Integer(@error_line) rescue "ErrorImage"
|
115
|
+
dur2 = Time.now
|
116
|
+
status = "fail"
|
117
|
+
result = "Exception occured, Checkpoint should have more info."
|
118
|
+
if ($checkpoint.nil?) == true then
|
119
|
+
checkpoint = "Error Message: #{@error_message} , Script Line Number: #{@error_line}"
|
120
|
+
else
|
121
|
+
checkpoint = $checkpoint
|
122
|
+
end
|
123
|
+
$checkpoint = nil
|
124
|
+
duration = dur2 - dur1
|
125
|
+
# taskhash = Qacloud.GetNextTask(task_id,status,result,checkpoint,duration)
|
126
|
+
# $workflow_status = "finished"
|
127
|
+
# Take error image:
|
128
|
+
# $browser.screenshot.save "#{dirname}/#{@error_line}.png"
|
129
|
+
|
130
|
+
else
|
131
|
+
dur2 = Time.now
|
132
|
+
status = $status
|
133
|
+
result = $result
|
134
|
+
checkpoint = $checkpoint
|
135
|
+
$checkpoint = nil
|
136
|
+
duration = dur2 - dur1
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smqacloud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ravi Trivedi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Use this gem with playlist automation framework:.
|
14
|
+
email:
|
15
|
+
- testerravit@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/smqacloud.rb
|
21
|
+
homepage: http://qacloud.io
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: playlist automation framework
|
44
|
+
test_files: []
|