Skip to content

Commit 51659da

Browse files
author
Jianfei Hu
committed
wip for adding test.
1 parent ab1af63 commit 51659da

File tree

4 files changed

+68
-10
lines changed

4 files changed

+68
-10
lines changed

pkg/test/framework/components/apps/kube/apps.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ var (
127127
headless: true,
128128
serviceAccount: true,
129129
},
130+
// TODO(incfly): ideally the test should declare the deployments content and associate it with
131+
// meaningful names for maintaience reason.
132+
{
133+
deployment: "http-probe-rewrite",
134+
service: "http-probe-rewrite",
135+
version: "unversioned",
136+
port1: 80,
137+
port2: 8080,
138+
port3: 90,
139+
port4: 9090,
140+
port5: 70,
141+
port6: 7070,
142+
injectProxy: false,
143+
kubeInject: true,
144+
serviceAccount: true,
145+
},
130146
}
131147
)
132148

@@ -154,7 +170,9 @@ func (c *kubeComponent) Init(ctx environment.ComponentContext, deps map[dependen
154170

155171
// Apply all the configs for the deployments.
156172
for _, d := range deployments {
173+
fmt.Println("jianfeih debug the deployment is ", d.deployment)
157174
if err := d.apply(e); err != nil {
175+
fmt.Printf("jianfeih debug the error occurred %v\n", err)
158176
return nil, multierror.Prefix(err, fmt.Sprintf("failed deploying %s: ", d.deployment))
159177
}
160178
}

pkg/test/framework/components/apps/kube/deployment.go

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ package kube
1616

1717
import (
1818
"fmt"
19+
"io/ioutil"
20+
"path"
1921
"strconv"
2022

2123
kubeApiCore "k8s.io/api/core/v1"
2224

2325
"istio.io/istio/pkg/test/framework/environments/kubernetes"
2426
"istio.io/istio/pkg/test/framework/tmpl"
27+
"istio.io/istio/tests/e2e/framework"
2528
)
2629

2730
const (
@@ -142,16 +145,19 @@ spec:
142145
)
143146

144147
type deployment struct {
145-
deployment string
146-
service string
147-
version string
148-
port1 int
149-
port2 int
150-
port3 int
151-
port4 int
152-
port5 int
153-
port6 int
154-
injectProxy bool
148+
deployment string
149+
service string
150+
version string
151+
port1 int
152+
port2 int
153+
port3 int
154+
port4 int
155+
port5 int
156+
port6 int
157+
injectProxy bool
158+
// by default deployment uses webhook auto inject. If `kubeInject` is true
159+
// we run `istioctl kubeinject` for injection. `injectProxy` has to be false.
160+
kubeInject bool
155161
headless bool
156162
serviceAccount bool
157163
}
@@ -181,6 +187,31 @@ func (d *deployment) apply(e *kubernetes.Implementation) error {
181187
return err
182188
}
183189

190+
// If `kubeInject` is turned on, run `istioctl kube-inject` instead.
191+
if d.kubeInject {
192+
tmpdir, _ := ioutil.TempDir("", "kubeinject")
193+
if d.injectProxy {
194+
return fmt.Errorf("%v: injectProxy has to be off while kubeInject is enabled", d.deployment)
195+
}
196+
197+
ictl, err := framework.NewIstioctl(tmpdir, kubernetes.DefaultIstioSystemNamespace,
198+
s.Values[kubernetes.HubValuesKey], s.Values[kubernetes.TagValuesKey], s.Values[kubernetes.ImagePullPolicyValuesKey], "", s.KubeConfig)
199+
if err != nil {
200+
return fmt.Errorf("failed to create istioctl instance %v", err)
201+
}
202+
src := path.Join(tmpdir, "src.yaml")
203+
if err := ioutil.WriteFile(src, []byte(result), 0644); err != nil {
204+
return fmt.Errorf("failed to dump file into file %v", err)
205+
}
206+
dest := path.Join(tmpdir, "destination.yaml")
207+
if err = ictl.KubeInject(src, dest, s.KubeConfig); err != nil {
208+
return fmt.Errorf("failed in kube-inject %v", err)
209+
}
210+
if err := e.Accessor.Apply(s.DependencyNamespace, dest); err != nil {
211+
return err
212+
}
213+
}
214+
184215
if err = e.Accessor.ApplyContents(s.DependencyNamespace, result); err != nil {
185216
return err
186217
}

pkg/test/framework/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (d *driver) Requires(t testing.TB, dependencies []dependency.Instance) {
162162
// Initialize dependencies only once.
163163
for _, dep := range dependencies {
164164
envID := d.context.Settings().Environment
165+
fmt.Println("jianfieh debug dependency ", dep, envID)
165166

166167
switch dep {
167168
case dependency.Local:

tests/integration2/examples/basic/basic_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package basic
1717

1818
import (
19+
"fmt"
1920
"testing"
2021

2122
"istio.io/istio/pkg/test/framework"
@@ -55,3 +56,10 @@ spec:
5556
// As an example, the following method calls the Report operation against Mixer's own API directly.
5657
m.Report(t, map[string]interface{}{})
5758
}
59+
60+
func TestProbeRewrite(t *testing.T) {
61+
framework.Requires(t, dependency.Apps)
62+
framework.Requires(t, dependency.Pilot)
63+
env := framework.AcquireEnvironment(t)
64+
fmt.Println("jianfeih debug env ", env)
65+
}

0 commit comments

Comments
 (0)