continuous_integration 0.0.2 → 0.0.3

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: 38c66cc12cbcc3a61aaf5c5c1695f6adea11de95
4
- data.tar.gz: 58adaab729fe1503d451cdd718c0394020812a93
3
+ metadata.gz: e8f963aefeb43fef87407dbed44b56ba9344a65f
4
+ data.tar.gz: ece5f7b447d5dc0f3b64f6f4a2d27b1a1ef19820
5
5
  SHA512:
6
- metadata.gz: 11fd83376f67fe5d81aad60ef2b5f54c4f282058b8a69218a9ad953350fe6e8e127d1544b6abce0c9ade3683b01e051c139078093aecf49bada765a00c500dba
7
- data.tar.gz: 9c6856f9b15016b79dfbb1a3b85fa6a0d16728e47fdb251d158ade7121b87094daef09ed5a0644aeb8fcdb7e4aaba68cd63ac3b4918fba10e98efc2cc4dbbaef
6
+ metadata.gz: cc13454449f1d1bbda2ca823a52618c5b696c9c1feded8df466ebb1536f794b2ab68a99b32327caa91a5f7eee1a0fd9180dc18cb55bcb7cd6551ac237725afbc
7
+ data.tar.gz: 3aa212a777cf4b27d3f4fe21c427a2d03497f03d08805a327c9a979b154ed84167dd32a70a4a92583d356e045292d1a7aa8f25348dad3a8cfee40992b5fc981e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ # Ignore bundler config.
2
+ /.bundle
3
+
4
+ # Ignore the default SQLite database.
5
+ /db/*.sqlite3
6
+ /db/*.sqlite3-journal
7
+
8
+ # Ignore all logfiles and tempfiles.
9
+ /log/*
10
+ !/log/.keep
11
+ /tmp
12
+
13
+ #custom ignores
14
+ *.gem
15
+ *.swp
16
+ *.swo
17
+ *.jpg
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'webrick'
4
+ gem 'byebug'
5
+ gem 'pry-byebug'
data/Gemfile.lock CHANGED
@@ -1,12 +1,25 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
+ byebug (9.0.6)
5
+ coderay (1.1.1)
6
+ method_source (0.8.2)
7
+ pry (0.10.4)
8
+ coderay (~> 1.1.0)
9
+ method_source (~> 0.8.1)
10
+ slop (~> 3.4)
11
+ pry-byebug (3.4.2)
12
+ byebug (~> 9.0)
13
+ pry (~> 0.10)
14
+ slop (3.6.0)
4
15
  webrick (1.3.1)
5
16
 
6
17
  PLATFORMS
7
18
  ruby
8
19
 
9
20
  DEPENDENCIES
21
+ byebug
22
+ pry-byebug
10
23
  webrick
11
24
 
12
25
  BUNDLED WITH
@@ -10,8 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["ragavendra.bn@gmail.com"]
11
11
  gem.description = %q{CI server for running integration tests using webrick}
12
12
  gem.summary = %q{One can run their UI and API tests using this gem}
13
- gem.homepage = "https://rubygems.org/gems/continuous_integration"
14
- gem.license = 'MIT'
13
+ gem.homepage = ""
15
14
 
16
15
  gem.files = `git ls-files`.split($/)
17
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -19,5 +18,5 @@ Gem::Specification.new do |gem|
19
18
  gem.require_paths = ["lib"]
20
19
 
21
20
  gem.add_development_dependency 'rspec', '~> 2.7'
22
- gem.add_development_dependency 'rake', '~> 0'
21
+ gem.add_development_dependency 'rake'
23
22
  end
@@ -1,13 +1,14 @@
1
+ #this file is like the global variable file
1
2
 
2
- DOCKER_PATH = "#{ENV['HOME']}/gitbase/devops/services/soa/dev"
3
- #DOCKER_PATH = "#{ENV['HOME']}/gitbase/devops/services/soa/#{@git_branch}"
4
- API_SPECS_PATH = "#{ENV['HOME']}/gitbase/test-auto/SOA/api"
5
- UI_SPECS_PATH = "#{ENV['HOME']}/gitbase/test-auto/SOA/se"
3
+ DOCKER_PATH = "#{ENV['HOME']}/repos/devops/services/soa/dev"
4
+ API_SPECS_PATH = "#{ENV['HOME']}/repos/api_tests"
5
+ UI_SPECS_PATH = "#{ENV['HOME']}/repos/selenium_tests"
6
6
 
7
- HOST="dockervm"
7
+ HOST = "dockervm"
8
8
  #HOST="https://amzn-se001"
9
9
  #HOST="https://qa.hostname.ca"
10
- BROWSER="phantomjs"
11
- SCREENS=true
12
-
10
+ BROWSER = "phantomjs"
11
+ SCREENS = true
13
12
 
13
+ PORT_NUM = 8080
14
+ SUB_URI = "/qa/docker/"
@@ -12,6 +12,7 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
12
12
  @result_api = ''
13
13
  @result_ui = ''
14
14
  @git_branch = ''
15
+ @lock = false
15
16
  end
16
17
 
17
18
 
@@ -47,67 +48,56 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
47
48
  end
48
49
 
49
50
  def do_POST (request, response)
50
- puts "this is a post request who received #{request.body}"
51
51
 
52
52
  requestHash = JSON.parse(request.body, symbolize_names: true)
53
- #repo_name = requestHash[:repository]
54
- #repo_name.split('/') repo_name[1]}
55
53
  @repo_name = requestHash[:name]
56
- #require 'pry'
57
- #binding.pry
58
- =begin
59
- cmd ="docker logs --tail=9 #{@opts[:docker_compose_logger]}"
60
- ENV["http_proxy"] = ''
61
- Dir.chdir(@opts[:docker_compose_path]){
62
- @log_str = %x[#{cmd}]
63
- }
64
- =end
65
-
66
- #%x["cd #{DOCKER_PATH}"]
67
-
68
- =begin
69
- Dir.chdir(DOCKER_PATH){
70
- cmd = "git pull"
71
- @result = %x[#{cmd}]
72
54
 
73
- cmd = "sudo docker-compose pull #{@repo_name}"
74
- @result = %x[#{cmd}]
75
-
76
- cmd = "sudo docker-compose kill" #haproxy may need to be restarted
77
- #cmd = "sudo docker-compose kill #{@repo_name}"] #haproxy may need to be restarted
78
- @result = %x[#{cmd}]
79
-
80
- #%x[docker-compose rm -y]
81
- cmd = "sudo docker-compose up -d"
82
- @result = %x[#{cmd}]
83
-
84
- #%x["sudo docker-compose start #{@repo_name}""]
85
- cmd = "sudo docker-compose ps"
86
- @process_status = %x[#{cmd}]
87
- puts "Docker process status - #{@process_status}"
88
- #%x[docker-compose ps]
89
- }
90
- =end
91
55
  @git_branch = requestHash[:trigger_metadata][:ref]
92
- #git_branch.split('/')"ref": "refs/heads/somebranch"
93
56
  @git_branch = @git_branch.split('/')
94
57
  @git_branch = @git_branch.last
95
- #navigate to specs dir
96
- #%x["cd #{API_SPECS_PATH}"]
97
58
 
59
+ #handle requests one at a time - Needs testing
60
+ while @lock
61
+ @lock = true
62
+ docker_update
63
+ sleep 10
64
+
65
+ run_api_tests
66
+ run_ui_tests
67
+ generate_log
68
+ slack_post
69
+ @lock = false
70
+ end
71
+ end
72
+
73
+ def docker_update
74
+ Dir.chdir(DOCKER_PATH){
75
+ #perform docker images update
76
+ `sudo docker compose kill`
77
+ `sudo docker compose rm`
78
+ `sudo docker compose up -d`
79
+ }
80
+
81
+ end
82
+
83
+ def run_api_tests
98
84
  Dir.chdir(API_SPECS_PATH){
99
85
  cmd = "RUBYOPT='-W0' HOST=#{HOST} RMQ_HOST=#{HOST} RMQ_VHOST=/ bundle exec rake cards:#{@git_branch} | aha --black >logs/#{@git_branch}/$(date +\%d-\%m-\%Y-\%H-\%s)-API-run.htm"
100
86
  @result_api = %x[#{cmd}]
101
87
  #%x["bundle exec rake cards:dev | aha --black >$LOGPATH/$(date +\%d-\%m-\%Y-\%H-\%s)-run.htm"]
102
88
  }
103
-
104
-
105
- #%x["cd #{UI_SPECS_PATH}"
89
+ end
90
+
91
+ def run_ui_tests
106
92
  Dir.chdir(UI_SPECS_PATH){
107
93
  #navigate to specs dir
108
94
  cmd = "HOST='https://#{HOST}' BROWSER=phantomjs SCREENS=true bundle exec rake selenium:#{@git_branch} | aha --black >logs/#{@git_branch}/$(date +\%d-\%m-\%Y-\%H-\%s)-UI-run.htm"
109
95
  @result_ui = %x[#{cmd}]
110
- }
96
+ }
97
+ end
98
+
99
+ def generate_log
100
+
111
101
  obj = {
112
102
  "Docker logs" => @process_status,
113
103
  "API logs" => @result_api,
@@ -115,24 +105,11 @@ class DockerEndpoint < WEBrick::HTTPServlet::AbstractServlet
115
105
  }
116
106
  response.body = JSON.generate obj
117
107
  response['Content-Type'] = "application/json"
108
+ end
118
109
 
119
- end
120
-
121
- #curl -d "{\"command\":\"ls\", \"par1\":\"/opt\"}" localhost:8080/docker/
122
- def do_POST2 (request, response)
123
- puts "this is a post request who received #{request.body}"
124
-
125
- requestHash = JSON.parse(request.body, symbolize_names: true)
126
- #@opts[:confirmation_token] = requestHash[:command]
127
-
128
- #cmd ="#{requestHash[:command]} docker logs --tail=9 #{@opts[:docker_compose_logger]}"
129
- cmd ="#{requestHash[:command]} #{requestHash[:par1]}"
130
-
131
- obj = {
132
- #"Result" => constants response.body = JSON.generate obj
133
- #response['Content-Type'] = "application/json"
134
- }
135
- end
110
+ def slack_post
111
+ #curl to post to slack for the team to see the results
112
+ end
136
113
  end
137
114
 
138
115
 
@@ -1,3 +1,3 @@
1
1
  module ContinuousIntegration
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -33,11 +33,11 @@ module ContinuousIntegration
33
33
  private
34
34
 
35
35
  def self.run_server root
36
- WEBrick::HTTPServer.new :Port => 8080, :DocumentRoot => root, :DirectoryIndex => []
36
+ WEBrick::HTTPServer.new :Port => PORT_NUM, :DocumentRoot => root, :DirectoryIndex => []
37
37
  end
38
38
 
39
39
  def self.dir_mount server
40
- server.mount "/qa/docker/", DockerEndpoint
40
+ server.mount SUB_URI, DockerEndpoint
41
41
  end
42
42
 
43
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continuous_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ragavendra Nagraj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: CI server for running integration tests using webrick
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".gitignore"
48
49
  - ".ruby-version"
49
50
  - Gemfile
50
51
  - Gemfile.lock
@@ -55,9 +56,8 @@ files:
55
56
  - lib/continuous_integration/constants.rb
56
57
  - lib/continuous_integration/tasks.rb
57
58
  - lib/continuous_integration/version.rb
58
- homepage: https://rubygems.org/gems/continuous_integration
59
- licenses:
60
- - MIT
59
+ homepage: ''
60
+ licenses: []
61
61
  metadata: {}
62
62
  post_install_message:
63
63
  rdoc_options: []