bucky-core 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +66 -0
  3. data/.codeclimate.yml +48 -0
  4. data/.dockerignore +11 -0
  5. data/.gitignore +40 -0
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +76 -0
  8. data/.rubocop_todo.yml +51 -0
  9. data/Dockerfile +38 -0
  10. data/Dockerfile.system-test +44 -0
  11. data/Gemfile +4 -0
  12. data/Gemfile.lock +115 -0
  13. data/LICENSE +201 -0
  14. data/README.md +246 -0
  15. data/Rakefile +8 -0
  16. data/bin/console +15 -0
  17. data/bin/setup +8 -0
  18. data/bucky-core.gemspec +47 -0
  19. data/docker-compose.dev-with-bm.yml +28 -0
  20. data/docker-compose.dev.yml +18 -0
  21. data/docker-compose.system-test.yml +21 -0
  22. data/docker/nginx/Dockerfile +7 -0
  23. data/docker/nginx/nginx.conf +22 -0
  24. data/docker/nginx/public/index.html +19 -0
  25. data/docker/nginx/public/test_page.html +12 -0
  26. data/exe/bucky +214 -0
  27. data/lib/bucky.rb +3 -0
  28. data/lib/bucky/core/database/db_connector.rb +29 -0
  29. data/lib/bucky/core/database/test_data_operator.rb +195 -0
  30. data/lib/bucky/core/exception/bucky_exception.rb +39 -0
  31. data/lib/bucky/core/report/screen_shot_generator.rb +24 -0
  32. data/lib/bucky/core/test_core/test_case_loader.rb +162 -0
  33. data/lib/bucky/core/test_core/test_class_generator.rb +129 -0
  34. data/lib/bucky/core/test_core/test_manager.rb +70 -0
  35. data/lib/bucky/core/test_core/test_result.rb +92 -0
  36. data/lib/bucky/test_equipment/evidence/evidence_generator.rb +36 -0
  37. data/lib/bucky/test_equipment/pageobject/base_pageobject.rb +55 -0
  38. data/lib/bucky/test_equipment/pageobject/pages.rb +61 -0
  39. data/lib/bucky/test_equipment/selenium_handler/webdriver_handler.rb +66 -0
  40. data/lib/bucky/test_equipment/test_case/abst_test_case.rb +49 -0
  41. data/lib/bucky/test_equipment/test_case/e2e_test_case.rb +70 -0
  42. data/lib/bucky/test_equipment/test_case/linkstatus_test_case.rb +28 -0
  43. data/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +97 -0
  44. data/lib/bucky/test_equipment/user_operation/user_operation_logger.rb +15 -0
  45. data/lib/bucky/test_equipment/user_operation/user_operator.rb +61 -0
  46. data/lib/bucky/test_equipment/verifications/abst_verification.rb +13 -0
  47. data/lib/bucky/test_equipment/verifications/e2e_verification.rb +106 -0
  48. data/lib/bucky/test_equipment/verifications/js_error_checker.rb +23 -0
  49. data/lib/bucky/test_equipment/verifications/service_verifications.rb +62 -0
  50. data/lib/bucky/test_equipment/verifications/status_checker.rb +180 -0
  51. data/lib/bucky/tools/lint.rb +69 -0
  52. data/lib/bucky/utils/bucky_logger.rb +25 -0
  53. data/lib/bucky/utils/bucky_output.rb +23 -0
  54. data/lib/bucky/utils/config.rb +55 -0
  55. data/lib/bucky/utils/requests.rb +33 -0
  56. data/lib/bucky/utils/yaml_load.rb +24 -0
  57. data/lib/bucky/version.rb +7 -0
  58. data/system_testing/test_bucky_project/.bucky_home +2 -0
  59. data/system_testing/test_bucky_project/config/bucky_config.yml +6 -0
  60. data/system_testing/test_bucky_project/config/e2e_config.yml +15 -0
  61. data/system_testing/test_bucky_project/config/linkstatus_config.yml +3 -0
  62. data/system_testing/test_bucky_project/config/test_db_config.yml +8 -0
  63. data/system_testing/test_bucky_project/services/README.md +1 -0
  64. data/system_testing/test_bucky_project/services/service_a/pc/pageobject/index.rb +13 -0
  65. data/system_testing/test_bucky_project/services/service_a/pc/parts/index.yml +6 -0
  66. data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/pc_e2e.yml +68 -0
  67. data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_each_pc_e2e.yml +20 -0
  68. data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_teardown_each_pc_e2e.yml +35 -0
  69. data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/teardown_each_pc_e2e.yml +20 -0
  70. data/system_testing/test_bucky_project/services/service_a/pc/scenarios/linkstatus/pc_link.yml +10 -0
  71. data/system_testing/test_bucky_project/services/service_a/sp/pageobject/index.rb +14 -0
  72. data/system_testing/test_bucky_project/services/service_a/sp/parts/index.yml +6 -0
  73. data/system_testing/test_bucky_project/services/service_a/sp/scenarios/e2e/sp_e2e_test.yml +26 -0
  74. data/system_testing/test_bucky_project/services/service_a/sp/scenarios/linkstatus/sp_link.yml +10 -0
  75. data/system_testing/test_bucky_project/services/service_a/tablet/pageobject/index.rb +14 -0
  76. data/system_testing/test_bucky_project/services/service_a/tablet/parts/index.yml +6 -0
  77. data/system_testing/test_bucky_project/services/service_a/tablet/scenarios/e2e/tablet_e2e_test.yml +26 -0
  78. data/system_testing/test_bucky_project/system/evidences/README.md +1 -0
  79. data/system_testing/test_bucky_project/system/evidences/screen_shots/README.md +1 -0
  80. data/system_testing/test_bucky_project/system/logs/README.md +1 -0
  81. data/system_testing/test_specification.md +38 -0
  82. data/system_testing/testing_code/command.bats +42 -0
  83. data/system_testing/testing_code/e2e.bats +75 -0
  84. data/system_testing/testing_code/linkstatus.bats +24 -0
  85. data/template/make_page/pc/pageobject/sample_page.rb +23 -0
  86. data/template/make_page/pc/parts/sample_page.yml +9 -0
  87. data/template/make_page/sp/pageobject/sample_page.rb +24 -0
  88. data/template/make_page/sp/parts/sample_page.yml +9 -0
  89. data/template/make_page/tablet/pageobject/sample_page.rb +24 -0
  90. data/template/make_page/tablet/parts/sample_page.yml +9 -0
  91. data/template/new/.bucky_home +2 -0
  92. data/template/new/config/bucky_config.yml +6 -0
  93. data/template/new/config/e2e_config.yml +15 -0
  94. data/template/new/config/linkstatus_config.yml +3 -0
  95. data/template/new/config/test_db_config.yml +8 -0
  96. data/template/new/services/README.md +1 -0
  97. data/template/new/system/evidences/README.md +1 -0
  98. data/template/new/system/evidences/screen_shots/README.md +1 -0
  99. data/template/new/system/logs/README.md +1 -0
  100. metadata +415 -0
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../utils/yaml_load'
4
+
5
+ module Bucky
6
+ module Tools
7
+ class Lint
8
+ class << self
9
+ include Bucky::Utils::YamlLoad
10
+ @@config_dir = "#{$bucky_home_dir}/config/**/*yml"
11
+ @@rule_config_dir = "#{$bucky_home_dir}/.bucky-core/template/new/config/*yml"
12
+
13
+ def check(category)
14
+ method = "check_#{category}".to_sym
15
+ respond_to?(method) ? send(method) : raise(StandardError, "no such a category #{category}")
16
+ end
17
+
18
+ # If you want to add new category, please make new method
19
+ def check_config
20
+ data = merge_yaml_data(@@config_dir)
21
+ rule_data = merge_yaml_data(@@rule_config_dir)
22
+ actual = make_key_chain(data)
23
+ expect = make_key_chain(rule_data)
24
+ diff = diff_arr(expect, actual)
25
+ make_message(diff)
26
+ end
27
+
28
+ private
29
+
30
+ # Merge yaml in target directory.
31
+ def merge_yaml_data(dir)
32
+ data_output = {}
33
+ file_sort_hierarchy(dir).each do |file|
34
+ data = load_yaml(file)
35
+ data_output.merge!(data) unless data.empty?
36
+ end
37
+ data_output.any? ? data_output : (raise StandardError, "No key! please check the directory existence [#{dir}]")
38
+ end
39
+
40
+ def make_message(diff)
41
+ if diff.empty?
42
+ puts "\e[32mok\e[0m"
43
+ else
44
+ puts "\e[31m[ERROR] The following configures are undefined."
45
+ diff.each do |key|
46
+ puts "- #{key}\e[0m"
47
+ end
48
+ end
49
+ end
50
+
51
+ def diff_arr(expect, actual)
52
+ expect.delete_if do |i|
53
+ actual.include?(i)
54
+ end
55
+ end
56
+
57
+ def make_key_chain(hash)
58
+ hash.map do |k, v|
59
+ if v.is_a? Hash
60
+ make_key_chain(v).map { |item| "#{k}-#{item}" }
61
+ else
62
+ k.to_s
63
+ end
64
+ end.flatten
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require_relative './config'
5
+
6
+ module Bucky
7
+ module Utils
8
+ module BuckyLogger
9
+ LogFileDir = Bucky::Utils::Config.instance.data[:log_path]
10
+ # Write following logs
11
+ # - user opareation (e.g. test_sample_app_pc_e2e_1_1.log)
12
+ # - verification (e.g. test_sample_app_pc_e2e_1_1.log)
13
+ # - Error of Bucky core (bucky_error.log)
14
+ # @param [String] file_name
15
+ # @param [String] or [Execption] content
16
+ def write(file_name, content)
17
+ puts " #{content}"
18
+ logger = Logger.new("#{LogFileDir}#{file_name}.log", 1)
19
+ logger.info content
20
+ logger.close
21
+ end
22
+ module_function :write
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bucky
4
+ module Utils
5
+ module BuckyOutput
6
+ module StringColorize
7
+ refine String do
8
+ def black
9
+ "\e[30m#{self}\e[0m"
10
+ end
11
+
12
+ def bg_red
13
+ "\e[41m#{self}\e[0m"
14
+ end
15
+
16
+ def bg_green
17
+ "\e[42m#{self}\e[0m"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+ require_relative './yaml_load'
5
+
6
+ module Bucky
7
+ module Utils
8
+ class Config
9
+ include Bucky::Utils::YamlLoad
10
+ include Singleton
11
+ @@dir = "#{$bucky_home_dir}/config/**/*yml"
12
+
13
+ # @param [String] *.yml or hoge/fuga.yml
14
+ def initialize
15
+ @data = {}
16
+ @resources = []
17
+
18
+ # Read from a file of shallow hierarchy, then overwrite it if there is same key in deep hierarchy
19
+ file_sort_hierarchy(@@dir).each do |file|
20
+ data = load_yaml(file)
21
+ unless data.empty?
22
+ @data = @data.merge(data)
23
+ @resources << file
24
+ end
25
+ end
26
+
27
+ set_selenium_ip
28
+ end
29
+
30
+ # @return [Hash] loaded data
31
+ def data
32
+ @data || {}
33
+ end
34
+
35
+ # Get data by []
36
+ def [](column)
37
+ return data[column] if data.key?(column)
38
+
39
+ # If there is no key, raise exeption
40
+ raise "Undefined Config : #{column}\nKey doesn't match in config file. Please check config file in config/*"
41
+ end
42
+
43
+ private
44
+
45
+ def set_selenium_ip
46
+ return unless @data[:selenium_ip] == 'docker_host_ip'
47
+
48
+ selenium_ip = `ip route | awk 'NR==1 {print $3}'`.chomp
49
+ raise StandardError, 'Could not load docker host ip.' if selenium_ip.empty?
50
+
51
+ @data[:selenium_ip] = selenium_ip
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ module Bucky
7
+ module Utils
8
+ module Requests
9
+ USER_AGENT_STRING = {
10
+ pc: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36',
11
+ sp: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E238 Safari/601.1'
12
+ }.freeze
13
+
14
+ # @param [String] uri
15
+ # @param [String] device
16
+ # @param [Integer/Float] open_timeout max wait time until open page
17
+ # @param [Integer/Float] read_timeout max wait time until recieve response
18
+ # @return [Net::HTTP] HttpStatusCode
19
+ def get_response(uri, device, open_timeout, read_timeout)
20
+ parsed_uri = URI.parse(uri.to_str.strip)
21
+ query = parsed_uri.query ? "?#{parsed_uri.query}" : ''
22
+ # If path is empty, add "/" e.g) http://example.com
23
+ path = parsed_uri.path.empty? ? '/' : parsed_uri.path
24
+
25
+ Net::HTTP.start(parsed_uri.host, parsed_uri.port, use_ssl: parsed_uri.scheme == 'https') do |http|
26
+ http.open_timeout = open_timeout
27
+ http.read_timeout = read_timeout
28
+ http.get("#{path}#{query}", 'User-Agent' => USER_AGENT_STRING[device.to_sym])
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'erb'
5
+
6
+ module Bucky
7
+ module Utils
8
+ module YamlLoad
9
+ # Load yaml(include erb)
10
+ # @param [File] yaml file
11
+ # @return [Hash] hashed yaml contents
12
+ def load_yaml(file)
13
+ YAML.safe_load(ERB.new(File.read(file)).result, [Array, Hash, String, Numeric, Symbol, TrueClass, FalseClass], [], true)
14
+ end
15
+
16
+ # Sort files to hierarchy
17
+ # @param [String] path of directory
18
+ # @return [Array] sorted files
19
+ def file_sort_hierarchy(path)
20
+ Dir.glob(path).sort_by { |f| f.split('/').size }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bucky
4
+ module Version
5
+ VERSION = '0.9.0'
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ # bucky home directory.
2
+ # Do not delete this file.
@@ -0,0 +1,6 @@
1
+ :parallel_num: 4
2
+ :test_result_path: './system/test_results/'
3
+ :log_path: './system/logs/'
4
+ :screen_shot_path: './system/evidences/screen_shots/'
5
+ :bucky_error: 'bucky_error'
6
+ :test_code_repo: 'https://github.com/hogehoge/fugafuga/'
@@ -0,0 +1,15 @@
1
+ :selenium_ip: 'docker_host_ip' # Default selenium ip. please set ip or 'docker_host_ip'. ip route | awk 'NR==1 {print $3}'
2
+ :selenium_port: '4444' # Default selenium port
3
+ :browser: :chrome # Only chrome
4
+ :sp_device_name: :iphone
5
+ :tablet_device_name: :ipad
6
+ :device_name_on_chrome:
7
+ :iphone: 'iPhone X'
8
+ :android: 'Galaxy S5'
9
+ :ipad: 'iPad'
10
+ :user_agent: 'E2ETest (X11; Linux x86_64)'
11
+ :js_error_check: true
12
+ :js_error_collector_path: '/var/lib/selenium/ChromeJSErrorCollector-master/extension' # https://github.com/dharrya/ChromeJSErrorCollector
13
+ :driver_read_timeout: 60 # sec
14
+ :driver_open_timeout: 60 # sec
15
+ :find_element_timeout: 10 # sec
@@ -0,0 +1,3 @@
1
+ :linkstatus_parallel_num: 8
2
+ :linkstatus_open_timeout: 60
3
+ :linkstatus_read_timeout: 60
@@ -0,0 +1,8 @@
1
+ :test_db:
2
+ :bucky_test:
3
+ :username: <%= ENV['BUCKY_DB_USERNAME'] %>
4
+ :password: <%= ENV['BUCKY_DB_PASSWORD'] %>
5
+ :database: 'bucky_development'
6
+ :host: <%= ENV['BUCKY_DB_HOST'] %>
7
+ :port: 3306
8
+ :adapter: :mysql
@@ -0,0 +1 @@
1
+ for services page and parts objects.
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bucky/test_equipment/pageobject/base_pageobject'
4
+ module Services
5
+ module ServiceA
6
+ module Pc
7
+ module PageObject
8
+ class Index < Bucky::TestEquipment::PageObject::BasePageObject
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ link:
2
+ - xpath
3
+ - "//*[@id='test_link']"
4
+ ua:
5
+ - xpath
6
+ - "//*[@id='user_agent']"
@@ -0,0 +1,68 @@
1
+ desc: pc e2e suits
2
+ device: pc
3
+ service: service_a
4
+ priority: high
5
+ test_category: e2e
6
+ cases:
7
+ - case_name: pc_e2e_1
8
+ func: pc e2e 1 func
9
+ desc: pc e2e 1 func
10
+ procs:
11
+ - proc: open index
12
+ exec:
13
+ operate: go
14
+ url: http://bucky.net
15
+ - proc: open index
16
+ exec:
17
+ operate: click
18
+ page: index
19
+ part: link
20
+ - proc: check title
21
+ exec:
22
+ verify: assert_title
23
+ expect: Test Page
24
+ - case_name: pc_e2e_2
25
+ func: pc e2e 2 func
26
+ desc: pc e2e 2 func
27
+ procs:
28
+ - proc: open index
29
+ exec:
30
+ operate: go
31
+ url: http://bucky.net
32
+ - proc: open index
33
+ exec:
34
+ operate: click
35
+ page: index
36
+ part: link
37
+ - proc: check title(NG)
38
+ exec:
39
+ verify: assert_title
40
+ expect: Test Page Wrong
41
+ - case_name: pc_e2e_3
42
+ func: pc e2e 3 func UserAgent
43
+ desc: pc e2e 3 func UserAgent
44
+ procs:
45
+ - proc: open index
46
+ exec:
47
+ operate: go
48
+ url: http://bucky.net
49
+ - proc: check UserAgent(OS)
50
+ exec:
51
+ verify: assert_contained_text
52
+ page: index
53
+ part: ua
54
+ expect: Linux
55
+ - case_name: pc_e2e_4
56
+ func: pc e2e 4 func when
57
+ desc: pc e2e 4 func when
58
+ procs:
59
+ - proc: open index
60
+ exec:
61
+ operate: go
62
+ url: http://bucky.net
63
+ - proc: index
64
+ exec:
65
+ operate: click
66
+ page: index
67
+ part: link
68
+ when: <%= ENV['STAGE'] == 'development' %>
@@ -0,0 +1,20 @@
1
+ desc: setup each pc e2e suits
2
+ device: pc
3
+ service: service_a
4
+ priority: high
5
+ test_category: e2e
6
+ setup_each:
7
+ procs:
8
+ - proc: open index
9
+ exec:
10
+ operate: go
11
+ url: http://bucky.net
12
+ cases:
13
+ - case_name: setup_each_pc_e2e_1
14
+ func: setup each pc e2e 1 func
15
+ desc: setup each pc e2e 1 func
16
+ procs:
17
+ - proc: check title
18
+ exec:
19
+ verify: assert_title
20
+ expect: Test Index
@@ -0,0 +1,35 @@
1
+ desc: setup teardown each pc e2e suits
2
+ device: pc
3
+ service: service_a
4
+ priority: high
5
+ test_category: e2e
6
+ setup_each:
7
+ procs:
8
+ - proc: open index
9
+ exec:
10
+ operate: go
11
+ url: http://bucky.net
12
+ teardown_each:
13
+ procs:
14
+ - proc: open test_page.html
15
+ exec:
16
+ operate: go
17
+ url: http://bucky.net/test_page.html
18
+
19
+ cases:
20
+ - case_name: setup_teardown_each_pc_e2e_1
21
+ func: setup teardown each pc e2e 1 func
22
+ desc: setup teardown each pc e2e 1 func
23
+ procs:
24
+ - proc: check title
25
+ exec:
26
+ verify: assert_title
27
+ expect: Test Index
28
+ - case_name: setup_teardown_each_pc_e2e_2
29
+ func: setup teardown each pc e2e 2 func
30
+ desc: setup teardown each pc e2e 2 func
31
+ procs:
32
+ - proc: check title
33
+ exec:
34
+ verify: assert_title
35
+ expect: Test Index