-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prerelease/9.0.0-alpha' into jw/migrate-pg-settings-log…
…-verbose
- Loading branch information
Showing
10 changed files
with
120 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/cli/src/commands/pg/settings/auto-explain/log-analyze.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {Args} from '@oclif/core' | ||
import heredoc from 'tsheredoc' | ||
import {PGSettingsCommand, booleanConverter, BooleanAsString} from '../../../../lib/pg/setter' | ||
import {SettingKey, Setting} from '../../../../lib/pg/types' | ||
|
||
export default class LogAnalyze extends PGSettingsCommand { | ||
static topic = 'pg' | ||
static description = heredoc(` | ||
Shows actual run times on the execution plan. | ||
This is equivalent to calling EXPLAIN ANALYZE. | ||
WARNING: EXPLAIN ANALYZE will be run on ALL queries, not just logged queries. This can cause significant performance impacts to your database and should be used with caution. | ||
`) | ||
|
||
static args = { | ||
database: Args.string(), | ||
value: Args.string(), | ||
} | ||
|
||
protected settingKey = 'auto_explain.log_analyze' as SettingKey | ||
|
||
protected convertValue(val: BooleanAsString): boolean { | ||
return booleanConverter(val) | ||
} | ||
|
||
protected explain(setting: Setting<boolean>) { | ||
if (setting.value) { | ||
return 'EXPLAIN ANALYZE execution plans will be logged.' | ||
} | ||
|
||
return 'EXPLAIN ANALYZE execution plans will not be logged.' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/cli/test/unit/commands/pg/settings/auto-explain/log-analyze.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {expect} from '@oclif/test' | ||
import * as nock from 'nock' | ||
import {stdout} from 'stdout-stderr' | ||
import heredoc from 'tsheredoc' | ||
import runCommand from '../../../../../helpers/runCommand' | ||
import Cmd from '../../../../../../src/commands/pg/settings/auto-explain/log-analyze' | ||
import * as fixtures from '../../../../../fixtures/addons/fixtures' | ||
|
||
describe('pg:settings:auto-explain:log-analyze', () => { | ||
const addon = fixtures.addons['dwh-db'] | ||
let api: nock.Scope | ||
|
||
beforeEach(() => { | ||
api = nock('https://api.heroku.com') | ||
.post('/actions/addons/resolve', { | ||
app: 'myapp', | ||
addon: 'test-database', | ||
}).reply(200, [addon]) | ||
}) | ||
|
||
afterEach(() => { | ||
nock.cleanAll() | ||
}) | ||
|
||
it('updates settings for auto_explain.log_analyze with value', async () => { | ||
const pg = nock('https://api.data.heroku.com') | ||
.patch(`/postgres/v0/databases/${addon.id}/config`).reply(200, {'auto_explain.log_analyze': {value: true}}) | ||
|
||
await runCommand(Cmd, ['--app', 'myapp', 'test-database', 'true']) | ||
|
||
api.done() | ||
pg.done() | ||
|
||
expect(stdout.output).to.equal(heredoc(` | ||
auto-explain.log-analyze has been set to true for ${addon.name}. | ||
EXPLAIN ANALYZE execution plans will be logged. | ||
`)) | ||
}) | ||
|
||
it('shows settings for auto_explain.log_analyze with no value', async () => { | ||
const pg = nock('https://api.data.heroku.com') | ||
.get(`/postgres/v0/databases/${addon.id}/config`).reply(200, {'auto_explain.log_analyze': {value: false}}) | ||
|
||
await runCommand(Cmd, ['--app', 'myapp', 'test-database']) | ||
|
||
api.done() | ||
pg.done() | ||
|
||
expect(stdout.output).to.equal(heredoc(` | ||
auto-explain.log-analyze is set to false for ${addon.name}. | ||
EXPLAIN ANALYZE execution plans will not be logged. | ||
`)) | ||
}) | ||
}) |
26 changes: 0 additions & 26 deletions
26
packages/pg-v5/commands/settings/auto_explain_log_analyze.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters