pgtk 0.10.0 → 0.12.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: 54cb8f69f002389612e9b89bb2514fecbb351c5aed6d70eb1ed570bc4ec45b6d
4
+ data.tar.gz: 0f4c36563a1eae3360ce0b3e50ef2f80e91fdc4a7a14b35efa9282499f1b9b20
5
5
  SHA512:
6
- metadata.gz: b6324e9656ae42a7735fa875fc9daffd306370f0f8afe2630900c9b2c76967eb666ba13b91cdf68eff7581c1f66110c5bf0a6bb617e2483ef5461b6f5e614914
7
- data.tar.gz: 7336b30c06b4f34c3a2e4df89ed633a1cdc49f2dcd20020fbb3e65bd9f198508f5a69b6d7729301e0775381d3dd0e8522c41cfe217c3176e2248c1c719c35b1c
6
+ metadata.gz: 53a8780bf422b4660d8a360c5580918a6fa84158d9f0111f382932167f1f8bd027b6135b690ff8b56500c71fae4920ef646ae46ae90d6d178d31c53f1763a347
7
+ data.tar.gz: 5551171c38c80efca7d9dca950c251387634889682085e546de58bafc8f8ffd6579d5beaf2993cdbe34897fbc22047e861c6c6cf3b7dcbed37328e50d6a519ea
@@ -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,23 @@ 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
- bundler-cache: true
48
- - run: bundle install
48
+ - run: bundle update
49
49
  - 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,11 @@ 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 apt-get update
27
+ sudo apt-get install -y libpq-dev postgresql-client postgresql
28
28
  sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/initdb)" /bin/initdb
29
29
  sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/postgres)" /bin/postgres
30
+ sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/pg_ctl)" /bin/pg_ctl
30
31
  pdd -f /dev/null
31
32
  bundle install --no-color
32
33
  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.3)
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
data/README.md CHANGED
@@ -50,6 +50,10 @@ Pgtk::PgsqlTask.new :pgsql do |t|
50
50
  t.password = 'test'
51
51
  t.dbname = 'test'
52
52
  t.yaml = 'target/pgsql-config.yml' # YAML file to be created with connection details
53
+ t.config = { # list of PostgreSQL configuration options
54
+ log_min_messages: 'ERROR',
55
+ log_filename: 'target/pg.log'
56
+ }
53
57
  end
54
58
  ```
55
59
 
@@ -82,7 +82,7 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
82
82
  Dir.chdir(File.dirname(@master)) do
83
83
  qbash(
84
84
  [
85
- 'mvn verify',
85
+ 'mvn', 'verify',
86
86
  '--errors',
87
87
  '--batch-mode',
88
88
  '--fail-fast',
@@ -94,14 +94,13 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
94
94
  '--define',
95
95
  "postgresql.version=#{@postgresql_version}",
96
96
  '--define',
97
- "liquibase.searchPath=#{File.dirname(@master)}",
97
+ Shellwords.escape("liquibase.searchPath=#{File.dirname(@master)}"),
98
98
  '--define',
99
- "liquibase.changeLogFile=#{old ? @master : File.basename(@master)}",
99
+ Shellwords.escape("liquibase.changeLogFile=#{old ? @master : File.basename(@master)}"),
100
100
  '--define',
101
- "liquibase.url=#{Shellwords.escape(url)}",
101
+ Shellwords.escape("liquibase.url=#{url}"),
102
102
  '--define',
103
- "liquibase.password=#{Shellwords.escape(password)}",
104
- '2>&1'
103
+ Shellwords.escape("liquibase.password=#{password}")
105
104
  ]
106
105
  )
107
106
  end
@@ -36,7 +36,7 @@ require_relative '../pgtk'
36
36
  # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
37
37
  # License:: MIT
38
38
  class Pgtk::PgsqlTask < Rake::TaskLib
39
- attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port
39
+ attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port, :config
40
40
 
41
41
  def initialize(*args, &task_block)
42
42
  super()
@@ -44,6 +44,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
44
44
  @fresh_start = false
45
45
  @quiet = false
46
46
  @user = 'test'
47
+ @config = {}
47
48
  @password = 'test'
48
49
  @dbname = 'test'
49
50
  @port = nil
@@ -64,20 +65,21 @@ class Pgtk::PgsqlTask < Rake::TaskLib
64
65
  home = File.expand_path(@dir)
65
66
  FileUtils.rm_rf(home) if @fresh_start
66
67
  raise "Directory/file #{home} is present, use fresh_start=true" if File.exist?(home)
67
- out = "2>&1 #{@quiet ? '>/dev/null' : ''}"
68
+ stdout = @quiet ? nil : $stdout
68
69
  Tempfile.open do |pwfile|
69
70
  File.write(pwfile.path, @password)
70
71
  qbash(
71
72
  [
72
- 'initdb --auth=trust',
73
+ 'initdb',
74
+ '--auth=trust',
73
75
  '-D',
74
76
  Shellwords.escape(home),
75
77
  '--username',
76
78
  Shellwords.escape(@user),
77
79
  '--pwfile',
78
- Shellwords.escape(pwfile.path),
79
- out
80
- ]
80
+ Shellwords.escape(pwfile.path)
81
+ ],
82
+ log: stdout
81
83
  )
82
84
  end
83
85
  port = @port
@@ -87,40 +89,47 @@ class Pgtk::PgsqlTask < Rake::TaskLib
87
89
  else
88
90
  puts "Required TCP port #{port} is used for PostgreSQL server" unless @quiet
89
91
  end
92
+ cmd = [
93
+ 'postgres',
94
+ '-k', Shellwords.escape(home),
95
+ '-D', Shellwords.escape(home),
96
+ @config.map { |k, v| "-c #{Shellwords.escape("#{k}=#{v}")}" },
97
+ "--port=#{port}"
98
+ ].join(' ')
90
99
  pid = Process.spawn(
91
- [
92
- 'postgres',
93
- '-k', Shellwords.escape(home),
94
- '-D', Shellwords.escape(home),
95
- "--port=#{port}"
96
- ].join(' '),
100
+ cmd,
97
101
  $stdout => File.join(home, 'stdout.txt'),
98
102
  $stderr => File.join(home, 'stderr.txt')
99
103
  )
100
104
  File.write(File.join(@dir, 'pid'), pid)
101
105
  at_exit do
102
- `kill -TERM #{pid}`
106
+ qbash("kill -TERM #{pid}", log: stdout)
103
107
  puts "PostgreSQL killed in PID #{pid}" unless @quiet
