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
3e98919a
Commit
3e98919a
authored
May 29, 2015
by
Rohit Jnagal
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8857 from andronat/fix_TestGetEtcdVersion_NotListening
fix TestGetEtcdVersion_NotListening
parents
8d1481ab
bb9fb19c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
etcd_helper_test.go
pkg/tools/etcd_helper_test.go
+22
-1
No files found.
pkg/tools/etcd_helper_test.go
View file @
3e98919a
...
...
@@ -19,12 +19,16 @@ package tools
import
(
"errors"
"fmt"
"math/rand"
"net"
"net/http"
"net/http/httptest"
"path"
"reflect"
"strconv"
"sync"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
...
...
@@ -812,7 +816,24 @@ func TestGetEtcdVersion_ErrorStatus(t *testing.T) {
}
func
TestGetEtcdVersion_NotListening
(
t
*
testing
.
T
)
{
_
,
err
:=
GetEtcdVersion
(
"http://127.0.0.1:4001"
)
portIsOpen
:=
func
(
port
int
)
bool
{
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
"127.0.0.1:"
+
strconv
.
Itoa
(
port
),
1
*
time
.
Second
)
if
err
==
nil
{
conn
.
Close
()
return
true
}
return
false
}
port
:=
rand
.
Intn
((
1
<<
16
)
-
1
)
for
tried
:=
0
;
portIsOpen
(
port
);
tried
++
{
if
tried
>=
10
{
t
.
Fatal
(
"Couldn't find a closed TCP port to continue testing"
)
}
port
++
}
_
,
err
:=
GetEtcdVersion
(
"http://127.0.0.1:"
+
strconv
.
Itoa
(
port
))
assert
.
NotNil
(
t
,
err
)
}
...
...
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