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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0e3dc64528c0ea54e3e2cc1d75e142f30ad127bf79ede0fcca307656bc42920
4
- data.tar.gz: c671bfbce992f4c922ecbf228211465bea1623d66d54796802d97d17052ad152
3
+ metadata.gz: 5dcffe3ba23b17694740ccad32c11d2813f1606b4dfa9b93c63480ebb0e54299
4
+ data.tar.gz: b166a621155d4be6f8e7294d46b7a07ead34a711a17a3119cd34c289313d8f62
5
5
  SHA512:
6
- metadata.gz: b6324e9656ae42a7735fa875fc9daffd306370f0f8afe2630900c9b2c76967eb666ba13b91cdf68eff7581c1f66110c5bf0a6bb617e2483ef5461b6f5e614914
7
- data.tar.gz: 7336b30c06b4f34c3a2e4df89ed633a1cdc49f2dcd20020fbb3e65bd9f198508f5a69b6d7729301e0775381d3dd0e8522c41cfe217c3176e2248c1c719c35b1c
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@v4
43
+ - uses: codecov/codecov-action@v5
43
44
  with:
44
45
  token: ${{ secrets.CODECOV_TOKEN }}
45
46
  file: coverage/.resultset.json
@@ -27,4 +27,4 @@ jobs:
27
27
  runs-on: ubuntu-24.04
28
28
  steps:
29
29
  - uses: actions/checkout@v4
30
- - uses: yegor256/copyrights-action@0.0.5
30
+ - uses: yegor256/copyrights-action@0.0.8
@@ -27,23 +27,24 @@ on:
27
27
  branches:
28
28
  - master
29
29
  jobs:
30
- test:
31
- name: test
30
+ rake:
31
+ name: rake
32
32
  strategy:
33
33
  matrix:
34
34
  os: [ubuntu-24.04]
35
- ruby: [3.2]
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 install
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: 50
36
+ Max: 100
37
37
  Layout/EmptyLineAfterGuardClause:
38
38
  Enabled: false
39
39
  Metrics/AbcSize:
40
- Max: 50
40
+ Max: 100
41
41
  Metrics/CyclomaticComplexity:
42
42
  Max: 15
43
43
  Metrics/ClassLength:
44
- Max: 150
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 apt-get -y update
27
- sudo apt-get -y install libpq-dev postgresql-client postgresql
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.1', require: false
26
+ gem 'minitest', '5.25.4', require: false
27
27
  gem 'minitest-reporters', '~>1.7', require: false
28
- gem 'rack', '3.1.7', require: false
28
+ gem 'rack', '3.1.8', require: false
29
29
  gem 'rake', '13.2.1', require: false
30
- gem 'rspec-rails', '7.0.1', require: false
31
- gem 'rubocop', '1.66.1', require: false
32
- gem 'rubocop-rspec', '3.0.5', require: false
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 (7.2.1)
15
- actionview (= 7.2.1)
16
- activesupport (= 7.2.1)
14
+ actionpack (8.0.1)
15
+ actionview (= 8.0.1)
16
+ activesupport (= 8.0.1)
17
17
  nokogiri (>= 1.8.5)
18
- racc
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 (7.2.1)
26
- activesupport (= 7.2.1)
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 (7.2.1)
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
- bigdecimal (3.1.8)
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.0)
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.0)
59
- i18n (1.14.5)
61
+ erubi (1.13.1)
62
+ i18n (1.14.6)
60
63
  concurrent-ruby (~> 1.0)
61
- io-console (0.7.2)
62
- irb (1.14.0)
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.7.2)
68
+ json (2.9.1)
66
69
  language_server-protocol (3.17.0.3)
67
- logger (1.6.1)
68
- loofah (2.22.0)
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.5.2)
72
- minitest (5.25.1)
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.16.7-arm64-darwin)
81
+ nokogiri (1.18.0-arm64-darwin)
79
82
  racc (~> 1.4)
80
- nokogiri (1.16.7-x86_64-linux)
83
+ nokogiri (1.18.0-x86_64-linux-gnu)
81
84
  racc (~> 1.4)
82
85
  parallel (1.26.3)
