fix some golint failures of e2e/network/[d-k]*.go

This commit is contained in:
SataQiu 2019-04-08 18:27:08 +08:00
parent f873d2a056
commit 36bc97cbb8
6 changed files with 39 additions and 41 deletions

View File

@ -53,7 +53,7 @@ type dnsTestCommon struct {
cm *v1.ConfigMap
}
func newDnsTestCommon() dnsTestCommon {
func newDNSTestCommon() dnsTestCommon {
return dnsTestCommon{
f: framework.NewDefaultFramework("dns-config-map"),
ns: "kube-system",
@ -137,9 +137,8 @@ func (t *dnsTestCommon) runDig(dnsName, target string) []string {
if stdout == "" {
return []string{}
} else {
return strings.Split(stdout, "\n")
}
return strings.Split(stdout, "\n")
}
func (t *dnsTestCommon) setConfigMap(cm *v1.ConfigMap) {

View File

@ -35,7 +35,7 @@ type dnsFederationsConfigMapTest struct {
}
var (
googleDnsHostname = "google-public-dns-a.google.com"
googleDNSHostname = "google-public-dns-a.google.com"
// The ConfigMap update mechanism takes longer than the standard
// wait.ForeverTestTimeout.
moreForeverTestTimeout = 2 * 60 * time.Second
@ -43,7 +43,7 @@ var (
var _ = SIGDescribe("DNS configMap federations [Feature:Federation]", func() {
t := &dnsFederationsConfigMapTest{dnsTestCommon: newDnsTestCommon()}
t := &dnsFederationsConfigMapTest{dnsTestCommon: newDNSTestCommon()}
It("should be able to change federation configuration [Slow][Serial]", func() {
t.c = t.f.ClientSet
@ -314,13 +314,13 @@ func (t *dnsPtrFwdTest) run(isIPv6 bool) {
if isIPv6 {
t.checkDNSRecordFrom(
"2001:4860:4860::8888",
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDNSHostname+"." },
"ptr-record",
moreForeverTestTimeout)
} else {
t.checkDNSRecordFrom(
"8.8.8.8",
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDnsHostname+"." },
func(actual []string) bool { return len(actual) == 1 && actual[0] == googleDNSHostname+"." },
"ptr-record",
moreForeverTestTimeout)
}
@ -401,7 +401,7 @@ func (t *dnsExternalNameTest) run(isIPv6 bool) {
f := t.f
serviceName := "dns-externalname-upstream-test"
externalNameService := framework.CreateServiceSpec(serviceName, googleDnsHostname, false, nil)
externalNameService := framework.CreateServiceSpec(serviceName, googleDNSHostname, false, nil)
if _, err := f.ClientSet.CoreV1().Services(f.Namespace.Name).Create(externalNameService); err != nil {
Fail(fmt.Sprintf("Failed when creating service: %v", err))
}
@ -421,7 +421,7 @@ func (t *dnsExternalNameTest) run(isIPv6 bool) {
t.checkDNSRecordFrom(
fmt.Sprintf("%s.%s.svc.%s", serviceName, f.Namespace.Name, framework.TestContext.ClusterDNSDomain),
func(actual []string) bool {
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
return len(actual) >= 1 && actual[0] == googleDNSHostname+"."
},
"cluster-dns-ipv6",
moreForeverTestTimeout)
@ -429,7 +429,7 @@ func (t *dnsExternalNameTest) run(isIPv6 bool) {
t.checkDNSRecordFrom(
fmt.Sprintf("%s.%s.svc.%s", serviceName, f.Namespace.Name, framework.TestContext.ClusterDNSDomain),
func(actual []string) bool {
return len(actual) >= 1 && actual[0] == googleDnsHostname+"."
return len(actual) >= 1 && actual[0] == googleDNSHostname+"."
},
"cluster-dns",
moreForeverTestTimeout)
@ -478,7 +478,7 @@ func (t *dnsExternalNameTest) run(isIPv6 bool) {
var _ = SIGDescribe("DNS configMap nameserver [IPv4]", func() {
Context("Change stubDomain", func() {
nsTest := &dnsNameserverTest{dnsTestCommon: newDnsTestCommon()}
nsTest := &dnsNameserverTest{dnsTestCommon: newDNSTestCommon()}
It("should be able to change stubDomain configuration [Slow][Serial]", func() {
nsTest.c = nsTest.f.ClientSet
@ -487,7 +487,7 @@ var _ = SIGDescribe("DNS configMap nameserver [IPv4]", func() {
})
Context("Forward PTR lookup", func() {
fwdTest := &dnsPtrFwdTest{dnsTestCommon: newDnsTestCommon()}
fwdTest := &dnsPtrFwdTest{dnsTestCommon: newDNSTestCommon()}
It("should forward PTR records lookup to upstream nameserver [Slow][Serial]", func() {
fwdTest.c = fwdTest.f.ClientSet
@ -496,7 +496,7 @@ var _ = SIGDescribe("DNS configMap nameserver [IPv4]", func() {
})
Context("Forward external name lookup", func() {
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDnsTestCommon()}
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDNSTestCommon()}
It("should forward externalname lookup to upstream nameserver [Slow][Serial]", func() {
externalNameTest.c = externalNameTest.f.ClientSet
@ -508,7 +508,7 @@ var _ = SIGDescribe("DNS configMap nameserver [IPv4]", func() {
var _ = SIGDescribe("DNS configMap nameserver [Feature:Networking-IPv6]", func() {
Context("Change stubDomain", func() {
nsTest := &dnsNameserverTest{dnsTestCommon: newDnsTestCommon()}
nsTest := &dnsNameserverTest{dnsTestCommon: newDNSTestCommon()}
It("should be able to change stubDomain configuration [Slow][Serial]", func() {
nsTest.c = nsTest.f.ClientSet
@ -517,7 +517,7 @@ var _ = SIGDescribe("DNS configMap nameserver [Feature:Networking-IPv6]", func()
})
Context("Forward PTR lookup", func() {
fwdTest := &dnsPtrFwdTest{dnsTestCommon: newDnsTestCommon()}
fwdTest := &dnsPtrFwdTest{dnsTestCommon: newDNSTestCommon()}
It("should forward PTR records lookup to upstream nameserver [Slow][Serial]", func() {
fwdTest.c = fwdTest.f.ClientSet
@ -526,7 +526,7 @@ var _ = SIGDescribe("DNS configMap nameserver [Feature:Networking-IPv6]", func()
})
Context("Forward external name lookup", func() {
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDnsTestCommon()}
externalNameTest := &dnsExternalNameTest{dnsTestCommon: newDNSTestCommon()}
It("should forward externalname lookup to upstream nameserver [Slow][Serial]", func() {
externalNameTest.c = externalNameTest.f.ClientSet

View File

@ -39,7 +39,7 @@ const (
dnsReadyTimeout = time.Minute
)
const queryDnsPythonTemplate string = `
const queryDNSPythonTemplate string = `
import socket
try:
socket.gethostbyname('%s')
@ -131,8 +131,8 @@ var _ = SIGDescribe("ClusterDns [Feature:Example]", func() {
}
podName := pods.Items[0].Name
queryDns := fmt.Sprintf(queryDnsPythonTemplate, backendSvcName+"."+namespaces[0].Name)
_, err = framework.LookForStringInPodExec(namespaces[0].Name, podName, []string{"python", "-c", queryDns}, "ok", dnsReadyTimeout)
queryDNS := fmt.Sprintf(queryDNSPythonTemplate, backendSvcName+"."+namespaces[0].Name)
_, err = framework.LookForStringInPodExec(namespaces[0].Name, podName, []string{"python", "-c", queryDNS}, "ok", dnsReadyTimeout)
Expect(err).NotTo(HaveOccurred(), "waiting for output from pod exec")
updatedPodYaml := prepareResourceWithReplacedString(frontendPodYaml, fmt.Sprintf("dns-backend.development.svc.%s", framework.TestContext.ClusterDNSDomain), fmt.Sprintf("dns-backend.%s.svc.%s", namespaces[0].Name, framework.TestContext.ClusterDNSDomain))

View File

@ -41,8 +41,8 @@ const (
)
var _ = SIGDescribe("Firewall rule", func() {
var firewall_test_name = "firewall-test"
f := framework.NewDefaultFramework(firewall_test_name)
var firewallTestName = "firewall-test"
f := framework.NewDefaultFramework(firewallTestName)
var cs clientset.Interface
var cloudConfig framework.CloudConfig

View File

@ -489,10 +489,9 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
if int(deploy.Status.UpdatedReplicas) == replicas {
if res.Len() == replicas {
return true, nil
} else {
framework.Logf("Expecting %d different responses, but got %d.", replicas, res.Len())
return false, nil
}
framework.Logf("Expecting %d different responses, but got %d.", replicas, res.Len())
return false, nil
} else {
framework.Logf("Waiting for rolling update to finished. Keep sending traffic.")
@ -928,7 +927,7 @@ func executeBacksideBacksideHTTPSTest(f *framework.Framework, jig *ingress.TestJ
Expect(err).NotTo(HaveOccurred(), "Failed to verify backside re-encryption ingress")
}
func detectHttpVersionAndSchemeTest(f *framework.Framework, jig *ingress.TestJig, address, version, scheme string) {
func detectHTTPVersionAndSchemeTest(f *framework.Framework, jig *ingress.TestJig, address, version, scheme string) {
timeoutClient := &http.Client{Timeout: ingress.IngressReqTimeout}
resp := ""
err := wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {

View File

@ -39,8 +39,8 @@ var kubeProxyE2eImage = imageutils.GetE2EImage(imageutils.Net)
var _ = SIGDescribe("Network", func() {
const (
testDaemonHttpPort = 11301
testDaemonTcpPort = 11302
testDaemonHTTPPort = 11301
testDaemonTCPPort = 11302
timeoutSeconds = 10
postFinTimeoutSeconds = 5
)
@ -60,19 +60,19 @@ var _ = SIGDescribe("Network", func() {
type NodeInfo struct {
node *v1.Node
name string
nodeIp string
nodeIP string
}
clientNodeInfo := NodeInfo{
node: &nodes.Items[0],
name: nodes.Items[0].Name,
nodeIp: ips[0],
nodeIP: ips[0],
}
serverNodeInfo := NodeInfo{
node: &nodes.Items[1],
name: nodes.Items[1].Name,
nodeIp: ips[1],
nodeIP: ips[1],
}
zero := int64(0)
@ -101,7 +101,7 @@ var _ = SIGDescribe("Network", func() {
Image: kubeProxyE2eImage,
ImagePullPolicy: "Always",
Command: []string{
"/net", "-serve", fmt.Sprintf("0.0.0.0:%d", testDaemonHttpPort),
"/net", "-serve", fmt.Sprintf("0.0.0.0:%d", testDaemonHTTPPort),
},
},
},
@ -127,14 +127,14 @@ var _ = SIGDescribe("Network", func() {
"-runner", "nat-closewait-server",
"-options",
fmt.Sprintf(`{"LocalAddr":"0.0.0.0:%v", "PostFindTimeoutSeconds":%v}`,
testDaemonTcpPort,
testDaemonTCPPort,
postFinTimeoutSeconds),
},
Ports: []v1.ContainerPort{
{
Name: "tcp",
ContainerPort: testDaemonTcpPort,
HostPort: testDaemonTcpPort,
ContainerPort: testDaemonTCPPort,
HostPort: testDaemonTCPPort,
},
},
},
@ -146,14 +146,14 @@ var _ = SIGDescribe("Network", func() {
By(fmt.Sprintf(
"Launching a server daemon on node %v (node ip: %v, image: %v)",
serverNodeInfo.name,
serverNodeInfo.nodeIp,
serverNodeInfo.nodeIP,
kubeProxyE2eImage))
fr.PodClient().CreateSync(serverPodSpec)
By(fmt.Sprintf(
"Launching a client daemon on node %v (node ip: %v, image: %v)",
clientNodeInfo.name,
clientNodeInfo.nodeIp,
clientNodeInfo.nodeIP,
kubeProxyE2eImage))
fr.PodClient().CreateSync(clientPodSpec)
@ -161,7 +161,7 @@ var _ = SIGDescribe("Network", func() {
options := nat.CloseWaitClientOptions{
RemoteAddr: fmt.Sprintf("%v:%v",
serverNodeInfo.nodeIp, testDaemonTcpPort),
serverNodeInfo.nodeIP, testDaemonTCPPort),
TimeoutSeconds: timeoutSeconds,
PostFinTimeoutSeconds: 0,
LeakConnection: true,
@ -171,7 +171,7 @@ var _ = SIGDescribe("Network", func() {
cmd := fmt.Sprintf(
`curl -X POST http://localhost:%v/run/nat-closewait-client -d `+
`'%v' 2>/dev/null`,
testDaemonHttpPort,
testDaemonHTTPPort,
string(jsonBytes))
framework.RunHostCmdOrDie(fr.Namespace.Name, "e2e-net-client", cmd)
@ -182,7 +182,7 @@ var _ = SIGDescribe("Network", func() {
// in a loop as there may be a race with the client connecting.
framework.IssueSSHCommandWithResult(
fmt.Sprintf("sudo cat /proc/net/nf_conntrack | grep 'dport=%v'",
testDaemonTcpPort),
testDaemonTCPPort),
framework.TestContext.Provider,
clientNodeInfo.node)
@ -194,8 +194,8 @@ var _ = SIGDescribe("Network", func() {
"| grep 'CLOSE_WAIT.*dst=%v.*dport=%v' "+
"| tail -n 1"+
"| awk '{print $5}' ",
serverNodeInfo.nodeIp,
testDaemonTcpPort),
serverNodeInfo.nodeIP,
testDaemonTCPPort),
framework.TestContext.Provider,
clientNodeInfo.node)
framework.ExpectNoError(err)