pgtk 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codecov.yml +2 -1
- data/.github/workflows/copyrights.yml +1 -1
- data/.github/workflows/rake.yml +6 -5
- data/.rubocop.yml +3 -3
- data/.rultor.yml +4 -2
- data/Gemfile +5 -5
- data/Gemfile.lock +70 -63
- data/lib/pgtk/pgsql_task.rb +36 -25
- data/lib/pgtk/version.rb +1 -1
- data/resources/pom.xml +1 -1
- data/test/test_pgsql_task.rb +19 -1
- data/test/test_pool.rb +33 -10
- 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: 5dcffe3ba23b17694740ccad32c11d2813f1606b4dfa9b93c63480ebb0e54299
|
4
|
+
data.tar.gz: b166a621155d4be6f8e7294d46b7a07ead34a711a17a3119cd34c289313d8f62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 522afdb2e8c28af25cffd7a298f7caa6e1d964f8551408b7c9200650013d4b2e17c59363e6826011b175269744fb0436a351a79d5d85c5eafcf97d38c2bd7a5a
|
7
|
+
data.tar.gz: fa0eae28c330618462229826c735b1802e483ae07db63f6a8cc617cfb41f2a70dcf40ddd1ec86ce33b5ea3ec605b47f6b50335f22d456cde919a7bbe8c852663
|
@@ -37,9 +37,10 @@ jobs:
|
|
37
37
|
sudo apt-get install -y libpq-dev postgresql-client postgresql
|
38
38
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/initdb)" /bin/initdb
|
39
39
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/postgres)" /bin/postgres
|
40
|
+
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/pg_ctl)" /bin/pg_ctl
|
40
41
|
- run: bundle install
|
41
42
|
- run: bundle exec rake
|
42
|
-
- uses: codecov/codecov-action@
|
43
|
+
- uses: codecov/codecov-action@v5
|
43
44
|
with:
|
44
45
|
token: ${{ secrets.CODECOV_TOKEN }}
|
45
46
|
file: coverage/.resultset.json
|
data/.github/workflows/rake.yml
CHANGED
@@ -27,23 +27,24 @@ on:
|
|
27
27
|
branches:
|
28
28
|
- master
|
29
29
|
jobs:
|
30
|
-
|
31
|
-
name:
|
30
|
+
rake:
|
31
|
+
name: rake
|
32
32
|
strategy:
|
33
33
|
matrix:
|
34
34
|
os: [ubuntu-24.04]
|
35
|
-
ruby: [3.
|
35
|
+
ruby: [3.3]
|
36
36
|
runs-on: ${{ matrix.os }}
|
37
37
|
steps:
|
38
38
|
- uses: actions/checkout@v4
|
39
39
|
- run: |
|
40
40
|
sudo apt-get update
|
41
|
-
sudo apt-get install -y postgresql
|
41
|
+
sudo apt-get install -y libpq-dev postgresql-client postgresql
|
42
42
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/initdb)" /bin/initdb
|
43
43
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/postgres)" /bin/postgres
|
44
|
+
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/pg_ctl)" /bin/pg_ctl
|
44
45
|
- uses: ruby/setup-ruby@v1
|
45
46
|
with:
|
46
47
|
ruby-version: ${{ matrix.ruby }}
|
47
48
|
bundler-cache: true
|
48
|
-
- run: bundle
|
49
|
+
- run: bundle update
|
49
50
|
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -33,15 +33,15 @@ Style/ClassAndModuleChildren:
|
|
33
33
|
Layout/EndOfLine:
|
34
34
|
EnforcedStyle: lf
|
35
35
|
Metrics/BlockLength:
|
36
|
-
Max:
|
36
|
+
Max: 100
|
37
37
|
Layout/EmptyLineAfterGuardClause:
|
38
38
|
Enabled: false
|
39
39
|
Metrics/AbcSize:
|
40
|
-
Max:
|
40
|
+
Max: 100
|
41
41
|
Metrics/CyclomaticComplexity:
|
42
42
|
Max: 15
|
43
43
|
Metrics/ClassLength:
|
44
|
-
Max:
|
44
|
+
Max: 200
|
45
45
|
Metrics/MethodLength:
|
46
46
|
Max: 100
|
47
47
|
Metrics/PerceivedComplexity:
|
data/.rultor.yml
CHANGED
@@ -23,10 +23,12 @@ docker:
|
|
23
23
|
assets:
|
24
24
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
25
25
|
install: |
|
26
|
-
sudo
|
27
|
-
sudo apt-get
|
26
|
+
sudo hostname docker
|
27
|
+
sudo apt-get update
|
28
|
+
sudo apt-get install -y libpq-dev postgresql-client postgresql
|
28
29
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/initdb)" /bin/initdb
|
29
30
|
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/postgres)" /bin/postgres
|
31
|
+
sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/pg_ctl)" /bin/pg_ctl
|
30
32
|
pdd -f /dev/null
|
31
33
|
bundle install --no-color
|
32
34
|
release:
|
data/Gemfile
CHANGED
@@ -23,13 +23,13 @@
|
|
23
23
|
source 'https://rubygems.org'
|
24
24
|
gemspec
|
25
25
|
|
26
|
-
gem 'minitest', '5.25.
|
26
|
+
gem 'minitest', '5.25.4', require: false
|
27
27
|
gem 'minitest-reporters', '~>1.7', require: false
|
28
|
-
gem 'rack', '3.1.
|
28
|
+
gem 'rack', '3.1.8', require: false
|
29
29
|
gem 'rake', '13.2.1', require: false
|
30
|
-
gem 'rspec-rails', '7.0
|
31
|
-
gem 'rubocop', '1.
|
32
|
-
gem 'rubocop-rspec', '3.0
|
30
|
+
gem 'rspec-rails', '7.1.0', require: false
|
31
|
+
gem 'rubocop', '1.69.2', require: false
|
32
|
+
gem 'rubocop-rspec', '3.3.0', require: false
|
33
33
|
gem 'simplecov', '0.22.0', require: false
|
34
34
|
gem 'simplecov-cobertura', '~>2.1'
|
35
35
|
gem 'xcop', '0.7.1', require: false
|
data/Gemfile.lock
CHANGED
@@ -11,25 +11,25 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actionpack (
|
15
|
-
actionview (=
|
16
|
-
activesupport (=
|
14
|
+
actionpack (8.0.1)
|
15
|
+
actionview (= 8.0.1)
|
16
|
+
activesupport (= 8.0.1)
|
17
17
|
nokogiri (>= 1.8.5)
|
18
|
-
|
19
|
-
rack (>= 2.2.4, < 3.2)
|
18
|
+
rack (>= 2.2.4)
|
20
19
|
rack-session (>= 1.0.1)
|
21
20
|
rack-test (>= 0.6.3)
|
22
21
|
rails-dom-testing (~> 2.2)
|
23
22
|
rails-html-sanitizer (~> 1.6)
|
24
23
|
useragent (~> 0.16)
|
25
|
-
actionview (
|
26
|
-
activesupport (=
|
24
|
+
actionview (8.0.1)
|
25
|
+
activesupport (= 8.0.1)
|
27
26
|
builder (~> 3.1)
|
28
27
|
erubi (~> 1.11)
|
29
28
|
rails-dom-testing (~> 2.2)
|
30
29
|
rails-html-sanitizer (~> 1.6)
|
31
|
-
activesupport (
|
30
|
+
activesupport (8.0.1)
|
32
31
|
base64
|
32
|
+
benchmark (>= 0.3)
|
33
33
|
bigdecimal
|
34
34
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
35
35
|
connection_pool (>= 2.2.5)
|
@@ -39,76 +39,80 @@ GEM
|
|
39
39
|
minitest (>= 5.1)
|
40
40
|
securerandom (>= 0.3)
|
41
41
|
tzinfo (~> 2.0, >= 2.0.5)
|
42
|
+
uri (>= 0.13.1)
|
42
43
|
ansi (1.5.0)
|
43
44
|
ast (2.4.2)
|
44
45
|
backtrace (0.4.0)
|
45
46
|
base64 (0.2.0)
|
46
|
-
|
47
|
+
benchmark (0.4.0)
|
48
|
+
bigdecimal (3.1.9)
|
47
49
|
builder (3.3.0)
|
48
50
|
concurrent-ruby (1.3.4)
|
49
51
|
connection_pool (2.4.1)
|
50
52
|
crass (1.0.6)
|
53
|
+
date (3.4.1)
|
51
54
|
diff-lcs (1.5.1)
|
52
55
|
differ (0.1.2)
|
53
|
-
docile (1.4.
|
56
|
+
docile (1.4.1)
|
54
57
|
drb (2.2.1)
|
55
58
|
elapsed (0.0.1)
|
56
59
|
loog (> 0)
|
57
60
|
tago (> 0)
|
58
|
-
erubi (1.13.
|
59
|
-
i18n (1.14.
|
61
|
+
erubi (1.13.1)
|
62
|
+
i18n (1.14.6)
|
60
63
|
concurrent-ruby (~> 1.0)
|
61
|
-
io-console (0.
|
62
|
-
irb (1.14.
|
64
|
+
io-console (0.8.0)
|
65
|
+
irb (1.14.3)
|
63
66
|
rdoc (>= 4.0.0)
|
64
67
|
reline (>= 0.4.2)
|
65
|
-
json (2.
|
68
|
+
json (2.9.1)
|
66
69
|
language_server-protocol (3.17.0.3)
|
67
|
-
logger (1.6.
|
68
|
-
loofah (2.
|
70
|
+
logger (1.6.4)
|
71
|
+
loofah (2.23.1)
|
69
72
|
crass (~> 1.0.2)
|
70
73
|
nokogiri (>= 1.12.0)
|
71
|
-
loog (0.
|
72
|
-
minitest (5.25.
|
74
|
+
loog (0.6.0)
|
75
|
+
minitest (5.25.4)
|
73
76
|
minitest-reporters (1.7.1)
|
74
77
|
ansi
|
75
78
|
builder
|
76
79
|
minitest (>= 5.0)
|
77
80
|
ruby-progressbar
|
78
|
-
nokogiri (1.
|
81
|
+
nokogiri (1.18.0-arm64-darwin)
|
79
82
|
racc (~> 1.4)
|
80
|
-
nokogiri (1.
|
83
|
+
nokogiri (1.18.0-x86_64-linux-gnu)
|
81
84
|
racc (~> 1.4)
|
82
85
|
parallel (1.26.3)
|
83
|
-
parser (3.3.
|
86
|
+
parser (3.3.6.0)
|
84
87
|
ast (~> 2.4.1)
|
85
88
|
racc
|
86
|
-
pg (1.5.
|
87
|
-
psych (5.
|
89
|
+
pg (1.5.9)
|
90
|
+
psych (5.2.2)
|
91
|
+
date
|
88
92
|
stringio
|
89
|
-
qbash (0.
|
93
|
+
qbash (0.2.2)
|
90
94
|
backtrace (> 0)
|
91
95
|
elapsed (> 0)
|
92
96
|
loog (> 0)
|
97
|
+
tago (> 0)
|
93
98
|
racc (1.8.1)
|
94
|
-
rack (3.1.
|
99
|
+
rack (3.1.8)
|
95
100
|
rack-session (2.0.0)
|
96
101
|
rack (>= 3.0.0)
|
97
|
-
rack-test (2.
|
102
|
+
rack-test (2.2.0)
|
98
103
|
rack (>= 1.3)
|
99
|
-
rackup (2.1
|
104
|
+
rackup (2.2.1)
|
100
105
|
rack (>= 3)
|
101
|
-
webrick (~> 1.8)
|
102
106
|
rails-dom-testing (2.2.0)
|
103
107
|
activesupport (>= 5.0.0)
|
104
108
|
minitest
|
105
109
|
nokogiri (>= 1.6)
|
106
|
-
rails-html-sanitizer (1.6.
|
110
|
+
rails-html-sanitizer (1.6.2)
|
107
111
|
loofah (~> 2.21)
|
108
|
-
nokogiri (
|
109
|
-
railties (
|
110
|
-
actionpack (=
|
111
|
-
activesupport (=
|
112
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
113
|
+
railties (8.0.1)
|
114
|
+
actionpack (= 8.0.1)
|
115
|
+
activesupport (= 8.0.1)
|
112
116
|
irb (~> 1.13)
|
113
117
|
rackup (>= 1.0.0)
|
114
118
|
rake (>= 12.2)
|
@@ -116,22 +120,22 @@ GEM
|
|
116
120
|
zeitwerk (~> 2.6)
|
117
121
|
rainbow (3.1.1)
|
118
122
|
rake (13.2.1)
|
119
|
-
random-port (0.7.
|
120
|
-
rdoc (6.
|
123
|
+
random-port (0.7.1)
|
124
|
+
rdoc (6.10.0)
|
121
125
|
psych (>= 4.0.0)
|
122
|
-
regexp_parser (2.
|
123
|
-
reline (0.
|
126
|
+
regexp_parser (2.10.0)
|
127
|
+
reline (0.6.0)
|
124
128
|
io-console (~> 0.5)
|
125
|
-
rexml (3.
|
126
|
-
rspec-core (3.13.
|
129
|
+
rexml (3.4.0)
|
130
|
+
rspec-core (3.13.2)
|
127
131
|
rspec-support (~> 3.13.0)
|
128
|
-
rspec-expectations (3.13.
|
132
|
+
rspec-expectations (3.13.3)
|
129
133
|
diff-lcs (>= 1.2.0, < 2.0)
|
130
134
|
rspec-support (~> 3.13.0)
|
131
|
-
rspec-mocks (3.13.
|
135
|
+
rspec-mocks (3.13.2)
|
132
136
|
diff-lcs (>= 1.2.0, < 2.0)
|
133
137
|
rspec-support (~> 3.13.0)
|
134
|
-
rspec-rails (7.0
|
138
|
+
rspec-rails (7.1.0)
|
135
139
|
actionpack (>= 7.0)
|
136
140
|
activesupport (>= 7.0)
|
137
141
|
railties (>= 7.0)
|
@@ -139,23 +143,23 @@ GEM
|
|
139
143
|
rspec-expectations (~> 3.13)
|
140
144
|
rspec-mocks (~> 3.13)
|
141
145
|
rspec-support (~> 3.13)
|
142
|
-
rspec-support (3.13.
|
143
|
-
rubocop (1.
|
146
|
+
rspec-support (3.13.2)
|
147
|
+
rubocop (1.69.2)
|
144
148
|
json (~> 2.3)
|
145
149
|
language_server-protocol (>= 3.17.0)
|
146
150
|
parallel (~> 1.10)
|
147
151
|
parser (>= 3.3.0.2)
|
148
152
|
rainbow (>= 2.2.2, < 4.0)
|
149
|
-
regexp_parser (>= 2.
|
150
|
-
rubocop-ast (>= 1.
|
153
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
154
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
151
155
|
ruby-progressbar (~> 1.7)
|
152
|
-
unicode-display_width (>= 2.4.0, <
|
153
|
-
rubocop-ast (1.
|
156
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
157
|
+
rubocop-ast (1.37.0)
|
154
158
|
parser (>= 3.3.1.0)
|
155
|
-
rubocop-rspec (3.0
|
159
|
+
rubocop-rspec (3.3.0)
|
156
160
|
rubocop (~> 1.61)
|
157
161
|
ruby-progressbar (1.13.0)
|
158
|
-
securerandom (0.
|
162
|
+
securerandom (0.4.1)
|
159
163
|
simplecov (0.22.0)
|
160
164
|
docile (~> 1.1)
|
161
165
|
simplecov-html (~> 0.11)
|
@@ -163,40 +167,43 @@ GEM
|
|
163
167
|
simplecov-cobertura (2.1.0)
|
164
168
|
rexml
|
165
169
|
simplecov (~> 0.19)
|
166
|
-
simplecov-html (0.
|
170
|
+
simplecov-html (0.13.1)
|
167
171
|
simplecov_json_formatter (0.1.4)
|
168
172
|
slop (4.10.1)
|
169
|
-
stringio (3.1.
|
173
|
+
stringio (3.1.2)
|
170
174
|
tago (0.0.2)
|
171
175
|
thor (1.3.2)
|
172
176
|
tzinfo (2.0.6)
|
173
177
|
concurrent-ruby (~> 1.0)
|
174
|
-
unicode-display_width (
|
175
|
-
|
176
|
-
|
178
|
+
unicode-display_width (3.1.2)
|
179
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
180
|
+
unicode-emoji (4.0.4)
|
181
|
+
uri (1.0.2)
|
182
|
+
useragent (0.16.11)
|
177
183
|
xcop (0.7.1)
|
178
184
|
differ (~> 0.1.2)
|
179
185
|
nokogiri (~> 1.10)
|
180
186
|
rainbow (~> 3.0)
|
181
187
|
slop (~> 4.4)
|
182
|
-
zeitwerk (2.
|
188
|
+
zeitwerk (2.7.1)
|
183
189
|
|
184
190
|
PLATFORMS
|
185
191
|
arm64-darwin-22
|
192
|
+
arm64-darwin-24
|
186
193
|
x86_64-linux
|
187
194
|
|
188
195
|
DEPENDENCIES
|
189
|
-
minitest (= 5.25.
|
196
|
+
minitest (= 5.25.4)
|
190
197
|
minitest-reporters (~> 1.7)
|
191
198
|
pgtk!
|
192
|
-
rack (= 3.1.
|
199
|
+
rack (= 3.1.8)
|
193
200
|
rake (= 13.2.1)
|
194
|
-
rspec-rails (= 7.0
|
195
|
-
rubocop (= 1.
|
196
|
-
rubocop-rspec (= 3.0
|
201
|
+
rspec-rails (= 7.1.0)
|
202
|
+
rubocop (= 1.69.2)
|
203
|
+
rubocop-rspec (= 3.3.0)
|
197
204
|
simplecov (= 0.22.0)
|
198
205
|
simplecov-cobertura (~> 2.1)
|
199
206
|
xcop (= 0.7.1)
|
200
207
|
|
201
208
|
BUNDLED WITH
|
202
|
-
2.5.
|
209
|
+
2.5.16
|
data/lib/pgtk/pgsql_task.rb
CHANGED
@@ -64,20 +64,21 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
64
64
|
home = File.expand_path(@dir)
|
65
65
|
FileUtils.rm_rf(home) if @fresh_start
|
66
66
|
raise "Directory/file #{home} is present, use fresh_start=true" if File.exist?(home)
|
67
|
-
|
67
|
+
stdout = @quiet ? nil : $stdout
|
68
68
|
Tempfile.open do |pwfile|
|
69
69
|
File.write(pwfile.path, @password)
|
70
70
|
qbash(
|
71
71
|
[
|
72
|
-
'initdb
|
72
|
+
'initdb',
|
73
|
+
'--auth=trust',
|
73
74
|
'-D',
|
74
75
|
Shellwords.escape(home),
|
75
76
|
'--username',
|
76
77
|
Shellwords.escape(@user),
|
77
78
|
'--pwfile',
|
78
|
-
Shellwords.escape(pwfile.path)
|
79
|
-
|
80
|
-
|
79
|
+
Shellwords.escape(pwfile.path)
|
80
|
+
],
|
81
|
+
log: stdout
|
81
82
|
)
|
82
83
|
end
|
83
84
|
port = @port
|
@@ -87,40 +88,50 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
87
88
|
else
|
88
89
|
puts "Required TCP port #{port} is used for PostgreSQL server" unless @quiet
|
89
90
|
end
|
91
|
+
cmd = [
|
92
|
+
'postgres',
|
93
|
+
'-k', Shellwords.escape(home),
|
94
|
+
'-D', Shellwords.escape(home),
|
95
|
+
'-c', Shellwords.escape("log_directory=#{home}"),
|
96
|
+
'-c', 'logging_collector=on',
|
97
|
+
'-c', 'log_statement=all',
|
98
|
+
'-c', 'log_filename=pgsql.log',
|
99
|
+
"--port=#{port}"
|
100
|
+
].join(' ')
|
90
101
|
pid = Process.spawn(
|
91
|
-
|
92
|
-
'postgres',
|
93
|
-
'-k', Shellwords.escape(home),
|
94
|
-
'-D', Shellwords.escape(home),
|
95
|
-
"--port=#{port}"
|
96
|
-
].join(' '),
|
102
|
+
cmd,
|
97
103
|
$stdout => File.join(home, 'stdout.txt'),
|
98
104
|
$stderr => File.join(home, 'stderr.txt')
|
99
105
|
)
|
100
106
|
File.write(File.join(@dir, 'pid'), pid)
|
101
107
|
at_exit do
|
102
|
-
|
108
|
+
qbash("kill -TERM #{pid}", log: stdout)
|
103
109
|
puts "PostgreSQL killed in PID #{pid}" unless @quiet
|
104
110
|
end
|
105
|
-
sleep 1
|
106
111
|
attempt = 0
|
107
112
|
begin
|
108
|
-
|
109
|
-
[
|
110
|
-
"createdb -h localhost -p #{port}",
|
111
|
-
'--username',
|
112
|
-
Shellwords.escape(@user),
|
113
|
-
Shellwords.escape(@dbname),
|
114
|
-
out
|
115
|
-
]
|
116
|
-
)
|
113
|
+
TCPSocket.new('localhost', port)
|
117
114
|
rescue StandardError => e
|
118
|
-
|
119
|
-
sleep(5)
|
115
|
+
sleep(0.1)
|
120
116
|
attempt += 1
|
121
|
-
|
117
|
+
if attempt > 50
|
118
|
+
puts "+ #{cmd}"
|
119
|
+
puts "stdout:\n#{File.read(File.join(home, 'stdout.txt'))}"
|
120
|
+
puts "stderr:\n#{File.read(File.join(home, 'stderr.txt'))}"
|
121
|
+
raise "Failed to start PostgreSQL database server on port #{port}: #{e.message}"
|
122
|
+
end
|
122
123
|
retry
|
123
124
|
end
|
125
|
+
qbash(
|
126
|
+
[
|
127
|
+
'createdb',
|
128
|
+
'--host', 'localhost',
|
129
|
+
'--port', Shellwords.escape(port),
|
130
|
+
'--username', Shellwords.escape(@user),
|
131
|
+
Shellwords.escape(@dbname)
|
132
|
+
],
|
133
|
+
log: stdout
|
134
|
+
)
|
124
135
|
File.write(
|
125
136
|
@yaml,
|
126
137
|
{
|
data/lib/pgtk/version.rb
CHANGED
data/resources/pom.xml
CHANGED
data/test/test_pgsql_task.rb
CHANGED
@@ -21,8 +21,8 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'minitest/autorun'
|
24
|
-
require 'tmpdir'
|
25
24
|
require 'rake'
|
25
|
+
require 'tmpdir'
|
26
26
|
require 'yaml'
|
27
27
|
require_relative '../lib/pgtk/pgsql_task'
|
28
28
|
|
@@ -44,6 +44,24 @@ class TestPgsqlTask < Minitest::Test
|
|
44
44
|
Rake::Task['p2'].invoke
|
45
45
|
yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
|
46
46
|
assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
|
47
|
+
assert(File.exist?(File.join(dir, 'pgsql/pgsql.log')))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_not_quiet
|
52
|
+
Dir.mktmpdir 'test' do |dir|
|
53
|
+
Pgtk::PgsqlTask.new(:p3) do |t|
|
54
|
+
t.dir = File.join(dir, 'pgsql')
|
55
|
+
t.user = 'hello'
|
56
|
+
t.password = 'the password'
|
57
|
+
t.dbname = 'test'
|
58
|
+
t.yaml = File.join(dir, 'cfg.yml')
|
59
|
+
t.quiet = false
|
60
|
+
end
|
61
|
+
Rake::Task['p3'].invoke
|
62
|
+
yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
|
63
|
+
assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
|
64
|
+
assert(File.exist?(File.join(dir, 'pgsql/pgsql.log')))
|
47
65
|
end
|
48
66
|
end
|
49
67
|
end
|
data/test/test_pool.rb
CHANGED
@@ -20,14 +20,15 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'loog'
|
23
24
|
require 'minitest/autorun'
|
24
|
-
require 'tmpdir'
|
25
25
|
require 'pg'
|
26
|
+
require 'qbash'
|
26
27
|
require 'rake'
|
28
|
+
require 'tmpdir'
|
27
29
|
require 'yaml'
|
28
|
-
require 'loog'
|
29
|
-
require_relative '../lib/pgtk/pgsql_task'
|
30
30
|
require_relative '../lib/pgtk/liquibase_task'
|
31
|
+
require_relative '../lib/pgtk/pgsql_task'
|
31
32
|
require_relative '../lib/pgtk/pool'
|
32
33
|
|
33
34
|
# Pool test.
|
@@ -127,7 +128,7 @@ class TestPool < Minitest::Test
|
|
127
128
|
t.password = 'A B C привет ! & | !'
|
128
129
|
t.dbname = 'test'
|
129
130
|
t.yaml = File.join(dir, 'cfg.yml')
|
130
|
-
t.quiet =
|
131
|
+
t.quiet = false
|
131
132
|
t.fresh_start = true
|
132
133
|
t.port = port
|
133
134
|
end
|
@@ -139,15 +140,37 @@ class TestPool < Minitest::Test
|
|
139
140
|
)
|
140
141
|
pool.start(1)
|
141
142
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
qbash("pg_ctl -D #{Shellwords.escape(File.join(dir, 'pgsql'))} stop", log: $stdout)
|
144
|
+
cycle = 0
|
145
|
+
loop do
|
146
|
+
begin
|
147
|
+
TCPSocket.new('localhost', port)
|
148
|
+
sleep(0.1)
|
149
|
+
cycle += 1
|
150
|
+
if cycle > 50
|
151
|
+
qbash('ps -ax | grep postgres')
|
152
|
+
raise "Can't stop running postgres at port #{port}, for some reason"
|
153
|
+
end
|
154
|
+
rescue StandardError => e
|
155
|
+
puts e.message
|
156
|
+
break
|
157
|
+
end
|
158
|
+
end
|
147
159
|
assert_raises(PG::UnableToSend, PG::ConnectionBad) do
|
148
160
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
149
161
|
end
|
150
|
-
|
162
|
+
task.reenable
|
163
|
+
task.invoke
|
164
|
+
loop do
|
165
|
+
begin
|
166
|
+
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
167
|
+
break
|
168
|
+
rescue StandardError => e
|
169
|
+
puts e.message
|
170
|
+
sleep(0.1)
|
171
|
+
retry
|
172
|
+
end
|
173
|
+
end
|
151
174
|
end
|
152
175
|
end
|
153
176
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|