Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
38c4cdff
Commit
38c4cdff
authored
Aug 04, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #773 from smarterclayton/speed_up_proxy_tests
Remove 8 seconds of unnecessary sleeps from proxy tests
parents
f36d2a7e
0c33ed09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
15 deletions
+23
-15
etcd.go
pkg/proxy/config/etcd.go
+3
-1
proxier_test.go
pkg/proxy/proxier_test.go
+20
-14
No files found.
pkg/proxy/config/etcd.go
View file @
38c4cdff
...
...
@@ -51,6 +51,7 @@ type ConfigSourceEtcd struct {
client
*
etcd
.
Client
serviceChannel
chan
ServiceUpdate
endpointsChannel
chan
EndpointsUpdate
interval
time
.
Duration
}
// NewConfigSourceEtcd creates a new ConfigSourceEtcd and immediately runs the created ConfigSourceEtcd in a goroutine.
...
...
@@ -59,6 +60,7 @@ func NewConfigSourceEtcd(client *etcd.Client, serviceChannel chan ServiceUpdate,
client
:
client
,
serviceChannel
:
serviceChannel
,
endpointsChannel
:
endpointsChannel
,
interval
:
2
*
time
.
Second
,
}
go
config
.
Run
()
return
config
...
...
@@ -76,7 +78,7 @@ func (s ConfigSourceEtcd) Run() {
break
}
glog
.
Errorf
(
"Failed to get any services: %v"
,
err
)
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
s
.
interval
)
}
if
len
(
services
)
>
0
{
...
...
pkg/proxy/proxier_test.go
View file @
38c4cdff
...
...
@@ -27,6 +27,17 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
)
func
waitForClosedPort
(
p
*
Proxier
,
proxyPort
string
)
error
{
for
i
:=
0
;
i
<
50
;
i
++
{
_
,
err
:=
net
.
Dial
(
"tcp"
,
net
.
JoinHostPort
(
"127.0.0.1"
,
proxyPort
))
if
err
!=
nil
{
return
nil
}
time
.
Sleep
(
1
*
time
.
Millisecond
)
}
return
fmt
.
Errorf
(
"port %s still open"
,
proxyPort
)
}
// a simple echoServer that only accepts one connection. Returns port actually
// being listened on, or an error.
func
echoServer
(
t
*
testing
.
T
,
addr
string
)
(
string
,
error
)
{
...
...
@@ -107,10 +118,8 @@ func TestProxyStop(t *testing.T) {
p
.
StopProxy
(
"echo"
)
// Wait for the port to really close.
time
.
Sleep
(
2
*
time
.
Second
)
_
,
err
=
net
.
Dial
(
"tcp"
,
net
.
JoinHostPort
(
"127.0.0.1"
,
proxyPort
))
if
err
==
nil
{
t
.
Fatalf
(
"Unexpected non-error."
)
if
err
:=
waitForClosedPort
(
p
,
proxyPort
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
}
}
...
...
@@ -136,11 +145,8 @@ func TestProxyUpdateDelete(t *testing.T) {
conn
.
Close
()
p
.
OnUpdate
([]
api
.
Service
{})
// Wait for the port to close.
time
.
Sleep
(
2
*
time
.
Second
)
_
,
err
=
net
.
Dial
(
"tcp"
,
net
.
JoinHostPort
(
"127.0.0.1"
,
proxyPort
))
if
err
==
nil
{
t
.
Fatalf
(
"Unexpected non-error."
)
if
err
:=
waitForClosedPort
(
p
,
proxyPort
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
}
}
...
...
@@ -167,14 +173,14 @@ func TestProxyUpdatePort(t *testing.T) {
l
.
Close
()
// Wait for the socket to actually get free.
time
.
Sleep
(
2
*
time
.
Second
)
if
err
:=
waitForClosedPort
(
p
,
port
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
}
p
.
OnUpdate
([]
api
.
Service
{
{
JSONBase
:
api
.
JSONBase
{
ID
:
"echo"
},
Port
:
portNum
},
})
time
.
Sleep
(
2
*
time
.
Second
)
_
,
err
=
net
.
Dial
(
"tcp"
,
net
.
JoinHostPort
(
"127.0.0.1"
,
proxyPort
))
if
err
==
nil
{
t
.
Fatalf
(
"Unexpected non-error."
)
if
err
:=
waitForClosedPort
(
p
,
proxyPort
);
err
!=
nil
{
t
.
Fatalf
(
err
.
Error
())
}
testEchoConnection
(
t
,
"127.0.0.1"
,
port
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment