Closed
Description
Customer need some guidance on how to mock management SDK.
Problem:
- Some of the classes are
final
- Fluent interface could be hard to mock
PS: note on wiki about mockito on final
class already provided, but this likely not adequent.
E.g. mock this:
// create cluster
KubernetesCluster kubernetesCluster = containerServiceManager.kubernetesClusters().define(aksName)
.withRegion(Region.US_CENTRAL)
.withExistingResourceGroup(rgName)
.withDefaultVersion()
.withRootUsername("testaks")
.withSshKey(SSH_KEY)
.withServicePrincipalClientId(servicePrincipalClientId)
.withServicePrincipalSecret(servicePrincipalSecret)
// zone redundancy
.defineAgentPool(agentPoolName)
.withVirtualMachineSize(ContainerServiceVMSizeTypes.STANDARD_D2_V2)
.withAgentPoolVirtualMachineCount(3)
.withAgentPoolType(AgentPoolType.VIRTUAL_MACHINE_SCALE_SETS)
.withAgentPoolMode(AgentPoolMode.SYSTEM)
.withAvailabilityZones(1, 2, 3)
.attach()
// auto-scaling
// labels and taints
.defineAgentPool(agentPoolName1)
.withVirtualMachineSize(ContainerServiceVMSizeTypes.STANDARD_A2_V2)
.withAgentPoolVirtualMachineCount(1)
.withAutoScaling(1, 3)
.withNodeLabels(Collections.unmodifiableMap(nodeLables))
.withNodeTaints(Collections.unmodifiableList(nodeTaints))
.attach()
// number of nodes = 0
.defineAgentPool(agentPoolName2)
.withVirtualMachineSize(ContainerServiceVMSizeTypes.STANDARD_A2_V2)
.withAgentPoolVirtualMachineCount(0)
.withMaxPodsCount(10)
.attach()
.withDnsPrefix("mp1" + dnsPrefix)
.withAutoScalerProfile(new ManagedClusterPropertiesAutoScalerProfile().withScanInterval("30s"))
.create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment