Skip to content

Commit 1892f47

Browse files
author
lec-bit
committed
update
Signed-off-by: lec-bit <glfhzmy@126.com>
1 parent ea9cb9d commit 1892f47

File tree

2 files changed

+97
-120
lines changed

2 files changed

+97
-120
lines changed

test/e2e/baseline_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,15 @@
2424
package kmesh
2525

2626
import (
27-
"context"
2827
"fmt"
2928
"net/http"
30-
"net/netip"
31-
"sort"
32-
"strings"
33-
"testing"
34-
"time"
3529

36-
"github.com/prometheus/common/model"
37-
"github.com/stretchr/testify/assert"
38-
"istio.io/api/label"
39-
"istio.io/api/networking/v1alpha3"
40-
"istio.io/istio/pkg/config/constants"
41-
"istio.io/istio/pkg/test"
4230
echot "istio.io/istio/pkg/test/echo"
4331
"istio.io/istio/pkg/test/echo/common/scheme"
4432
"istio.io/istio/pkg/test/framework"
45-
"istio.io/istio/pkg/test/framework/components/cluster"
4633
"istio.io/istio/pkg/test/framework/components/echo"
4734
"istio.io/istio/pkg/test/framework/components/echo/check"
48-
"istio.io/istio/pkg/test/framework/components/echo/common/ports"
49-
"istio.io/istio/pkg/test/framework/components/echo/config"
50-
"istio.io/istio/pkg/test/framework/components/echo/config/param"
51-
"istio.io/istio/pkg/test/framework/components/echo/echotest"
52-
"istio.io/istio/pkg/test/framework/components/echo/util/traffic"
53-
"istio.io/istio/pkg/test/framework/components/prometheus"
54-
testKube "istio.io/istio/pkg/test/kube"
55-
"istio.io/istio/pkg/test/shell"
56-
"istio.io/istio/pkg/test/util/retry"
5735
"istio.io/istio/pkg/util/sets"
58-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
59-
"k8s.io/apimachinery/pkg/types"
6036
)
6137

6238
func IsL7() echo.Checker {
@@ -113,4 +89,3 @@ func OriginalSourceCheck(t framework.TestContext, src echo.Instance) echo.Checke
11389
return nil
11490
})
11591
}
116-

test/e2e/main_test.go

Lines changed: 97 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,99 +17,101 @@
1717
* limitations under the License.
1818
*/
1919

20-
package kmesh
20+
package kmesh
2121

