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
a227ce42
Commit
a227ce42
authored
Aug 11, 2016
by
Michael Taufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for memory to be reclaimed after node_e2e MemoryEviction test
This helps prevent interference with other tests that run immediately after the MemoryEviction test.
parent
cdfd46cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
memory_eviction_test.go
test/e2e_node/memory_eviction_test.go
+59
-0
No files found.
test/e2e_node/memory_eviction_test.go
View file @
a227ce42
...
@@ -17,13 +17,18 @@ limitations under the License.
...
@@ -17,13 +17,18 @@ limitations under the License.
package
e2e_node
package
e2e_node
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strconv"
"strings"
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/stats"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -96,6 +101,60 @@ var _ = framework.KubeDescribe("MemoryEviction [Slow] [Serial]", func() {
...
@@ -96,6 +101,60 @@ var _ = framework.KubeDescribe("MemoryEviction [Slow] [Serial]", func() {
},
60
*
time
.
Minute
,
5
*
time
.
Second
)
.
Should
(
Equal
(
true
))
},
60
*
time
.
Minute
,
5
*
time
.
Second
)
.
Should
(
Equal
(
true
))
// Wait for available memory to decrease to a reasonable level before ending the test.
// This prevents interference with tests that start immediately after this one.
Eventually
(
func
()
bool
{
glog
.
Infof
(
"Waiting for available memory to decrease to a reasonable level before ending the test."
)
summary
:=
stats
.
Summary
{}
client
:=
&
http
.
Client
{}
req
,
err
:=
http
.
NewRequest
(
"GET"
,
"http://localhost:10255/stats/summary"
,
nil
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to build http request: %v"
,
err
)
return
false
}
req
.
Header
.
Add
(
"Accept"
,
"application/json"
)
resp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to get /stats/summary: %v"
,
err
)
return
false
}
contentsBytes
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to read /stats/summary: %+v"
,
resp
)
return
false
}
contents
:=
string
(
contentsBytes
)
decoder
:=
json
.
NewDecoder
(
strings
.
NewReader
(
contents
))
err
=
decoder
.
Decode
(
&
summary
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to parse /stats/summary to go struct: %+v"
,
resp
)
return
false
}
if
summary
.
Node
.
Memory
.
AvailableBytes
==
nil
{
glog
.
Warningf
(
"summary.Node.Memory.AvailableBytes was nil, cannot get memory stats."
)
return
false
}
if
summary
.
Node
.
Memory
.
WorkingSetBytes
==
nil
{
glog
.
Warningf
(
"summary.Node.Memory.WorkingSetBytes was nil, cannot get memory stats."
)
return
false
}
avail
:=
*
summary
.
Node
.
Memory
.
AvailableBytes
wset
:=
*
summary
.
Node
.
Memory
.
WorkingSetBytes
// memory limit = avail + wset
limit
:=
avail
+
wset
halflimit
:=
limit
/
2
// Wait for at least half of memory limit to be available
glog
.
Infof
(
"Current available memory is: %d bytes. Waiting for at least %d bytes available."
,
avail
,
halflimit
)
if
avail
>=
halflimit
{
return
true
}
return
false
},
5
*
time
.
Minute
,
5
*
time
.
Second
)
.
Should
(
Equal
(
true
))
})
})
})
})
...
...
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