bucky-core 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +66 -0
- data/.codeclimate.yml +48 -0
- data/.dockerignore +11 -0
- data/.gitignore +40 -0
- data/.rspec +3 -0
- data/.rubocop.yml +76 -0
- data/.rubocop_todo.yml +51 -0
- data/Dockerfile +38 -0
- data/Dockerfile.system-test +44 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +115 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bucky-core.gemspec +47 -0
- data/docker-compose.dev-with-bm.yml +28 -0
- data/docker-compose.dev.yml +18 -0
- data/docker-compose.system-test.yml +21 -0
- data/docker/nginx/Dockerfile +7 -0
- data/docker/nginx/nginx.conf +22 -0
- data/docker/nginx/public/index.html +19 -0
- data/docker/nginx/public/test_page.html +12 -0
- data/exe/bucky +214 -0
- data/lib/bucky.rb +3 -0
- data/lib/bucky/core/database/db_connector.rb +29 -0
- data/lib/bucky/core/database/test_data_operator.rb +195 -0
- data/lib/bucky/core/exception/bucky_exception.rb +39 -0
- data/lib/bucky/core/report/screen_shot_generator.rb +24 -0
- data/lib/bucky/core/test_core/test_case_loader.rb +162 -0
- data/lib/bucky/core/test_core/test_class_generator.rb +129 -0
- data/lib/bucky/core/test_core/test_manager.rb +70 -0
- data/lib/bucky/core/test_core/test_result.rb +92 -0
- data/lib/bucky/test_equipment/evidence/evidence_generator.rb +36 -0
- data/lib/bucky/test_equipment/pageobject/base_pageobject.rb +55 -0
- data/lib/bucky/test_equipment/pageobject/pages.rb +61 -0
- data/lib/bucky/test_equipment/selenium_handler/webdriver_handler.rb +66 -0
- data/lib/bucky/test_equipment/test_case/abst_test_case.rb +49 -0
- data/lib/bucky/test_equipment/test_case/e2e_test_case.rb +70 -0
- data/lib/bucky/test_equipment/test_case/linkstatus_test_case.rb +28 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +97 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_logger.rb +15 -0
- data/lib/bucky/test_equipment/user_operation/user_operator.rb +61 -0
- data/lib/bucky/test_equipment/verifications/abst_verification.rb +13 -0
- data/lib/bucky/test_equipment/verifications/e2e_verification.rb +106 -0
- data/lib/bucky/test_equipment/verifications/js_error_checker.rb +23 -0
- data/lib/bucky/test_equipment/verifications/service_verifications.rb +62 -0
- data/lib/bucky/test_equipment/verifications/status_checker.rb +180 -0
- data/lib/bucky/tools/lint.rb +69 -0
- data/lib/bucky/utils/bucky_logger.rb +25 -0
- data/lib/bucky/utils/bucky_output.rb +23 -0
- data/lib/bucky/utils/config.rb +55 -0
- data/lib/bucky/utils/requests.rb +33 -0
- data/lib/bucky/utils/yaml_load.rb +24 -0
- data/lib/bucky/version.rb +7 -0
- data/system_testing/test_bucky_project/.bucky_home +2 -0
- data/system_testing/test_bucky_project/config/bucky_config.yml +6 -0
- data/system_testing/test_bucky_project/config/e2e_config.yml +15 -0
- data/system_testing/test_bucky_project/config/linkstatus_config.yml +3 -0
- data/system_testing/test_bucky_project/config/test_db_config.yml +8 -0
- data/system_testing/test_bucky_project/services/README.md +1 -0
- data/system_testing/test_bucky_project/services/service_a/pc/pageobject/index.rb +13 -0
- data/system_testing/test_bucky_project/services/service_a/pc/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/pc_e2e.yml +68 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_teardown_each_pc_e2e.yml +35 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/teardown_each_pc_e2e.yml +20 -0
- data/system_testing/test_bucky_project/services/service_a/pc/scenarios/linkstatus/pc_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/sp/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/sp/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/e2e/sp_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/services/service_a/sp/scenarios/linkstatus/sp_link.yml +10 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/pageobject/index.rb +14 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/parts/index.yml +6 -0
- data/system_testing/test_bucky_project/services/service_a/tablet/scenarios/e2e/tablet_e2e_test.yml +26 -0
- data/system_testing/test_bucky_project/system/evidences/README.md +1 -0
- data/system_testing/test_bucky_project/system/evidences/screen_shots/README.md +1 -0
- data/system_testing/test_bucky_project/system/logs/README.md +1 -0
- data/system_testing/test_specification.md +38 -0
- data/system_testing/testing_code/command.bats +42 -0
- data/system_testing/testing_code/e2e.bats +75 -0
- data/system_testing/testing_code/linkstatus.bats +24 -0
- data/template/make_page/pc/pageobject/sample_page.rb +23 -0
- data/template/make_page/pc/parts/sample_page.yml +9 -0
- data/template/make_page/sp/pageobject/sample_page.rb +24 -0
- data/template/make_page/sp/parts/sample_page.yml +9 -0
- data/template/make_page/tablet/pageobject/sample_page.rb +24 -0
- data/template/make_page/tablet/parts/sample_page.yml +9 -0
- data/template/new/.bucky_home +2 -0
- data/template/new/config/bucky_config.yml +6 -0
- data/template/new/config/e2e_config.yml +15 -0
- data/template/new/config/linkstatus_config.yml +3 -0
- data/template/new/config/test_db_config.yml +8 -0
- data/template/new/services/README.md +1 -0
- data/template/new/system/evidences/README.md +1 -0
- data/template/new/system/evidences/screen_shots/README.md +1 -0
- data/template/new/system/logs/README.md +1 -0
- 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,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 @@
|
|
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,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' %>
|
data/system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/setup_each_pc_e2e.yml
ADDED
@@ -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
|