berl 1.0.6 → 1.0.7
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 +4 -4
- data/lib/berl/application.rb +19 -5
- data/lib/berl/behat_runner.rb +10 -2
- data/lib/berl/database_wizard.rb +12 -10
- data/lib/berl/suites_resolver.rb +5 -3
- data/lib/berl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd67392aa53ccf62c963235de2f928c1b24aa66fa100cd65a2c7e91a676f0d4e
|
4
|
+
data.tar.gz: d4b5c1e82de754cd12a349e8ecf80560fdd567c6f5a27f0bd03c4ae2152ff7dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b03f0a8eafb06e117ac2e3eef42f90755f3e6b574c14e90bca9943d10650cd8e021679f56e1638d69994111c2ac022450df84bb1539a4a99843e60cdb49d77
|
7
|
+
data.tar.gz: ccc600d3d56c243351178647a24124a14c7fffb2ee9bcb980e49916df5232444da30b285c7b166a6128b8f8244043b3c38a8bf01cbd645cbd94afcb4cf0f02bd
|
data/lib/berl/application.rb
CHANGED
@@ -5,13 +5,27 @@ module Berl
|
|
5
5
|
def run
|
6
6
|
start = Time.now
|
7
7
|
|
8
|
-
number_of_workers = ENV['
|
8
|
+
number_of_workers = ENV['BERL_NUM_OF_WORKERS'].to_i ||= 1
|
9
|
+
db_conn_str_tpl = ENV['BERL_DB_CONN_STR_TPL'] ||= "mysql://root@localhost:3306/db_%s"
|
10
|
+
debug = !!ENV['BERL_DEBUG'] ||= false
|
11
|
+
suites_path = ENV['BERL_SUITES_PATH']
|
9
12
|
|
10
|
-
database_wizard = DatabaseWizard.new
|
11
|
-
database_wizard.initialize_num_of_databases(number_of_workers)
|
12
|
-
suites = SuitesResolver.resolve_suites
|
13
|
+
# database_wizard = DatabaseWizard.new(debug)
|
14
|
+
# database_wizard.initialize_num_of_databases(number_of_workers, db_conn_str_tpl)
|
13
15
|
|
14
|
-
|
16
|
+
databases = [
|
17
|
+
sprintf(db_conn_str_tpl, 1),
|
18
|
+
sprintf(db_conn_str_tpl, 2),
|
19
|
+
]
|
20
|
+
|
21
|
+
puts "[Debug] Resolving suites" if debug
|
22
|
+
|
23
|
+
suites_resolver = SuitesResolver.new(suites_path)
|
24
|
+
suites = suites_resolver.resolve_suites
|
25
|
+
|
26
|
+
puts "[Debug] Running Behat" if debug
|
27
|
+
|
28
|
+
behat_runner = BehatRunner.new(number_of_workers, suites, databases, debug)
|
15
29
|
behat_runner.start
|
16
30
|
|
17
31
|
behat_runner.print_errors
|
data/lib/berl/behat_runner.rb
CHANGED
@@ -5,12 +5,13 @@ module Berl
|
|
5
5
|
class BehatRunner
|
6
6
|
attr_reader :num_of_succeed, :num_of_failed
|
7
7
|
|
8
|
-
def initialize(num_of_workers, suites, databases)
|
8
|
+
def initialize(num_of_workers, suites, databases, debug)
|
9
9
|
@num_of_succeed = 0
|
10
10
|
@num_of_failed = 0
|
11
11
|
@num_of_workers = num_of_workers
|
12
12
|
@suites = suites
|
13
13
|
@databases = databases
|
14
|
+
@debug = debug
|
14
15
|
@output = {}
|
15
16
|
end
|
16
17
|
|
@@ -24,6 +25,9 @@ module Berl
|
|
24
25
|
cache = "cache_#{Parallel.worker_number}"
|
25
26
|
|
26
27
|
behat_cmd = build_behat_cmd(database, cache, suite)
|
28
|
+
|
29
|
+
puts "[DEBUG] command: #{behat_cmd}" if @debug
|
30
|
+
|
27
31
|
Open3.popen3(behat_cmd) do |_, stdout, _, wait_thr|
|
28
32
|
result = {}
|
29
33
|
result['output'] = []
|
@@ -33,6 +37,8 @@ module Berl
|
|
33
37
|
result['suite_name'] = suite
|
34
38
|
result['status'] = wait_thr.value == 0 ? 'success' : 'fail'
|
35
39
|
|
40
|
+
puts "[DEBUG] result: #{result}" if @debug
|
41
|
+
|
36
42
|
result
|
37
43
|
end
|
38
44
|
end
|
@@ -42,7 +48,7 @@ module Berl
|
|
42
48
|
cmd = []
|
43
49
|
cmd.push("DATABASE_URL=#{database}")
|
44
50
|
cmd.push("PARALLELE_CACHE_DIR=#{cache}")
|
45
|
-
cmd.push("
|
51
|
+
cmd.push("vendor/bin/behat --suite='#{suite}'")
|
46
52
|
cmd.push("--tags='~@javascript&&~@todo&&~@cli'")
|
47
53
|
cmd.push('--colors --strict --no-interaction -vvv -f progress')
|
48
54
|
|
@@ -52,6 +58,8 @@ module Berl
|
|
52
58
|
private :build_behat_cmd
|
53
59
|
|
54
60
|
def handle_finish(_, _, result)
|
61
|
+
puts "Handling finished job for #{result['suite_name']}" if @debug
|
62
|
+
|
55
63
|
if result['status'] == 'success'
|
56
64
|
@num_of_succeed += 1
|
57
65
|
puts "✅ #{result['suite_name']} (#{num_of_executed}/#{@suites.count})"
|
data/lib/berl/database_wizard.rb
CHANGED
@@ -7,23 +7,21 @@ require 'open3'
|
|
7
7
|
class DatabaseWizard
|
8
8
|
attr_reader :databases
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(debug = false)
|
11
11
|
@databases = []
|
12
12
|
@num_of_set_up_databases = 0
|
13
|
+
@debug = debug
|
13
14
|
end
|
14
15
|
|
15
|
-
def initialize_num_of_databases(num_of_databases)
|
16
|
-
database_connection_string_tpl = ENV["PARALLELE_DATABASE_URL_TEMPLATE"]
|
17
|
-
|
18
|
-
if database_connection_string_tpl.nil?
|
19
|
-
database_connection_string_tpl = "mysql://root:root_password@db/sylius_%s?charset=utf8mb4"
|
20
|
-
end
|
21
|
-
|
16
|
+
def initialize_num_of_databases(num_of_databases, db_conn_str_tpl)
|
22
17
|
Parallel.each(1..num_of_databases, in_threads: num_of_databases, finish: method(:handle_finish)) do |i|
|
23
|
-
database_connection_string = sprintf(
|
18
|
+
database_connection_string = sprintf(db_conn_str_tpl, i)
|
24
19
|
|
25
20
|
setup_db_cmd = build_setup_db_cmd(database_connection_string)
|
26
|
-
|
21
|
+
|
22
|
+
puts "[DEBUG] command: #{setup_db_cmd}" if @debug
|
23
|
+
|
24
|
+
Open3.popen3(setup_db_cmd) do |stdin, stdout, stderr, wait_thr|
|
27
25
|
result = {}
|
28
26
|
result['status'] = wait_thr.value == 0 ? 'success' : 'fail'
|
29
27
|
result['output'] = []
|
@@ -31,6 +29,8 @@ class DatabaseWizard
|
|
31
29
|
result['output'].push(*stderr.readlines)
|
32
30
|
result['database_connection_string'] = database_connection_string
|
33
31
|
|
32
|
+
stdout.readlines.each { |line| puts line } if @debug
|
33
|
+
|
34
34
|
result
|
35
35
|
end
|
36
36
|
end
|
@@ -48,6 +48,8 @@ class DatabaseWizard
|
|
48
48
|
private :build_setup_db_cmd
|
49
49
|
|
50
50
|
def handle_finish(_, _, result)
|
51
|
+
puts "[Debug] Handling finish for #{result['database_connection_string']}" if @debug
|
52
|
+
|
51
53
|
@num_of_set_up_databases += 1
|
52
54
|
if result['status'] == 'fail'
|
53
55
|
puts "❌ Database #{@num_of_set_up_databases} set up"
|
data/lib/berl/suites_resolver.rb
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
# Service to resolve suites
|
4
4
|
class SuitesResolver
|
5
|
-
def
|
6
|
-
suites_path =
|
5
|
+
def initialize(suites_path)
|
6
|
+
@suites_path = suites_path
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
+
def resolve_suites
|
10
|
+
files = Dir.glob("#{Dir.pwd}/#{@suites_path}/**/*.{yml,yaml}")
|
9
11
|
suites = []
|
10
12
|
|
11
13
|
files.each do |path|
|
data/lib/berl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Tobiasz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|