Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

test: add VMSS client interfaces and mocks to make upgrade testable #590

Merged
merged 2 commits into from Feb 27, 2019

Conversation

serbrech
Copy link
Member

Reason for Change:

This is extracting the vmss interfaces and mocks from the upgrade --force PR to reduce its footprint.
One test is carried over, which I just marked as skipped here as it lacks the implementation to pass

@acs-bot acs-bot added the size/L label Feb 26, 2019
@codecov
Copy link

codecov bot commented Feb 27, 2019

Codecov Report

Merging #590 into master will decrease coverage by 0.01%.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##           master     #590      +/-   ##
==========================================
- Coverage    56.7%   56.68%   -0.02%     
==========================================
  Files          91       91              
  Lines       13898    13902       +4     
==========================================
  Hits         7881     7881              
- Misses       5352     5355       +3     
- Partials      665      666       +1

@@ -36,13 +36,15 @@ func (az *AzureClient) DeleteVirtualMachine(ctx context.Context, resourceGroup,
}

// ListVirtualMachineScaleSets returns (the first page of) the vmss resources in the specified resource group.
func (az *AzureClient) ListVirtualMachineScaleSets(ctx context.Context, resourceGroup string) (compute.VirtualMachineScaleSetListResultPage, error) {
return az.virtualMachineScaleSetsClient.List(ctx, resourceGroup)
func (az *AzureClient) ListVirtualMachineScaleSets(ctx context.Context, resourceGroup string) (VirtualMachineScaleSetListResultPage, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this will require a change to AKS implementation, as it consumes this client+method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't cause a problem as the interface is 1-1 with the compute type, and all other methods currently depend on these interfaces. If we're lucky, the import will already be present.
Otherwise, good reminder to always depend on our interface types and never on the compute types...

}

// ListVirtualMachineScaleSetVMs returns the list of VMs per VMSS
func (az *AzureClient) ListVirtualMachineScaleSetVMs(ctx context.Context, resourceGroup, virtualMachineScaleSet string) (compute.VirtualMachineScaleSetVMListResultPage, error) {
return az.virtualMachineScaleSetVMsClient.List(ctx, resourceGroup, virtualMachineScaleSet, "", "", "")
func (az *AzureClient) ListVirtualMachineScaleSetVMs(ctx context.Context, resourceGroup, virtualMachineScaleSet string) (VirtualMachineScaleSetVMListResultPage, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

//MakeFakeVirtualMachine returns a fake compute.VirtualMachine
func (mc *MockAKSEngineClient) MakeFakeVirtualMachine() compute.VirtualMachine {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since this is already a mock function, using "fake" in the name is redundant. Also slight preference for mock over fake in comment wording.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I already commented before, the mockClient stubs functions like CreateVirtualMachine that are real function on the service. This is a helper builder function that return a default instance of a VirtualMachine. the Fake part of the name is to distinguish it from the functions exposed by the actual service that we mock

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're saying existing MockAKSEngineClient methods (e.g., ListVirtualMachineScaleSets) represent mock equivalents of identically names methods in the real client libraries?

If that's the case, I'd argue we don't actually want to be adding these "fake" methods onto pre-existing mock libraries that fit that description, and better to create static functions that access the mock objects in order to return an appropriate fake, single-use object for testing.

I don't want to block progress, but something to think about as the mock + fake semantics are arguably a bit confusing.

Copy link
Member Author

@serbrech serbrech Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I extracted this for reusability as it was inlined in the mockclient code and duplicated. I first wanted it standalone, but it relied on other parameters from the mockClient and so, I decided to keep it there for simplicity. it is used by the client to generate the faked results, and it can be used from the tests to build dummy objects.

@CecileRobertMichon
Copy link
Contributor

s/Vmss/VMSS in the title/commit message for release notes

@CecileRobertMichon
Copy link
Contributor

lgtm besides some minor comments on wording/formatting

@jackfrancis
Copy link
Member

back-compat tests passed

@serbrech
Copy link
Member Author

serbrech commented Feb 27, 2019

s/Vmss/VMSS in the title/commit message for release notes .

squashed the 2 commits and adjusted the comment

@CecileRobertMichon CecileRobertMichon changed the title test: Vmss interface mocks test: add VMSS client interfaces and mocks to make upgrade testable Feb 27, 2019
@jackfrancis
Copy link
Member

/lgtm

@acs-bot acs-bot added the lgtm label Feb 27, 2019
@jackfrancis jackfrancis merged commit 405af08 into Azure:master Feb 27, 2019
@acs-bot
Copy link

acs-bot commented Feb 27, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis, serbrech

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

juhacket pushed a commit to juhacket/aks-engine that referenced this pull request Mar 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants