-
Notifications
You must be signed in to change notification settings - Fork 3
Fix the Helm version fetcher with the corrected paths to the chart #159
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
Merged
Merged
Changes from all commits
Commits
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
204 changes: 204 additions & 0 deletions
204
__tests__/extensions/version-fetcher/get-latest-redpanda-helm-version-from-operator.test.js
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,204 @@ | ||
| const getLatestHelmVersion = require('../../../extensions/version-fetcher/get-latest-redpanda-helm-version-from-operator'); | ||
|
|
||
| describe('getLatestHelmVersion', () => { | ||
| let mockGithub; | ||
|
|
||
| beforeEach(() => { | ||
| mockGithub = { | ||
| repos: { | ||
| getContent: jest.fn() | ||
| } | ||
| }; | ||
| }); | ||
|
|
||
| it('should fetch stable helm chart version from release branch', async () => { | ||
| // Mock the GitHub API response | ||
| const mockChartYaml = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| version: 5.9.7 | ||
| description: Redpanda is a streaming data platform | ||
| `; | ||
|
|
||
| mockGithub.repos.getContent.mockResolvedValue({ | ||
| data: { | ||
| content: Buffer.from(mockChartYaml).toString('base64') | ||
| } | ||
| }); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'v25.1.3', | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBe('5.9.7'); | ||
| expect(result.latestBetaRelease).toBeNull(); | ||
| expect(mockGithub.repos.getContent).toHaveBeenCalledWith({ | ||
| owner: 'redpanda-data', | ||
| repo: 'redpanda-operator', | ||
| path: 'charts/redpanda/chart/Chart.yaml', | ||
| ref: 'release/v25.1.x' | ||
| }); | ||
| }); | ||
|
|
||
| it('should fetch both stable and beta helm chart versions', async () => { | ||
| const mockStableChart = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| version: 5.9.7 | ||
| `; | ||
|
|
||
| const mockBetaChart = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| version: 5.10.0-beta1 | ||
| `; | ||
|
|
||
| mockGithub.repos.getContent | ||
| .mockResolvedValueOnce({ | ||
| data: { content: Buffer.from(mockStableChart).toString('base64') } | ||
| }) | ||
| .mockResolvedValueOnce({ | ||
| data: { content: Buffer.from(mockBetaChart).toString('base64') } | ||
| }); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'v25.1.3', | ||
| 'v25.2.1-beta1' | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBe('5.9.7'); | ||
| expect(result.latestBetaRelease).toBe('5.10.0-beta1'); | ||
| expect(mockGithub.repos.getContent).toHaveBeenCalledTimes(2); | ||
| }); | ||
|
|
||
| it('should handle older version format (v2.x.x)', async () => { | ||
| const mockChartYaml = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| version: 2.4.5 | ||
| `; | ||
|
|
||
| mockGithub.repos.getContent.mockResolvedValue({ | ||
| data: { content: Buffer.from(mockChartYaml).toString('base64') } | ||
| }); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'v2.4.2', | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBe('2.4.5'); | ||
| expect(mockGithub.repos.getContent).toHaveBeenCalledWith({ | ||
| owner: 'redpanda-data', | ||
| repo: 'redpanda-operator', | ||
| path: 'charts/redpanda/chart/Chart.yaml', | ||
| ref: 'release/v2.4.x' | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle invalid docker tag format', async () => { | ||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'invalid-tag', | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBeNull(); | ||
| expect(result.latestBetaRelease).toBeNull(); | ||
| expect(mockGithub.repos.getContent).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should handle GitHub API errors gracefully', async () => { | ||
| mockGithub.repos.getContent.mockRejectedValue( | ||
| new Error('Branch not found') | ||
| ); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'v25.1.3', | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBeNull(); | ||
| expect(result.latestBetaRelease).toBeNull(); | ||
| }); | ||
|
|
||
| it('should handle missing version in Chart.yaml', async () => { | ||
| const mockChartYaml = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| description: No version field | ||
| `; | ||
|
|
||
| mockGithub.repos.getContent.mockResolvedValue({ | ||
| data: { content: Buffer.from(mockChartYaml).toString('base64') } | ||
| }); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| 'v25.1.3', | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBeNull(); | ||
| }); | ||
|
|
||
| it('should handle beta tag with -beta suffix', async () => { | ||
| const mockChartYaml = ` | ||
| apiVersion: v2 | ||
| name: redpanda | ||
| version: 5.10.0-beta1 | ||
| `; | ||
|
|
||
| mockGithub.repos.getContent.mockResolvedValue({ | ||
| data: { content: Buffer.from(mockChartYaml).toString('base64') } | ||
| }); | ||
|
|
||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| null, | ||
| 'v25.2.1-beta1' | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBeNull(); | ||
| expect(result.latestBetaRelease).toBe('5.10.0-beta1'); | ||
| expect(mockGithub.repos.getContent).toHaveBeenCalledWith({ | ||
| owner: 'redpanda-data', | ||
| repo: 'redpanda-operator', | ||
| path: 'charts/redpanda/chart/Chart.yaml', | ||
| ref: 'release/v25.2.x' | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle null/undefined dockerTag parameters', async () => { | ||
| const result = await getLatestHelmVersion( | ||
| mockGithub, | ||
| 'redpanda-data', | ||
| 'redpanda-operator', | ||
| null, | ||
| null | ||
| ); | ||
|
|
||
| expect(result.latestStableRelease).toBeNull(); | ||
| expect(result.latestBetaRelease).toBeNull(); | ||
| expect(mockGithub.repos.getContent).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.