-
Notifications
You must be signed in to change notification settings - Fork 41
MTV-3741 part 1 - Make test compatible with provider creation form changes #2178
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
avivtur
merged 3 commits into
kubev2v:main
from
Pedro-S-Abreu:test-enhance-create-provider-form-1
Jan 12, 2026
Merged
Changes from 1 commit
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
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 |
|---|---|---|
|
|
@@ -9,109 +9,117 @@ if (!existsSync(providersPath)) { | |
| } | ||
|
|
||
| import { CreateProviderPage } from '../../page-objects/CreateProviderPage'; | ||
| import { EndpointType } from '../../types/enums'; | ||
| import { EndpointType, ProviderType } from '../../types/enums'; | ||
| import type { ProviderData } from '../../types/test-data'; | ||
| import { getProviderConfig } from '../../utils/providers'; | ||
| import { MTV_NAMESPACE } from '../../utils/resource-manager/constants'; | ||
| import { ResourceManager } from '../../utils/resource-manager/ResourceManager'; | ||
|
|
||
| const createProviderData = ({ | ||
| useVddkAioOptimization, | ||
| }: { | ||
| useVddkAioOptimization: boolean; | ||
| }): ProviderData => { | ||
| const providerKey = process.env.VSPHERE_PROVIDER ?? 'vsphere-8.0.1'; | ||
| const VSPHERE_KEY = process.env.VSPHERE_PROVIDER ?? 'vsphere-8.0.1'; | ||
| const OVA_KEY = process.env.OVA_PROVIDER ?? 'ova'; | ||
|
|
||
| interface ProviderTestScenario { | ||
| scenarioName: string; | ||
| providerType: ProviderType; | ||
| providerKey: string; | ||
| providerDataOverrides?: Partial<ProviderData>; | ||
| } | ||
|
|
||
| const createProviderData = ( | ||
| providerType: ProviderType, | ||
| providerKey: string, | ||
| overrides?: Partial<ProviderData>, | ||
| ): ProviderData => { | ||
| const providerConfig = getProviderConfig(providerKey); | ||
| const suffix = useVddkAioOptimization ? 'enabled' : 'disabled'; | ||
| const uniqueId = crypto.randomUUID().slice(0, 8); | ||
|
|
||
| return { | ||
| name: `test-vsphere-provider-${suffix}-${crypto.randomUUID().slice(0, 8)}`, | ||
| const baseData: ProviderData = { | ||
| name: `test-${providerType}-provider-${uniqueId}`, | ||
| projectName: MTV_NAMESPACE, | ||
| type: providerConfig.type, | ||
| endpointType: providerConfig.endpoint_type ?? EndpointType.VCENTER, | ||
| hostname: providerConfig.api_url, | ||
| username: providerConfig.username, | ||
| password: providerConfig.password, | ||
| vddkInitImage: providerConfig.vddk_init_image, | ||
| useVddkAioOptimization, | ||
| }; | ||
| }; | ||
|
|
||
| test.describe('Provider Creation Tests', () => { | ||
| const resourceManager = new ResourceManager(); | ||
| if (providerType !== ProviderType.OVA) { | ||
| baseData.username = providerConfig.username; | ||
| baseData.password = providerConfig.password; | ||
| } | ||
|
|
||
| test( | ||
| 'should create a new vsphere provider with VDDK AIO optimization enabled', | ||
| { | ||
| tag: '@downstream', | ||
| }, | ||
| async ({ page }) => { | ||
| const createProvider = new CreateProviderPage(page, resourceManager); | ||
| const testProviderData = createProviderData({ useVddkAioOptimization: true }); | ||
| if (providerType === ProviderType.VSPHERE) { | ||
| baseData.endpointType = providerConfig.endpoint_type ?? EndpointType.VCENTER; | ||
| baseData.vddkInitImage = providerConfig.vddk_init_image; | ||
| } | ||
|
|
||
| await createProvider.navigate(); | ||
| await createProvider.create(testProviderData, true); | ||
| return { ...baseData, ...overrides }; | ||
| }; | ||
|
|
||
| // Verify the useVddkAioOptimization value is persisted in the provider spec | ||
| const providerResource = await resourceManager.fetchProvider(page, testProviderData.name); | ||
| expect(providerResource).not.toBeNull(); | ||
| expect(providerResource?.spec?.settings?.useVddkAioOptimization).toBe('true'); | ||
| }, | ||
| ); | ||
| const providerTestScenarios: ProviderTestScenario[] = [ | ||
| { | ||
| scenarioName: 'vSphere with VDDK AIO optimization enabled', | ||
| providerType: ProviderType.VSPHERE, | ||
| providerKey: VSPHERE_KEY, | ||
| providerDataOverrides: { useVddkAioOptimization: true }, | ||
| }, | ||
| { | ||
| scenarioName: 'vSphere with VDDK AIO optimization disabled', | ||
| providerType: ProviderType.VSPHERE, | ||
| providerKey: VSPHERE_KEY, | ||
| providerDataOverrides: { useVddkAioOptimization: false }, | ||
| }, | ||
| { | ||
| scenarioName: 'OVA provider', | ||
| providerType: ProviderType.OVA, | ||
| providerKey: OVA_KEY, | ||
| }, | ||
| ]; | ||
|
|
||
| test( | ||
| 'should create a new vsphere provider with VDDK AIO optimization disabled', | ||
| { | ||
| tag: '@downstream', | ||
| }, | ||
| async ({ page }) => { | ||
| const createProvider = new CreateProviderPage(page, resourceManager); | ||
| const testProviderData = createProviderData({ useVddkAioOptimization: false }); | ||
|
|
||
| await createProvider.navigate(); | ||
| await createProvider.create(testProviderData, true); | ||
|
|
||
| // Verify the useVddkAioOptimization value is persisted in the provider spec | ||
| const providerResource = await resourceManager.fetchProvider(page, testProviderData.name); | ||
| expect(providerResource).not.toBeNull(); | ||
| // When disabled, the field might be undefined, 'false', or not present | ||
| const aioOptimization = providerResource?.spec?.settings?.useVddkAioOptimization; | ||
| expect(aioOptimization === undefined || aioOptimization === 'false').toBe(true); | ||
| }, | ||
| ); | ||
| test.describe('Provider Creation Tests', () => { | ||
| const resourceManager = new ResourceManager(); | ||
|
|
||
| test( | ||
| 'should create a new OVA provider', | ||
| { | ||
| tag: '@downstream', | ||
| }, | ||
| async ({ page }) => { | ||
| const createProvider = new CreateProviderPage(page, resourceManager); | ||
|
|
||
| // Get OVA provider configuration | ||
| const ovaProviderKey = process.env.OVA_PROVIDER ?? 'ova'; | ||
| const ovaProviderConfig = getProviderConfig(ovaProviderKey); | ||
|
|
||
| const testProviderData: ProviderData = { | ||
| name: `test-ova-provider-${crypto.randomUUID().slice(0, 8)}`, | ||
| projectName: MTV_NAMESPACE, | ||
| type: ovaProviderConfig.type, | ||
| hostname: ovaProviderConfig.api_url, | ||
| }; | ||
|
|
||
| await createProvider.navigate(); | ||
| await createProvider.create(testProviderData, true); | ||
|
|
||
| // Verify the provider resource was created | ||
| const providerResource = await resourceManager.fetchProvider(page, testProviderData.name); | ||
| expect(providerResource).not.toBeNull(); | ||
| expect(providerResource?.spec?.type).toBe('ova'); | ||
| expect(providerResource?.spec?.url).toBe(testProviderData.hostname); | ||
| providerTestScenarios.forEach( | ||
| ({ scenarioName, providerType, providerKey, providerDataOverrides }) => { | ||
| test( | ||
| `should create a new ${providerType} provider: ${scenarioName}`, | ||
| { | ||
| tag: '@downstream', | ||
| }, | ||
| async ({ page }) => { | ||
| const createProvider = new CreateProviderPage(page, resourceManager); | ||
| const testProviderData = createProviderData( | ||
| providerType, | ||
| providerKey, | ||
| providerDataOverrides, | ||
| ); | ||
|
|
||
| await test.step('Navigate to provider creation page', async () => { | ||
| await createProvider.navigate(); | ||
| }); | ||
|
|
||
| await test.step('Create provider', async () => { | ||
| await createProvider.create(testProviderData, true); | ||
| }); | ||
|
|
||
| await test.step('Verify provider resource', async () => { | ||
| const providerResource = await resourceManager.fetchProvider( | ||
| page, | ||
| testProviderData.name, | ||
| ); | ||
| expect(providerResource).not.toBeNull(); | ||
| expect(providerResource?.spec?.type).toBe(providerType); | ||
|
|
||
| if (testProviderData.useVddkAioOptimization === true) { | ||
|
||
| expect(providerResource?.spec?.settings?.useVddkAioOptimization).toBe('true'); | ||
| } else if (testProviderData.useVddkAioOptimization === false) { | ||
|
||
| const aioValue = providerResource?.spec?.settings?.useVddkAioOptimization; | ||
| expect(aioValue === undefined || aioValue === 'false').toBe(true); | ||
| } | ||
| }); | ||
| }, | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| test.afterAll(async () => { | ||
| // Cleanup: Delete the created provider | ||
| await resourceManager.instantCleanup(); | ||
| }); | ||
| }); | ||
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.
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.
worth extracting to a constant to make this file a bit more clear and to easily expand more scenrios