104
108
  end
105
- sleep 1
106
109
  attempt = 0
107
110
  begin
108
- qbash(
109
- [
110
- "createdb -h localhost -p #{port}",
111
- '--username',
112
- Shellwords.escape(@user),
113
- Shellwords.escape(@dbname),
114
- out
115
- ]
116
- )
111
+ TCPSocket.new('localhost', port)
117
112
  rescue StandardError => e
118
- puts e.message
119
- sleep(5)
113
+ sleep(0.1)
120
114
  attempt += 1
121
- raise if attempt > 10
115
+ if attempt > 50
116
+ puts "+ #{cmd}"
117
+ puts "stdout:\n#{File.read(File.join(home, 'stdout.txt'))}"
118
+ puts "stderr:\n#{File.read(File.join(home, 'stderr.txt'))}"
119
+ raise "Failed to start PostgreSQL database server on port #{port}: #{e.message}"
120
+ end
122
121
  retry
123
122
  end
123
+ qbash(
124
+ [
125
+ 'createdb',
126
+ '--host', 'localhost',
127
+ '--port', Shellwords.escape(port),
128
+ '--username', Shellwords.escape(@user),
129
+ Shellwords.escape(@dbname)
130
+ ],
131
+ log: stdout
132
+ )
124
133
  File.write(
125
134
  @yaml,
126
135
  {
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.12.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
 
@@ -40,10 +40,36 @@ class TestPgsqlTask < Minitest::Test
40
40
  t.dbname = 'test'
41
41
  t.yaml = File.join(dir, 'cfg.yml')
42
42
  t.quiet = true
43
+ t.config = {
44
+ log_min_error_statement: 'ERROR'
45
+ }
43
46
  end
44
47
  Rake::Task['p2'].invoke
45
48
  yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
46
49
  assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
47
50
  end
48
51
  end
52
+
53
+ def test_not_quiet
54
+ Dir.mktmpdir 'test' do |dir|
55
+ Pgtk::PgsqlTask.new(:p3) do |t|
56
+ t.dir = File.join(dir, 'pgsql')
57
+ t.user = 'hello'
58
+ t.password = 'the password'
59
+ t.dbname = 'test'
60
+ t.yaml = File.join(dir, 'cfg.yml')
61
+ t.quiet = false
62
+ t.config = {
63
+ log_directory: dir,
64
+ logging_collector: 'on',
65
+ log_statement: 'all',
66
+ log_filename: 'pgsql.log'
67
+ }
68
+ end
69
+ Rake::Task['p3'].invoke
70
+ yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
71
+ assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
72
+ assert(File.exist?(File.join(dir, 'pgsql.log')))
73
+ end
74
+ end
49
75
  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.12.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