83
- parser (3.3.5.0)
86
+ parser (3.3.6.0)
84
87
  ast (~> 2.4.1)
85
88
  racc
86
- pg (1.5.6)
87
- psych (5.1.2)
89
+ pg (1.5.9)
90
+ psych (5.2.2)
91
+ date
88
92
  stringio
89
- qbash (0.0.4)
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.7)
99
+ rack (3.1.8)
95
100
  rack-session (2.0.0)
96
101
  rack (>= 3.0.0)
97
- rack-test (2.1.0)
102
+ rack-test (2.2.0)
98
103
  rack (>= 1.3)
99
- rackup (2.1.0)
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.0)
110
+ rails-html-sanitizer (1.6.2)
107
111
  loofah (~> 2.21)
108
- nokogiri (~> 1.14)
109
- railties (7.2.1)
110
- actionpack (= 7.2.1)
111
- activesupport (= 7.2.1)
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.0)
120
- rdoc (6.7.0)
123
+ random-port (0.7.1)
124
+ rdoc (6.10.0)
121
125
  psych (>= 4.0.0)
122
- regexp_parser (2.9.2)
123
- reline (0.5.9)
126
+ regexp_parser (2.10.0)
127
+ reline (0.6.0)
124
128
  io-console (~> 0.5)
125
- rexml (3.3.8)
126
- rspec-core (3.13.1)
129
+ rexml (3.4.0)
130
+ rspec-core (3.13.2)
127
131
  rspec-support (~> 3.13.0)
128
- rspec-expectations (3.13.2)
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.1)
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.1)
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.1)
143
- rubocop (1.66.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.4, < 3.0)
150
- rubocop-ast (>= 1.32.2, < 2.0)
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, < 3.0)
153
- rubocop-ast (1.32.3)
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.5)
159
+ rubocop-rspec (3.3.0)
156
160
  rubocop (~> 1.61)
157
161
  ruby-progressbar (1.13.0)
158
- securerandom (0.3.1)
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.12.3)
170
+ simplecov-html (0.13.1)
167
171
  simplecov_json_formatter (0.1.4)
168
172
  slop (4.10.1)
169
- stringio (3.1.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 (2.5.0)
175
- useragent (0.16.10)
176
- webrick (1.8.1)
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.6.18)
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.1)
196
+ minitest (= 5.25.4)
190
197
  minitest-reporters (~> 1.7)
191
198
  pgtk!
192
- rack (= 3.1.7)
199
+ rack (= 3.1.8)
193
200
  rake (= 13.2.1)
194
- rspec-rails (= 7.0.1)
195
- rubocop (= 1.66.1)
196
- rubocop-rspec (= 3.0.5)
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.18
209
+ 2.5.16
@@ -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
- out = "2>&1 #{@quiet ? '>/dev/null' : ''}"
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 --auth=trust',
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
- out
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
- `kill -TERM #{pid}`
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
- qbash(
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
- puts e.message
119
- sleep(5)
115
+ sleep(0.1)
120
116
  attempt += 1
121
- raise if attempt > 10
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
@@ -28,5 +28,5 @@ require_relative '../pgtk'
28
28
  # License:: MIT
29
29
  module Pgtk
30
30
  # Current version of the library.
31
- VERSION = '0.10.0'
31
+ VERSION = '0.11.0'
32
32
  end
data/resources/pom.xml CHANGED
@@ -30,7 +30,7 @@ SOFTWARE.
30
30
  <packaging>pom</packaging>
31
31
  <properties>
32
32
  <postgresql.version>42.7.4</postgresql.version>
33
- <liquibase.version>4.29.2</liquibase.version>
33
+ <liquibase.version>4.30.0</liquibase.version>
34
34
  </properties>
35
35
  <dependencies>
36
36
  <dependency>
@@ -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 = true
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
- pid = File.read(File.join(dir, 'pgsql/pid')).to_i
143
- `kill -KILL #{pid}`
144
- sleep 1
145
- task.reenable
146
- task.invoke
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
- pool.exec('SELECT * FROM pg_catalog.pg_tables')
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.10.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-09-30 00:00:00.000000000 Z
11
+ date: 2024-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace