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

Commit

Permalink
move mock container function out
Browse files Browse the repository at this point in the history
  • Loading branch information
CecileRobertMichon committed Jul 3, 2018
1 parent 298bd61 commit 2b3a0a1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 85 deletions.
90 changes: 90 additions & 0 deletions pkg/acsengine/mocks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package acsengine

import (
"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/helpers"
"github.com/satori/go.uuid"
)

// CreateMockContainerService returns a mock container service for testing purposes
func CreateMockContainerService(containerServiceName, orchestratorVersion string, masterCount, agentCount int, certs bool) *api.ContainerService {
cs := api.ContainerService{}
cs.ID = uuid.NewV4().String()
cs.Location = "eastus"
cs.Name = containerServiceName

cs.Properties = &api.Properties{}

cs.Properties.MasterProfile = &api.MasterProfile{}
cs.Properties.MasterProfile.Count = masterCount
cs.Properties.MasterProfile.DNSPrefix = "testmaster"
cs.Properties.MasterProfile.VMSize = "Standard_D2_v2"

cs.Properties.AgentPoolProfiles = []*api.AgentPoolProfile{}
agentPool := &api.AgentPoolProfile{}
agentPool.Count = agentCount
agentPool.Name = "agentpool1"
agentPool.VMSize = "Standard_D2_v2"
agentPool.OSType = "Linux"
agentPool.AvailabilityProfile = "AvailabilitySet"
agentPool.StorageProfile = "StorageAccount"

cs.Properties.AgentPoolProfiles = append(cs.Properties.AgentPoolProfiles, agentPool)

cs.Properties.LinuxProfile = &api.LinuxProfile{
AdminUsername: "azureuser",
SSH: struct {
PublicKeys []api.PublicKey `json:"publicKeys"`
}{},
}

cs.Properties.LinuxProfile.AdminUsername = "azureuser"
cs.Properties.LinuxProfile.SSH.PublicKeys = append(
cs.Properties.LinuxProfile.SSH.PublicKeys, api.PublicKey{KeyData: "test"})

cs.Properties.ServicePrincipalProfile = &api.ServicePrincipalProfile{}
cs.Properties.ServicePrincipalProfile.ClientID = "DEC923E3-1EF1-4745-9516-37906D56DEC4"
cs.Properties.ServicePrincipalProfile.Secret = "DEC923E3-1EF1-4745-9516-37906D56DEC4"

cs.Properties.OrchestratorProfile = &api.OrchestratorProfile{}
cs.Properties.OrchestratorProfile.OrchestratorType = api.Kubernetes
cs.Properties.OrchestratorProfile.OrchestratorVersion = orchestratorVersion
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{
EnableSecureKubelet: helpers.PointerToBool(api.DefaultSecureKubeletEnabled),
EnableRbac: helpers.PointerToBool(api.DefaultRBACEnabled),
EtcdDiskSizeGB: DefaultEtcdDiskSize,
ServiceCIDR: DefaultKubernetesServiceCIDR,
DockerBridgeSubnet: DefaultDockerBridgeSubnet,
DNSServiceIP: DefaultKubernetesDNSServiceIP,
GCLowThreshold: DefaultKubernetesGCLowThreshold,
GCHighThreshold: DefaultKubernetesGCHighThreshold,
MaxPods: DefaultKubernetesMaxPodsVNETIntegrated,
ClusterSubnet: DefaultKubernetesSubnet,
ContainerRuntime: DefaultContainerRuntime,
NetworkPlugin: DefaultNetworkPlugin,
NetworkPolicy: DefaultNetworkPolicy,
EtcdVersion: DefaultEtcdVersion,
KubeletConfig: make(map[string]string),
}

cs.Properties.CertificateProfile = &api.CertificateProfile{}
if certs {
cs.Properties.CertificateProfile.CaCertificate = "cacert"
cs.Properties.CertificateProfile.CaPrivateKey = "cakey"
cs.Properties.CertificateProfile.KubeConfigCertificate = "kubeconfigcert"
cs.Properties.CertificateProfile.KubeConfigPrivateKey = "kubeconfigkey"
cs.Properties.CertificateProfile.APIServerCertificate = "apiservercert"
cs.Properties.CertificateProfile.APIServerPrivateKey = "apiserverkey"
cs.Properties.CertificateProfile.ClientCertificate = "clientcert"
cs.Properties.CertificateProfile.ClientPrivateKey = "clientkey"
cs.Properties.CertificateProfile.EtcdServerCertificate = "etcdservercert"
cs.Properties.CertificateProfile.EtcdServerPrivateKey = "etcdserverkey"
cs.Properties.CertificateProfile.EtcdClientCertificate = "etcdclientcert"
cs.Properties.CertificateProfile.EtcdClientPrivateKey = "etcdclientkey"
cs.Properties.CertificateProfile.EtcdPeerCertificates = []string{"etcdpeercert1", "etcdpeercert2", "etcdpeercert3", "etcdpeercert4", "etcdpeercert5"}
cs.Properties.CertificateProfile.EtcdPeerPrivateKeys = []string{"etcdpeerkey1", "etcdpeerkey2", "etcdpeerkey3", "etcdpeerkey4", "etcdpeerkey5"}

}

return &cs
}
85 changes: 0 additions & 85 deletions pkg/acsengine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/api/v20160330"
"github.com/Azure/acs-engine/pkg/api/vlabs"
"github.com/Azure/acs-engine/pkg/helpers"
"github.com/Azure/acs-engine/pkg/i18n"
uuid "github.com/satori/go.uuid"
)

// DCOSNodeType represents the type of DCOS Node
Expand Down Expand Up @@ -103,86 +101,3 @@ type KeyVaultRef struct {
}

type paramsMap map[string]interface{}

// CreateMockContainerService returns a mock container service for testing purposes
func CreateMockContainerService(containerServiceName, orchestratorVersion string, masterCount, agentCount int, certs bool) *api.ContainerService {
cs := api.ContainerService{}
cs.ID = uuid.NewV4().String()
cs.Location = "eastus"
cs.Name = containerServiceName

cs.Properties = &api.Properties{}

cs.Properties.MasterProfile = &api.MasterProfile{}
cs.Properties.MasterProfile.Count = masterCount
cs.Properties.MasterProfile.DNSPrefix = "testmaster"
cs.Properties.MasterProfile.VMSize = "Standard_D2_v2"

cs.Properties.AgentPoolProfiles = []*api.AgentPoolProfile{}
agentPool := &api.AgentPoolProfile{}
agentPool.Count = agentCount
agentPool.Name = "agentpool1"
agentPool.VMSize = "Standard_D2_v2"
agentPool.OSType = "Linux"
agentPool.AvailabilityProfile = "AvailabilitySet"
agentPool.StorageProfile = "StorageAccount"

cs.Properties.AgentPoolProfiles = append(cs.Properties.AgentPoolProfiles, agentPool)

cs.Properties.LinuxProfile = &api.LinuxProfile{
AdminUsername: "azureuser",
SSH: struct {
PublicKeys []api.PublicKey `json:"publicKeys"`
}{},
}

cs.Properties.LinuxProfile.AdminUsername = "azureuser"
cs.Properties.LinuxProfile.SSH.PublicKeys = append(
cs.Properties.LinuxProfile.SSH.PublicKeys, api.PublicKey{KeyData: "test"})

cs.Properties.ServicePrincipalProfile = &api.ServicePrincipalProfile{}
cs.Properties.ServicePrincipalProfile.ClientID = "DEC923E3-1EF1-4745-9516-37906D56DEC4"
cs.Properties.ServicePrincipalProfile.Secret = "DEC923E3-1EF1-4745-9516-37906D56DEC4"

cs.Properties.OrchestratorProfile = &api.OrchestratorProfile{}
cs.Properties.OrchestratorProfile.OrchestratorType = api.Kubernetes
cs.Properties.OrchestratorProfile.OrchestratorVersion = orchestratorVersion
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{
EnableSecureKubelet: helpers.PointerToBool(api.DefaultSecureKubeletEnabled),
EnableRbac: helpers.PointerToBool(api.DefaultRBACEnabled),
EtcdDiskSizeGB: DefaultEtcdDiskSize,
ServiceCIDR: DefaultKubernetesServiceCIDR,
DockerBridgeSubnet: DefaultDockerBridgeSubnet,
DNSServiceIP: DefaultKubernetesDNSServiceIP,
GCLowThreshold: DefaultKubernetesGCLowThreshold,
GCHighThreshold: DefaultKubernetesGCHighThreshold,
MaxPods: DefaultKubernetesMaxPodsVNETIntegrated,
ClusterSubnet: DefaultKubernetesSubnet,
ContainerRuntime: DefaultContainerRuntime,
NetworkPlugin: DefaultNetworkPlugin,
NetworkPolicy: DefaultNetworkPolicy,
EtcdVersion: DefaultEtcdVersion,
KubeletConfig: make(map[string]string),
}

cs.Properties.CertificateProfile = &api.CertificateProfile{}
if certs {
cs.Properties.CertificateProfile.CaCertificate = "cacert"
cs.Properties.CertificateProfile.CaPrivateKey = "cakey"
cs.Properties.CertificateProfile.KubeConfigCertificate = "kubeconfigcert"
cs.Properties.CertificateProfile.KubeConfigPrivateKey = "kubeconfigkey"
cs.Properties.CertificateProfile.APIServerCertificate = "apiservercert"
cs.Properties.CertificateProfile.APIServerPrivateKey = "apiserverkey"
cs.Properties.CertificateProfile.ClientCertificate = "clientcert"
cs.Properties.CertificateProfile.ClientPrivateKey = "clientkey"
cs.Properties.CertificateProfile.EtcdServerCertificate = "etcdservercert"
cs.Properties.CertificateProfile.EtcdServerPrivateKey = "etcdserverkey"
cs.Properties.CertificateProfile.EtcdClientCertificate = "etcdclientcert"
cs.Properties.CertificateProfile.EtcdClientPrivateKey = "etcdclientkey"
cs.Properties.CertificateProfile.EtcdPeerCertificates = []string{"etcdpeercert1", "etcdpeercert2", "etcdpeercert3", "etcdpeercert4", "etcdpeercert5"}
cs.Properties.CertificateProfile.EtcdPeerPrivateKeys = []string{"etcdpeerkey1", "etcdpeerkey2", "etcdpeerkey3", "etcdpeerkey4", "etcdpeerkey5"}

}

return &cs
}

0 comments on commit 2b3a0a1

Please sign in to comment.