Repository navigation
Stop a stone the previous engine started with that engine, and ask before forcing it for an upgrade #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srbaker
wants to merge
3
commits into
main
Choose a base branch
from
fix/upgrade-stop-old-stone
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Stop a stone the previous engine started with that engine, and ask before forcing it for an upgrade #195
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2199ec9
Stop a stone the previous engine started with that engine, and ask be…
srbaker d67e3f9
Run the engine upgrade's integration test against a stone the previou…
srbaker 53f6bf0
Say why a declined force-stop leaves the previous engine's listener down
srbaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
| import * as fs from 'fs'; | ||
| import * as os from 'os'; | ||
| import * as path from 'path'; | ||
| import { afterEach, beforeEach, describe, expect, it } from 'vitest'; | ||
| import { __resetSettings, __setSetting } from '../__mocks__/vscode'; | ||
| import { EngineProcess } from '../gslist'; | ||
| import { engineDirName } from '../paths'; | ||
| import { engineThatStarted, startedByAnotherEngine } from '../processes'; | ||
|
|
||
| /** | ||
| * Which engine's tools stop a stone that is already running. | ||
| * | ||
| * Stones outlive the editor, so after an update moves the pin the stone still | ||
| * up is the previous engine's, and the new engine's stopstone cannot log in to | ||
| * it (4044). Stopping it with the wrong engine is what left a user unable to | ||
| * stop or upgrade their database without reinstalling the old GemDB. | ||
| */ | ||
|
|
||
| const PIN = '4.0.0.a8'; | ||
| const PREVIOUS = '4.0.0.a5'; | ||
|
|
||
| function stone(version: string): EngineProcess { | ||
| return { type: 'stone', name: 'gemdb', version, pid: 101, status: 'OK', responding: true }; | ||
| } | ||
|
|
||
| let root: string; | ||
|
|
||
| beforeEach(() => { | ||
| __resetSettings(); | ||
| root = fs.mkdtempSync(path.join(os.tmpdir(), 'gemdb-engine-')); | ||
| __setSetting('gemdb.rootPath', root); | ||
| __setSetting('gemdb.engineVersion', PIN); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fs.rmSync(root, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| function install(version: string): string { | ||
| const dir = path.join(root, engineDirName(version)); | ||
| fs.mkdirSync(dir); | ||
| return dir; | ||
| } | ||
|
|
||
| describe('the engine that stops a running database', () => { | ||
| it('is the pinned one for a stone the pinned engine started', () => { | ||
| install(PIN); | ||
|
|
||
| expect(startedByAnotherEngine(stone(PIN))).toBe(false); | ||
| expect(engineThatStarted(stone(PIN))).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('is the previous one for a stone the previous engine started', () => { | ||
| install(PIN); | ||
| const previous = install(PREVIOUS); | ||
|
|
||
| expect(startedByAnotherEngine(stone(PREVIOUS))).toBe(true); | ||
| expect(engineThatStarted(stone(PREVIOUS))).toBe(previous); | ||
| }); | ||
|
|
||
| it('falls back to the pinned one when the previous engine is gone', () => { | ||
| install(PIN); | ||
|
|
||
| expect(engineThatStarted(stone(PREVIOUS))).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('takes a version the process list cut short for the pinned one', () => { | ||
| __setSetting('gemdb.engineVersion', '4.0.0.Alpha1'); | ||
|
|
||
| expect(startedByAnotherEngine(stone('4.0.0.Alpha'))).toBe(false); | ||
| }); | ||
|
|
||
| it('is the pinned one when nothing is running', () => { | ||
| expect(startedByAnotherEngine(undefined)).toBe(false); | ||
| expect(engineThatStarted(undefined)).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The "declined" answer here comes from the vscode mock's default
showWarningMessage(which resolvesundefined), so a reader can't see from the test itself that the user said no. Would.mockResolvedValue(undefined)be clearer? It would match the explicit'Stop Anyway'in the next test and keep this test correct if the mock's default ever changes.