Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
43215606
Commit
43215606
authored
Mar 05, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for parseConfig
parent
b697251d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+76
-0
No files found.
pkg/cloudprovider/providers/azure/azure_test.go
View file @
43215606
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
azure
package
azure
import
(
import
(
"bytes"
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
...
@@ -37,10 +38,85 @@ import (
...
@@ -37,10 +38,85 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/autorest/to"
"github.com/stretchr/testify/assert"
)
)
var
testClusterName
=
"testCluster"
var
testClusterName
=
"testCluster"
func
TestParseConfig
(
t
*
testing
.
T
)
{
azureConfig
:=
`{
"aadClientCertPassword": "aadClientCertPassword",
"aadClientCertPath": "aadClientCertPath",
"aadClientId": "aadClientId",
"aadClientSecret": "aadClientSecret",
"cloud":"AzurePublicCloud",
"cloudProviderBackoff": true,
"cloudProviderBackoffDuration": 1,
"cloudProviderBackoffExponent": 1,
"cloudProviderBackoffJitter": 1,
"cloudProviderBackoffRetries": 1,
"cloudProviderRatelimit": true,
"cloudProviderRateLimitBucket": 1,
"CloudProviderRateLimitBucketWrite": 1,
"cloudProviderRateLimitQPS": 1,
"CloudProviderRateLimitQPSWrite": 1,
"location": "location",
"maximumLoadBalancerRuleCount": 1,
"primaryAvailabilitySetName": "primaryAvailabilitySetName",
"primaryScaleSetName": "primaryScaleSetName",
"resourceGroup": "resourceGroup",
"routeTableName": "routeTableName",
"securityGroupName": "securityGroupName",
"subnetName": "subnetName",
"subscriptionId": "subscriptionId",
"tenantId": "tenantId",
"useInstanceMetadata": true,
"useManagedIdentityExtension": true,
"vnetName": "vnetName",
"vnetResourceGroup": "vnetResourceGroup",
vmType: "standard"
}`
expected
:=
&
Config
{
AzureAuthConfig
:
auth
.
AzureAuthConfig
{
AADClientCertPassword
:
"aadClientCertPassword"
,
AADClientCertPath
:
"aadClientCertPath"
,
AADClientID
:
"aadClientId"
,
AADClientSecret
:
"aadClientSecret"
,
Cloud
:
"AzurePublicCloud"
,
SubscriptionID
:
"subscriptionId"
,
TenantID
:
"tenantId"
,
UseManagedIdentityExtension
:
true
,
},
CloudProviderBackoff
:
true
,
CloudProviderBackoffDuration
:
1
,
CloudProviderBackoffExponent
:
1
,
CloudProviderBackoffJitter
:
1
,
CloudProviderBackoffRetries
:
1
,
CloudProviderRateLimit
:
true
,
CloudProviderRateLimitBucket
:
1
,
CloudProviderRateLimitBucketWrite
:
1
,
CloudProviderRateLimitQPS
:
1
,
CloudProviderRateLimitQPSWrite
:
1
,
Location
:
"location"
,
MaximumLoadBalancerRuleCount
:
1
,
PrimaryAvailabilitySetName
:
"primaryAvailabilitySetName"
,
PrimaryScaleSetName
:
"primaryScaleSetName"
,
ResourceGroup
:
"resourceGroup"
,
RouteTableName
:
"routeTableName"
,
SecurityGroupName
:
"securityGroupName"
,
SubnetName
:
"subnetName"
,
UseInstanceMetadata
:
true
,
VMType
:
"standard"
,
VnetName
:
"vnetName"
,
VnetResourceGroup
:
"vnetResourceGroup"
,
}
buffer
:=
bytes
.
NewBufferString
(
azureConfig
)
config
,
err
:=
parseConfig
(
buffer
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
expected
,
config
)
}
// Test flipServiceInternalAnnotation
// Test flipServiceInternalAnnotation
func
TestFlipServiceInternalAnnotation
(
t
*
testing
.
T
)
{
func
TestFlipServiceInternalAnnotation
(
t
*
testing
.
T
)
{
svc
:=
getTestService
(
"servicea"
,
v1
.
ProtocolTCP
,
80
)
svc
:=
getTestService
(
"servicea"
,
v1
.
ProtocolTCP
,
80
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment