2015-01-13 02:11:27 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors.
|
2015-01-13 02:11:27 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-07-11 06:44:46 +00:00
|
|
|
package network
|
2015-01-13 02:11:27 +00:00
|
|
|
|
|
|
|
import (
|
2015-02-06 13:53:41 +00:00
|
|
|
"fmt"
|
2015-10-14 07:03:39 +00:00
|
|
|
"net/http"
|
|
|
|
|
2017-01-11 14:09:48 +00:00
|
|
|
"k8s.io/apimachinery/pkg/util/sets"
|
2017-05-05 21:44:25 +00:00
|
|
|
"k8s.io/kubernetes/pkg/master/ports"
|
2016-04-07 17:21:31 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2017-05-05 21:44:25 +00:00
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo"
|
2015-10-14 07:03:39 +00:00
|
|
|
)
|
2015-10-05 21:06:33 +00:00
|
|
|
|
2017-07-24 09:43:54 +00:00
|
|
|
var _ = SIGDescribe("Networking", func() {
|
2015-10-14 07:03:39 +00:00
|
|
|
var svcname = "nettest"
|
2016-08-25 01:08:12 +00:00
|
|
|
f := framework.NewDefaultFramework(svcname)
|
2015-10-14 07:03:39 +00:00
|
|
|
|
2015-05-28 00:52:15 +00:00
|
|
|
BeforeEach(func() {
|
2016-08-25 01:08:12 +00:00
|
|
|
// Assert basic external connectivity.
|
|
|
|
// Since this is not really a test of kubernetes in any way, we
|
|
|
|
// leave it as a pre-test assertion, rather than a Ginko test.
|
2015-05-28 00:52:15 +00:00
|
|
|
By("Executing a successful http request from the external internet")
|
|
|
|
resp, err := http.Get("http://google.com")
|
|
|
|
if err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Failf("Unable to connect/talk to the internet: %v", err)
|
2015-05-28 00:52:15 +00:00
|
|
|
}
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Failf("Unexpected error code, expected 200, got, %v (%v)", resp.StatusCode, resp)
|
2015-05-28 00:52:15 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-10-03 14:46:27 +00:00
|
|
|
It("should provide Internet connection for containers [Feature:Networking-IPv4]", func() {
|
2017-03-28 00:18:55 +00:00
|
|
|
By("Running container which tries to ping 8.8.8.8")
|
|
|
|
framework.ExpectNoError(
|
2017-10-03 14:46:27 +00:00
|
|
|
framework.CheckConnectivityToHost(f, "", "ping-test", "8.8.8.8", framework.IPv4PingCommand, 30))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should provide Internet connection for containers [Feature:Networking-IPv6][Experimental]", func() {
|
|
|
|
By("Running container which tries to ping google.com")
|
|
|
|
framework.ExpectNoError(
|
|
|
|
framework.CheckConnectivityToHost(f, "", "ping-test", "google.com", framework.IPv6PingCommand, 30))
|
2015-06-24 12:30:45 +00:00
|
|
|
})
|
|
|
|
|
2015-05-28 00:52:15 +00:00
|
|
|
// First test because it has no dependencies on variables created later on.
|
2016-10-05 20:13:59 +00:00
|
|
|
It("should provide unchanging, static URL paths for kubernetes api services", func() {
|
2015-05-28 00:52:15 +00:00
|
|
|
tests := []struct {
|
|
|
|
path string
|
|
|
|
}{
|
|
|
|
{path: "/healthz"},
|
2016-08-22 02:00:07 +00:00
|
|
|
{path: "/api"},
|
|
|
|
{path: "/apis"},
|
|
|
|
{path: "/metrics"},
|
|
|
|
{path: "/swaggerapi"},
|
|
|
|
{path: "/version"},
|
2015-05-28 00:52:15 +00:00
|
|
|
// TODO: test proxy links here
|
|
|
|
}
|
2017-10-05 21:26:24 +00:00
|
|
|
if !framework.ProviderIs("gke", "skeleton") {
|
2017-06-14 00:31:16 +00:00
|
|
|
tests = append(tests, struct{ path string }{path: "/logs"})
|
|
|
|
}
|
2015-05-28 00:52:15 +00:00
|
|
|
for _, test := range tests {
|
|
|
|
By(fmt.Sprintf("testing: %s", test.path))
|
2016-10-18 13:00:38 +00:00
|
|
|
data, err := f.ClientSet.Core().RESTClient().Get().
|
2015-05-28 00:52:15 +00:00
|
|
|
AbsPath(test.path).
|
|
|
|
DoRaw()
|
|
|
|
if err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Failf("Failed: %v\nBody: %s", err, string(data))
|
2015-05-28 00:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should check kube-proxy urls", func() {
|
|
|
|
// TODO: this is overkill we just need the host networking pod
|
|
|
|
// to hit kube-proxy urls.
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
2016-08-25 01:08:12 +00:00
|
|
|
|
|
|
|
By("checking kube-proxy URLs")
|
2017-05-05 21:44:25 +00:00
|
|
|
config.GetSelfURL(ports.ProxyHealthzPort, "/healthz", "200 OK")
|
2017-07-20 06:21:28 +00:00
|
|
|
// Verify /healthz returns the proper content.
|
|
|
|
config.GetSelfURL(ports.ProxyHealthzPort, "/healthz", "lastUpdated")
|
2017-06-02 02:51:55 +00:00
|
|
|
// Verify /proxyMode returns http status code 200.
|
|
|
|
config.GetSelfURLStatusCode(ports.ProxyStatusPort, "/proxyMode", "200")
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
// TODO: Remove [Slow] when this has had enough bake time to prove presubmit worthiness.
|
2017-08-21 18:17:02 +00:00
|
|
|
Describe("Granular Checks: Services [Slow]", func() {
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for pod-Service: http", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterHttpPort))
|
|
|
|
config.DialFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.ExternalAddrs[0], config.NodeHttpPort))
|
|
|
|
config.DialFromTestContainer("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-10-05 21:06:33 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for pod-Service: udp", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterUdpPort))
|
|
|
|
config.DialFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v --> %v:%v (nodeIP)", config.TestContainerPod.Name, config.ExternalAddrs[0], config.NodeUdpPort))
|
|
|
|
config.DialFromTestContainer("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for node-Service: http", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, framework.ClusterHttpPort))
|
|
|
|
config.DialFromNode("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeHttpPort))
|
|
|
|
config.DialFromNode("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-10-05 21:06:33 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for node-Service: udp", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (config.clusterIP)", config.NodeIP, config.ClusterIP, framework.ClusterUdpPort))
|
|
|
|
config.DialFromNode("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeUdpPort))
|
|
|
|
config.DialFromNode("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2016-04-14 21:27:10 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for endpoint-Service: http", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, framework.ClusterHttpPort))
|
|
|
|
config.DialFromEndpointContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, config.NodeHttpPort))
|
|
|
|
config.DialFromEndpointContainer("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should function for endpoint-Service: udp", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(udp) %v (endpoint) --> %v:%v (config.clusterIP)", config.EndpointPods[0].Name, config.ClusterIP, framework.ClusterUdpPort))
|
|
|
|
config.DialFromEndpointContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v (endpoint) --> %v:%v (nodeIP)", config.EndpointPods[0].Name, config.NodeIP, config.NodeUdpPort))
|
|
|
|
config.DialFromEndpointContainer("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
})
|
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should update endpoints: http", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterHttpPort))
|
|
|
|
config.DialFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
config.DeleteNetProxyPod()
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-10 10:36:00 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterHttpPort))
|
|
|
|
config.DialFromTestContainer("http", config.ClusterIP, framework.ClusterHttpPort, config.MaxTries, config.MaxTries, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
It("should update endpoints: udp", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
|
|
|
By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterUdpPort))
|
|
|
|
config.DialFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
config.DeleteNetProxyPod()
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-10 10:36:00 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, framework.ClusterUdpPort))
|
|
|
|
config.DialFromTestContainer("udp", config.ClusterIP, framework.ClusterUdpPort, config.MaxTries, config.MaxTries, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling.
|
|
|
|
It("should update nodePort: http [Slow]", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeHttpPort))
|
|
|
|
config.DialFromNode("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
config.DeleteNodePortService()
|
2015-08-17 19:19:22 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(http) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeHttpPort))
|
|
|
|
config.DialFromNode("http", config.NodeIP, config.NodeHttpPort, config.MaxTries, config.MaxTries, sets.NewString())
|
2015-08-17 19:19:22 +00:00
|
|
|
})
|
2015-05-28 00:52:15 +00:00
|
|
|
|
2016-08-25 01:08:12 +00:00
|
|
|
// Slow because we confirm that the nodePort doesn't serve traffic, which requires a period of polling.
|
|
|
|
It("should update nodePort: udp [Slow]", func() {
|
2016-10-10 10:36:00 +00:00
|
|
|
config := framework.NewNetworkingTestConfig(f)
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeUdpPort))
|
|
|
|
config.DialFromNode("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, 0, config.EndpointHostnames())
|
2016-08-25 01:08:12 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
config.DeleteNodePortService()
|
2016-08-25 01:08:12 +00:00
|
|
|
|
2016-10-04 21:06:25 +00:00
|
|
|
By(fmt.Sprintf("dialing(udp) %v (node) --> %v:%v (nodeIP)", config.NodeIP, config.NodeIP, config.NodeUdpPort))
|
|
|
|
config.DialFromNode("udp", config.NodeIP, config.NodeUdpPort, config.MaxTries, config.MaxTries, sets.NewString())
|
2015-04-02 02:32:21 +00:00
|
|
|
})
|
2016-08-25 01:08:12 +00:00
|
|
|
// TODO: Test sessionAffinity #31712
|
|
|
|
})
|
|
|
|
})
|