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
c928fb06
Unverified
Commit
c928fb06
authored
Oct 05, 2023
by
Vitor Savian
Committed by
GitHub
Oct 05, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added advertise address integration test
Signed-off-by:
Vitor Savian
<
vitor.savian@suse.com
>
parent
e7e7615d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
4 deletions
+39
-4
integration.go
tests/integration/integration.go
+21
-0
startup_int_test.go
tests/integration/startup/startup_int_test.go
+18
-4
No files found.
tests/integration/integration.go
View file @
c928fb06
...
...
@@ -359,6 +359,27 @@ func K3sSaveLog(server *K3sServer, dump bool) error {
return
nil
}
func
GetEndpointsAddresses
()
(
string
,
error
)
{
client
,
err
:=
k8sClient
()
if
err
!=
nil
{
return
""
,
err
}
endpoints
,
err
:=
client
.
CoreV1
()
.
Endpoints
(
"default"
)
.
Get
(
context
.
Background
(),
"kubernetes"
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
""
,
err
}
var
addresses
[]
string
for
_
,
subset
:=
range
endpoints
.
Subsets
{
for
_
,
address
:=
range
subset
.
Addresses
{
addresses
=
append
(
addresses
,
address
.
IP
)
}
}
return
strings
.
Join
(
addresses
,
","
),
nil
}
// RunCommand Runs command on the host
func
RunCommand
(
cmd
string
)
(
string
,
error
)
{
c
:=
exec
.
Command
(
"bash"
,
"-c"
,
cmd
)
...
...
tests/integration/startup/startup_int_test.go
View file @
c928fb06
...
...
@@ -5,12 +5,12 @@ import (
"path/filepath"
"testing"
v1
"k8s.io/api/core/v1"
testutil
"github.com/k3s-io/k3s/tests/integration"
.
"github.com/onsi/ginkgo/v2"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega/gstruct"
v1
"k8s.io/api/core/v1"
)
var
startupServer
*
testutil
.
K3sServer
...
...
@@ -85,12 +85,18 @@ var _ = Describe("startup tests", Ordered, func() {
It
(
"creates dummy interfaces"
,
func
()
{
Expect
(
testutil
.
RunCommand
(
"ip link add dummy2 type dummy"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip link add dummy3 type dummy"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip link add dummy4 type dummy"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip addr add 11.22.33.44/24 dev dummy2"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip addr add 55.66.77.88/24 dev dummy3"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip addr add 11.11.22.22/24 dev dummy4"
))
.
To
(
Equal
(
""
))
})
It
(
"is created with node-ip arguments"
,
func
()
{
var
err
error
startupServerArgs
=
[]
string
{
"--node-ip"
,
"11.22.33.44"
,
"--node-external-ip"
,
"55.66.77.88"
}
startupServerArgs
=
[]
string
{
"--node-ip"
,
"11.22.33.44"
,
"--node-external-ip"
,
"55.66.77.88"
,
"--advertise-address"
,
"11.11.22.22"
,
}
startupServer
,
err
=
testutil
.
K3sStartServer
(
startupServerArgs
...
)
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
})
...
...
@@ -110,13 +116,20 @@ var _ = Describe("startup tests", Ordered, func() {
{
Type
:
"ExternalIP"
,
Address
:
"55.66.77.88"
,
}}))
},
}))
})
It
(
"get the kubectl and see if has the right advertise ip"
,
func
()
{
apiInfo
,
err
:=
testutil
.
GetEndpointsAddresses
()
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
Expect
(
apiInfo
)
.
To
(
ContainSubstring
(
"11.11.22.22"
))
})
It
(
"dies cleanly"
,
func
()
{
Expect
(
testutil
.
K3sKillServer
(
startupServer
))
.
To
(
Succeed
())
Expect
(
testutil
.
K3sCleanup
(
-
1
,
""
))
.
To
(
Succeed
())
Expect
(
testutil
.
RunCommand
(
"ip link del dummy2"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip link del dummy3"
))
.
To
(
Equal
(
""
))
Expect
(
testutil
.
RunCommand
(
"ip link del dummy4"
))
.
To
(
Equal
(
""
))
})
})
When
(
"a server with different data-dir is created"
,
func
()
{
...
...
@@ -250,6 +263,7 @@ var _ = Describe("startup tests", Ordered, func() {
Expect
(
testutil
.
K3sCleanup
(
-
1
,
""
))
.
To
(
Succeed
())
})
})
})
var
failed
bool
...
...
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