-
Notifications
You must be signed in to change notification settings - Fork 41
MTV-3649 Transfer network setting test automation #2164
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
+325
−192
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e20601d
Make test compatible with provider creation form changes
Pedro-S-Abreu d5089c9
test for controller transfer network
Pedro-S-Abreu 2a10639
Refactor resource management API calls to use a generic helper method
Pedro-S-Abreu 22dc8f4
cleanup
Pedro-S-Abreu 205f592
Remove unused helper files for NAD and Network Map
Pedro-S-Abreu dc7f23f
remove unused methods
Pedro-S-Abreu cd560c0
restore addNetworkMap method
Pedro-S-Abreu dc3c0af
Refactor resource creation helpers t
Pedro-S-Abreu 7808d55
Refactor export of V1NetworkAttachmentDefinition
Pedro-S-Abreu 8cb3afa
Refactor provider creation test conditions
Pedro-S-Abreu 989001f
Refactor TestNad type to directly return V1NetworkAttachmentDefinitio…
Pedro-S-Abreu 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
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 |
|---|---|---|
|
|
@@ -6,8 +6,19 @@ import { CreateProviderPage } from '../../page-objects/CreateProviderPage'; | |
| import { PlanDetailsPage } from '../../page-objects/PlanDetailsPage/PlanDetailsPage'; | ||
| import { EndpointType, ProviderType } from '../../types/enums'; | ||
| import { createPlanTestData, type ProviderData } from '../../types/test-data'; | ||
| import { NavigationHelper } from '../../utils/NavigationHelper'; | ||
| import { getProviderConfig } from '../../utils/providers'; | ||
| import { MTV_NAMESPACE } from '../../utils/resource-manager/constants'; | ||
| import { | ||
| MTV_NAMESPACE, | ||
| NAD_API_VERSION, | ||
| RESOURCE_KINDS, | ||
| } from '../../utils/resource-manager/constants'; | ||
| import { | ||
| createNad as createNadApi, | ||
| createProvider as createProviderApi, | ||
| createSecret as createSecretApi, | ||
| type V1NetworkAttachmentDefinition, | ||
| } from '../../utils/resource-manager/ResourceCreator'; | ||
| import type { ResourceManager } from '../../utils/resource-manager/ResourceManager'; | ||
|
|
||
| export const createSecretObject = ( | ||
|
|
@@ -61,6 +72,13 @@ export type TestPlan = V1beta1Plan & { | |
| testData: ReturnType<typeof createPlanTestData>; | ||
| }; | ||
|
|
||
| export type TestNad = V1NetworkAttachmentDefinition & { | ||
|
||
| metadata: { | ||
| name: string; | ||
| namespace: string; | ||
| }; | ||
| }; | ||
|
|
||
| export interface CreateProviderOptions { | ||
| providerKey?: string; | ||
| namePrefix?: string; | ||
|
|
@@ -78,10 +96,11 @@ const createOvaProviderViaApi = async ( | |
| const secretName = `${providerData.name}-secret`; | ||
| const secret = createSecretObject(secretName, MTV_NAMESPACE, { url: providerData.hostname }); | ||
|
|
||
| const createdSecret = await resourceManager.createSecret(page, secret); | ||
| const createdSecret = await createSecretApi(page, secret, MTV_NAMESPACE); | ||
| if (!createdSecret) { | ||
| throw new Error(`Failed to create secret for OVA provider ${providerData.name}`); | ||
| } | ||
| resourceManager.addSecret(secretName, MTV_NAMESPACE); | ||
|
|
||
| const provider = createProviderObject(providerData.name, MTV_NAMESPACE, { | ||
| type: ProviderType.OVA, | ||
|
|
@@ -90,11 +109,10 @@ const createOvaProviderViaApi = async ( | |
| settings: { applianceManagement: 'true' }, | ||
| }); | ||
|
|
||
| const createdProvider = await resourceManager.createProvider(page, provider); | ||
| const createdProvider = await createProviderApi(page, provider, MTV_NAMESPACE); | ||
| if (!createdProvider) { | ||
| throw new Error(`Failed to create OVA provider ${providerData.name}`); | ||
| } | ||
|
|
||
| resourceManager.addProvider(providerData.name, MTV_NAMESPACE); | ||
| }; | ||
|
|
||
|
|
@@ -207,3 +225,45 @@ export const createPlan = async ( | |
|
|
||
| return buildTestPlanResult(testPlanData); | ||
| }; | ||
|
|
||
| export const createTestNad = async ( | ||
| page: Page, | ||
| resourceManager: ResourceManager, | ||
| options: { | ||
| name?: string; | ||
| namespace: string; | ||
| bridgeName?: string; | ||
| }, | ||
| ): Promise<TestNad> => { | ||
| const { namespace, bridgeName = 'br0' } = options; | ||
| const nadName = options.name ?? `nad-test-${crypto.randomUUID().slice(0, 8)}`; | ||
|
|
||
| const navigationHelper = new NavigationHelper(page); | ||
| await navigationHelper.navigateToConsole(); | ||
|
|
||
| const nadConfig = { | ||
| cniVersion: '0.3.1', | ||
| name: nadName, | ||
| type: 'bridge', | ||
| bridge: bridgeName, | ||
| ipam: {}, | ||
| }; | ||
|
|
||
| const nad: V1NetworkAttachmentDefinition = { | ||
| apiVersion: NAD_API_VERSION, | ||
| kind: RESOURCE_KINDS.NETWORK_ATTACHMENT_DEFINITION, | ||
| metadata: { name: nadName, namespace }, | ||
| spec: { config: JSON.stringify(nadConfig) }, | ||
| }; | ||
|
|
||
| const createdNad = await createNadApi(page, nad, namespace); | ||
| if (!createdNad) { | ||
| throw new Error(`Failed to create NAD ${nadName}`); | ||
| } | ||
| resourceManager.addNad(nadName, namespace); | ||
|
|
||
| return { | ||
| ...createdNad, | ||
| metadata: { ...createdNad.metadata, name: nadName, namespace }, | ||
| }; | ||
| }; | ||
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.
no need for explicit check for boolean and can remove else:
if (testProviderData.useVddkAioOptimization) {
expect(providerResource?.spec?.settings?.useVddkAioOptimization).toBe('true');
} if (!testProviderData.useVddkAioOptimization) { ...