-
Notifications
You must be signed in to change notification settings - Fork 432
/
istio_integration_deployer_suite.go
62 lines (49 loc) · 2.31 KB
/
istio_integration_deployer_suite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package deployer
import (
"context"
"time"
"github.com/onsi/gomega"
"github.com/stretchr/testify/suite"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/solo-io/gloo/projects/gloo/cli/pkg/cmd/istio"
"github.com/solo-io/gloo/test/gomega/matchers"
"github.com/solo-io/gloo/test/kubernetes/e2e"
)
// istioIntegrationDeployerSuite is the entire Suite of tests for the "deployer" feature that relies on an Istio installation
// The "deployer" code can be found here: /projects/gateway2/deployer
type istioIntegrationDeployerSuite struct {
suite.Suite
ctx context.Context
// testInstallation contains all the metadata/utilities necessary to execute a series of tests
// against an installation of Gloo Gateway
testInstallation *e2e.TestInstallation
}
func NewIstioIntegrationTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &istioIntegrationDeployerSuite{
ctx: ctx,
testInstallation: testInst,
}
}
func (s *istioIntegrationDeployerSuite) TestConfigureIstioIntegrationFromGatewayParameters() {
s.T().Cleanup(func() {
err := s.testInstallation.Actions.Kubectl().DeleteFile(s.ctx, istioGatewayParametersManifestFile)
s.NoError(err, "can delete manifest")
s.testInstallation.Assertions.EventuallyObjectsNotExist(s.ctx, gwParams)
err = s.testInstallation.Actions.Kubectl().DeleteFileSafe(s.ctx, deployerProvisionManifestFile)
s.NoError(err, "can delete manifest")
s.testInstallation.Assertions.EventuallyObjectsNotExist(s.ctx, proxyService, proxyDeployment)
})
err := s.testInstallation.Actions.Kubectl().ApplyFile(s.ctx, istioGatewayParametersManifestFile)
s.Require().NoError(err, "can apply manifest")
s.testInstallation.Assertions.EventuallyObjectsExist(s.ctx, proxyService, proxyDeployment)
s.testInstallation.Assertions.EventuallyObjectsExist(s.ctx, gwParams)
// Assert Istio integration is enabled and correct Istio image is set
listOpts := metav1.ListOptions{
LabelSelector: "app.kubernetes.io/name=gloo-proxy-gw",
}
matcher := gomega.And(
matchers.PodMatches(matchers.ExpectedPod{ContainerName: istio.SDSContainerName}),
matchers.PodMatches(matchers.ExpectedPod{ContainerName: istio.IstioProxyName}),
)
s.testInstallation.Assertions.EventuallyPodsMatches(s.ctx, proxyDeployment.ObjectMeta.GetNamespace(), listOpts, matcher, time.Minute*2)
}