Repository navigation
fix(clusters): explain the two saves a region change takes instead of failing the update #1849
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
dawsontoth
wants to merge
4
commits into
claude/1275-region-removal-keeps-siblings
from
claude/1311-guide-region-swap
+297
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
52bc376
fix(clusters): explain the two saves a region swap takes before the u…
dawsontoth 7502e12
fix(clusters): say which regions to remove after a multi-region swap
dawsontoth c215cde
test(clusters): pin the one-region swap guidance for a tier missing f…
dawsontoth c81ec95
fix(clusters): name every region a swap adds in the two-save steps
dawsontoth 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
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
87 changes: 87 additions & 0 deletions
87
src/features/clusters/upsert/lib/describeRegionSwap.test.ts
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,87 @@ | ||
| import type { SchemaRegion } from '@/integrations/api/api.gen'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { describeRegionSwap, RegionCohort, regionCohortsOfPlans } from './describeRegionSwap'; | ||
| import { buildRegionLookup } from './regionLookup'; | ||
|
|
||
| const catalog = (names: string[]): RegionCohort[] => names.map(name => ({ key: name, name })); | ||
| const swap = (currentRegionNames: string[], selectedRegionNames: string[], singleRegionTier = false) => | ||
| describeRegionSwap({ | ||
| currentRegions: catalog(currentRegionNames), | ||
| selectedRegions: catalog(selectedRegionNames), | ||
| singleRegionTier, | ||
| }); | ||
|
|
||
| describe('regionCohortsOfPlans', () => { | ||
| const lookup = buildRegionLookup( | ||
| [ | ||
| { id: 'us-1', region: 'US', latencyDescription: '83ms', instanceCount: 2 }, | ||
| { id: 'eu-1', region: 'Europe', latencyDescription: '58ms', instanceCount: 2 }, | ||
| ] as SchemaRegion[], | ||
| [{ id: 'oreg-1', organizationId: 'org-a', name: 'Edge', placement: { gcp: ['us-east1', 'us-west1'] } }], | ||
| undefined, | ||
| ); | ||
|
|
||
| it('keys a catalog plan by its region name and a custom region by its id', () => { | ||
| expect(regionCohortsOfPlans([ | ||
| { planId: 'shared', regionId: 'eu-1' }, | ||
| { planId: 'shared', regionId: 'oreg-1', quantity: 2 }, | ||
| ], lookup)).toEqual([{ key: 'Europe', name: 'Europe' }, { key: 'oreg-1', name: 'Edge' }]); | ||
| }); | ||
|
|
||
| it('falls back to what a plan the lookup lacks carries', () => { | ||
| expect(regionCohortsOfPlans([ | ||
| { planId: 'shared', regionId: 'retired-1', region: 'Asia' }, | ||
| { planId: 'shared', regionId: 'oreg-gone', region: 'Old edge' }, | ||
| ], lookup)).toEqual([{ key: 'Asia', name: 'Asia' }, { key: 'oreg-gone', name: 'Old edge' }]); | ||
| }); | ||
|
|
||
| it('skips plans with no region, such as self-hosted instances', () => { | ||
| expect(regionCohortsOfPlans([{ planId: 'self-hosted-0' }], lookup)).toEqual([]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('describeRegionSwap', () => { | ||
| it('stays quiet for a new cluster, which has no current regions', () => { | ||
| expect(swap([], ['Europe'])).toBeNull(); | ||
| }); | ||
|
|
||
| it('stays quiet while any current region is kept', () => { | ||
| expect(swap(['US'], ['US'])).toBeNull(); | ||
| expect(swap(['US'], ['Europe', 'US'])).toBeNull(); | ||
| expect(swap(['US', 'Asia'], ['Asia', 'Europe'])).toBeNull(); | ||
| }); | ||
|
|
||
| it('stays quiet until a region is actually chosen', () => { | ||
| expect(swap(['US'], [])).toBeNull(); | ||
| expect(swap(['US'], [''])).toBeNull(); | ||
| }); | ||
|
|
||
| it('names the region to keep and the one to add', () => { | ||
| expect(swap(['US'], ['', 'Europe'])).toBe( | ||
| "A cluster can't move out of all its current regions in one update. Keep US, add Europe as an additional region and save, then remove US once that update has finished.", | ||
| ); | ||
| }); | ||
|
|
||
| it('asks to keep at least one of several current regions', () => { | ||
| expect(swap(['US', 'Asia', 'US'], ['Europe', 'Canada'])).toBe( | ||
| "A cluster can't move out of all its current regions in one update. Keep at least one of US and Asia, add Europe and Canada as additional regions and save, then remove the old regions that are left once that update has finished.", | ||
| ); | ||
| }); | ||
|
|
||
| it('does not suggest a second region on a tier that allows only one', () => { | ||
| expect(swap(['US'], ['Europe'], true)).toBe( | ||
| "A cluster can't move out of all its current regions in one update, and this tier allows only one region, so it can't move from US to Europe. Create a new cluster in Europe instead.", | ||
| ); | ||
| }); | ||
|
|
||
| it('matches a custom region by id, as central manager does, not by its name', () => { | ||
| const edge = { key: 'oreg-1', name: 'US' }; | ||
| expect(describeRegionSwap({ | ||
| currentRegions: [edge], | ||
| selectedRegions: [{ ...edge, name: 'US, renamed' }, ...catalog(['Europe'])], | ||
| singleRegionTier: false, | ||
| })).toBeNull(); | ||
| expect(describeRegionSwap({ currentRegions: [edge], selectedRegions: catalog(['US']), singleRegionTier: false })) | ||
| .not.toBeNull(); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.