22-
import (
23-
"context"
24-
"testing"
25-
"time"
26-
27-
"istio.io/api/label"
28-
"istio.io/istio/pkg/config/protocol"
29-
"istio.io/istio/pkg/test"
30-
"istio.io/istio/pkg/test/framework"
31-
"istio.io/istio/pkg/test/framework/components/echo"
32-
"istio.io/istio/pkg/test/framework/components/namespace"
33-
"istio.io/istio/pkg/test/framework/resource"
34-
)
35-
36-
var (
37-
apps = &EchoDeployments{}
38-
)
39-
40-
type EchoDeployments struct {
41-
Namespace namespace.Instance
42-
All echo.Instances
43-
}
44-
45-
const (
46-
ServiceName = "echo-service"
47-
Timeout = 2 * time.Minute
48-
)
49-
50-
func TestMain(m *testing.M) {
51-
framework.
52-
NewSuite(m).
53-
Setup(func(t resource.Context) error {
54-
t.Settings().Ambient = true
55-
return nil
56-
}).
57-
Setup(func(t resource.Context) error {
58-
return SetupApps(t, apps)
59-
}).
60-
Run()
61-
}
62-
63-
func SetupApps(t resource.Context, apps *EchoDeployments) error {
64-
var err error
65-
apps.Namespace, err = namespace.New(t, namespace.Config{
66-
Prefix: "echo",
67-
Inject: true, // 启用自动注入
68-
Labels: map[string]string{
69-
label.IoIstioDataplaneMode.Name: "Kmesh",
70-
},
71-
})
72-
if err != nil {
73-
return err
74-
}
75-
76-
builder := echo.New(t).
77-
WithClusters(t.Clusters()...).
78-
WithConfig(echo.Config{
79-
Service: ServiceName,
80-
Namespace: apps.Namespace,
81-
Ports: echo.Ports{{
82-
Name: "http",
83-
Protocol: protocol.HTTP,
84-
Port: 8080,
85-
}},
86-
ServiceAccount: true,
87-
Subsets: []echo.SubsetConfig{
88-
{
89-
Replicas: 1,
90-
Version: "v1",
91-
Labels: map[string]string{
92-
"app": ServiceName,
93-
"version": "v1",
94-
},
95-
},
96-
{
97-
Replicas: 1,
98-
Version: "v2",
99-
Labels: map[string]string{
100-
"app": ServiceName,
101-
"version": "v2",
102-
},
103-
},
104-
},
105-
})
106-
107-
echos, err := builder.Build()
108-
if err != nil {
109-
return err
110-
}
111-
112-
apps.All = echos
113-
return nil
114-
}
115-
22+
import (
23+
"testing"
24+
"time"
25+
26+
"istio.io/api/label"
27+
"istio.io/istio/pkg/config/protocol"
28+
"istio.io/istio/pkg/test/framework"
29+
"istio.io/istio/pkg/test/framework/components/echo"
30+
"istio.io/istio/pkg/test/framework/components/namespace"
31+
"istio.io/istio/pkg/test/framework/resource"
32+
)
33+
34+
var (
35+
apps = &EchoDeployments{}
36+
)
37+
38+
type EchoDeployments struct {
39+
Namespace namespace.Instance
40+
All echo.Instances
41+
}
42+
43+
const (
44+
ServiceName = "echo-service"
45+
EnrolledToKmesh = "enrolled-to-kmesh"
46+
Timeout = 2 * time.Minute
47+
KmeshReleaseName = "kmesh"
48+
KmeshDaemonsetName = "kmesh"
49+
KmeshNamespace = "kmesh-system"
50+
DataplaneModeKmesh = "Kmesh"
51+
)
52+
53+
func TestMain(m *testing.M) {
54+
framework.
55+
NewSuite(m).
56+
Setup(func(t resource.Context) error {
57+
t.Settings().Ambient = true
58+
return nil
59+
}).
60+
Setup(func(t resource.Context) error {
61+
return SetupApps(t, apps)
62+
}).
63+
Run()
64+
}
65+
66+
func SetupApps(t resource.Context, apps *EchoDeployments) error {
67+
var err error
68+
apps.Namespace, err = namespace.New(t, namespace.Config{
69+
Prefix: "echo",
70+
Inject: false,
71+
Labels: map[string]string{
72+
label.IoIstioDataplaneMode.Name: DataplaneModeKmesh,
73+
},
74+
})
75+
if err != nil {
76+
return err
77+
}
78+
79+
builder := echo.New(t).
80+
WithClusters(t.Clusters()...).
81+
WithConfig(echo.Config{
82+
Service: ServiceName,
83+
Namespace: apps.Namespace,
84+
Ports: echo.Ports{{
85+
Name: "http",
86+
Protocol: protocol.HTTP,
87+
Port: 8080,
88+
}},
89+
ServiceAccount: true,
90+
Subsets: []echo.SubsetConfig{
91+
{
92+
Replicas: 1,
93+
Version: "v1",
94+
Labels: map[string]string{
95+
"app": ServiceName,
96+
"version": "v1",
97+
},
98+
},
99+
{
100+
Replicas: 1,
101+
Version: "v2",
102+
Labels: map[string]string{
103+
"app": ServiceName,
104+
"version": "v2",
105+
},
106+
},
107+
},
108+
})
109+
110+
echos, err := builder.Build()
111+
if err != nil {
112+
return err
113+
}
114+
115+
apps.All = echos
116+
return nil
117+
}

0 commit comments

Comments
 (0)