mirror of https://github.com/k3s-io/k3s
Merge pull request #59299 from hanxiaoshuai/fixtodo0203
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix todo: use the ServiceTestJig replace of service in e2e/network/service.go **What this PR does / why we need it**: fix todo: use the ServiceTestJig replace of service in e2e/network/service.go **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/8/head
commit
122122c7fa
|
@ -211,6 +211,20 @@ func (j *ServiceTestJig) CreateExternalNameServiceOrFail(namespace string, tweak
|
|||
return result
|
||||
}
|
||||
|
||||
// CreateServiceWithServicePort creates a new Service with ServicePort.
|
||||
func (j *ServiceTestJig) CreateServiceWithServicePort(labels map[string]string, namespace string, ports []v1.ServicePort) (*v1.Service, error) {
|
||||
service := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: j.Name,
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Ports: ports,
|
||||
},
|
||||
}
|
||||
return j.Client.CoreV1().Services(namespace).Create(service)
|
||||
}
|
||||
|
||||
func (j *ServiceTestJig) ChangeServiceType(namespace, name string, newType v1.ServiceType, timeout time.Duration) {
|
||||
ingressIP := ""
|
||||
svc := j.UpdateServiceOrFail(namespace, name, func(s *v1.Service) {
|
||||
|
|
|
@ -84,9 +84,9 @@ var _ = SIGDescribe("Services", func() {
|
|||
valid/accessible endpoints (same port number for service and pods).
|
||||
*/
|
||||
framework.ConformanceIt("should serve a basic endpoint from pods ", func() {
|
||||
// TODO: use the ServiceTestJig here
|
||||
serviceName := "endpoint-test2"
|
||||
ns := f.Namespace.Name
|
||||
jig := framework.NewServiceTestJig(cs, serviceName)
|
||||
labels := map[string]string{
|
||||
"foo": "bar",
|
||||
"baz": "blah",
|
||||
|
@ -97,20 +97,12 @@ var _ = SIGDescribe("Services", func() {
|
|||
err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}()
|
||||
ports := []v1.ServicePort{{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(80),
|
||||
}}
|
||||
_, err := jig.CreateServiceWithServicePort(labels, ns, ports)
|
||||
|
||||
service := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: serviceName,
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Ports: []v1.ServicePort{{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(80),
|
||||
}},
|
||||
},
|
||||
}
|
||||
_, err := cs.CoreV1().Services(ns).Create(service)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
framework.ValidateEndpointsOrFail(cs, ns, serviceName, framework.PortsByPodName{})
|
||||
|
@ -149,10 +141,10 @@ var _ = SIGDescribe("Services", func() {
|
|||
valid/accessible endpoints (different port number for pods).
|
||||
*/
|
||||
framework.ConformanceIt("should serve multiport endpoints from pods ", func() {
|
||||
// TODO: use the ServiceTestJig here
|
||||
// repacking functionality is intentionally not tested here - it's better to test it in an integration test.
|
||||
serviceName := "multi-endpoint-test"
|
||||
ns := f.Namespace.Name
|
||||
jig := framework.NewServiceTestJig(cs, serviceName)
|
||||
|
||||
defer func() {
|
||||
err := cs.CoreV1().Services(ns).Delete(serviceName, nil)
|
||||
|
@ -165,27 +157,19 @@ var _ = SIGDescribe("Services", func() {
|
|||
svc2port := "svc2"
|
||||
|
||||
By("creating service " + serviceName + " in namespace " + ns)
|
||||
service := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: serviceName,
|
||||
ports := []v1.ServicePort{
|
||||
{
|
||||
Name: "portname1",
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString(svc1port),
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: "portname1",
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString(svc1port),
|
||||
},
|
||||
{
|
||||
Name: "portname2",
|
||||
Port: 81,
|
||||
TargetPort: intstr.FromString(svc2port),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "portname2",
|
||||
Port: 81,
|
||||
TargetPort: intstr.FromString(svc2port),
|
||||
},
|
||||
}
|
||||
_, err := cs.CoreV1().Services(ns).Create(service)
|
||||
_, err := jig.CreateServiceWithServicePort(labels, ns, ports)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
port1 := 100
|
||||
port2 := 101
|
||||
|
|
Loading…
Reference in New Issue