Skip to content

Commit

Permalink
fix(e2e): Add default meshconfig
Browse files Browse the repository at this point in the history
Signed-off-by: nshankar13 <[email protected]>
  • Loading branch information
nshankar13 committed Jun 10, 2021
1 parent 9684c97 commit e13f4c7
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions tests/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,25 @@ func (td *OsmTestData) LoadImagesToKind(imageNames []string) error {
return nil
}

func setMeshConfigToDefault(instOpts InstallOSMOpts, meshConfig *v1alpha1.MeshConfig) (defaultConfig *v1alpha1.MeshConfig) {
meshConfig.Spec.Traffic.EnableEgress = instOpts.EgressEnabled
meshConfig.Spec.Traffic.EnablePermissiveTrafficPolicyMode = instOpts.EnablePermissiveMode
meshConfig.Spec.Traffic.OutboundPortExclusionList = []int{}
meshConfig.Spec.Traffic.OutboundIPRangeExclusionList = []string{}

meshConfig.Spec.Observability.EnableDebugServer = instOpts.EnableDebugServer

meshConfig.Spec.Sidecar.Resources = corev1.ResourceRequirements{}
meshConfig.Spec.Sidecar.EnablePrivilegedInitContainer = instOpts.EnablePrivilegedInitContainer
meshConfig.Spec.Sidecar.LogLevel = instOpts.EnvoyLogLevel
meshConfig.Spec.Sidecar.MaxDataPlaneConnections = 0
meshConfig.Spec.Sidecar.ConfigResyncInterval = "0s"

meshConfig.Spec.Certificate.ServiceCertValidityDuration = "24h"

return meshConfig
}

// InstallOSM installs OSM. The behavior of this function is dependant on
// installType and instOpts
func (td *OsmTestData) InstallOSM(instOpts InstallOSMOpts) error {
Expand All @@ -562,21 +581,12 @@ func (td *OsmTestData) InstallOSM(instOpts InstallOSMOpts) error {

meshConfig, _ := Td.GetMeshConfig(Td.OsmNamespace)

// This resets supported dynamic configs expected by the caller
meshConfig.Spec.Traffic.EnableEgress = instOpts.EgressEnabled
meshConfig, err := Td.UpdateOSMConfig(meshConfig)
if err != nil {
return err
}
meshConfig.Spec.Traffic.EnablePermissiveTrafficPolicyMode = instOpts.EnablePermissiveMode
meshConfig, err = Td.UpdateOSMConfig(meshConfig)
if err != nil {
return err
}
meshConfig.Spec.Observability.EnableDebugServer = instOpts.EnableDebugServer
if _, err = Td.UpdateOSMConfig(meshConfig); err != nil {
meshConfig = setMeshConfigToDefault(instOpts, meshConfig)

if _, err := Td.UpdateOSMConfig(meshConfig); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit e13f4c7

Please sign in to comment.