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
02985c9d
Commit
02985c9d
authored
Sep 01, 2016
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a file from data stored in gobindata to fix kubectl-based examples
parent
f6eb2876
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
8 deletions
+33
-8
examples.go
test/e2e/examples.go
+15
-8
util.go
test/e2e/framework/util.go
+18
-0
No files found.
test/e2e/examples.go
View file @
02985c9d
...
@@ -301,14 +301,16 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
...
@@ -301,14 +301,16 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
framework
.
KubeDescribe
(
"Liveness"
,
func
()
{
framework
.
KubeDescribe
(
"Liveness"
,
func
()
{
It
(
"liveness pods should be automatically restarted"
,
func
()
{
It
(
"liveness pods should be automatically restarted"
,
func
()
{
mkpath
:=
func
(
file
string
)
string
{
mkpath
:=
func
(
file
string
)
string
{
return
filepath
.
Join
(
framework
.
TestContext
.
RepoRoot
,
"test/fixtures/doc-yaml/user-guide/liveness"
,
file
)
path
:=
filepath
.
Join
(
"test/fixtures/doc-yaml/user-guide/liveness"
,
file
)
ExpectNoError
(
framework
.
CreateFileForGoBinData
(
path
,
path
))
return
path
}
}
execYaml
:=
mkpath
(
"exec-liveness.yaml"
)
execYaml
:=
mkpath
(
"exec-liveness.yaml"
)
httpYaml
:=
mkpath
(
"http-liveness.yaml"
)
httpYaml
:=
mkpath
(
"http-liveness.yaml"
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
execYaml
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
filepath
.
Join
(
framework
.
TestContext
.
OutputDir
,
execYaml
)
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
httpYaml
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
filepath
.
Join
(
framework
.
TestContext
.
OutputDir
,
httpYaml
)
,
nsFlag
)
// Since both containers start rapidly, we can easily run this test in parallel.
// Since both containers start rapidly, we can easily run this test in parallel.
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
...
@@ -351,16 +353,19 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
...
@@ -351,16 +353,19 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
framework
.
KubeDescribe
(
"Secret"
,
func
()
{
framework
.
KubeDescribe
(
"Secret"
,
func
()
{
It
(
"should create a pod that reads a secret"
,
func
()
{
It
(
"should create a pod that reads a secret"
,
func
()
{
mkpath
:=
func
(
file
string
)
string
{
mkpath
:=
func
(
file
string
)
string
{
return
filepath
.
Join
(
framework
.
TestContext
.
RepoRoot
,
"test/fixtures/doc-yaml/user-guide/secrets"
,
file
)
path
:=
filepath
.
Join
(
"test/fixtures/doc-yaml/user-guide/secrets"
,
file
)
ExpectNoError
(
framework
.
CreateFileForGoBinData
(
path
,
path
))
return
path
}
}
secretYaml
:=
mkpath
(
"secret.yaml"
)
secretYaml
:=
mkpath
(
"secret.yaml"
)
podYaml
:=
mkpath
(
"secret-pod.yaml"
)
podYaml
:=
mkpath
(
"secret-pod.yaml"
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
podName
:=
"secret-test-pod"
podName
:=
"secret-test-pod"
By
(
"creating secret and pod"
)
By
(
"creating secret and pod"
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
secretYaml
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
filepath
.
Join
(
framework
.
TestContext
.
OutputDir
,
secretYaml
)
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
podYaml
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
filepath
.
Join
(
framework
.
TestContext
.
OutputDir
,
podYaml
)
,
nsFlag
)
err
:=
framework
.
WaitForPodNoLongerRunningInNamespace
(
c
,
podName
,
ns
,
""
)
err
:=
framework
.
WaitForPodNoLongerRunningInNamespace
(
c
,
podName
,
ns
,
""
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -373,14 +378,16 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
...
@@ -373,14 +378,16 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
framework
.
KubeDescribe
(
"Downward API"
,
func
()
{
framework
.
KubeDescribe
(
"Downward API"
,
func
()
{
It
(
"should create a pod that prints his name and namespace"
,
func
()
{
It
(
"should create a pod that prints his name and namespace"
,
func
()
{
mkpath
:=
func
(
file
string
)
string
{
mkpath
:=
func
(
file
string
)
string
{
return
filepath
.
Join
(
framework
.
TestContext
.
RepoRoot
,
"test/fixtures/doc-yaml/user-guide/downward-api"
,
file
)
path
:=
filepath
.
Join
(
"test/fixtures/doc-yaml/user-guide/downward-api"
,
file
)
ExpectNoError
(
framework
.
CreateFileForGoBinData
(
path
,
path
))
return
path
}
}
podYaml
:=
mkpath
(
"dapi-pod.yaml"
)
podYaml
:=
mkpath
(
"dapi-pod.yaml"
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
nsFlag
:=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
podName
:=
"dapi-test-pod"
podName
:=
"dapi-test-pod"
By
(
"creating the pod"
)
By
(
"creating the pod"
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
podYaml
,
nsFlag
)
framework
.
RunKubectlOrDie
(
"create"
,
"-f"
,
filepath
.
Join
(
framework
.
TestContext
.
OutputDir
,
podYaml
)
,
nsFlag
)
err
:=
framework
.
WaitForPodNoLongerRunningInNamespace
(
c
,
podName
,
ns
,
""
)
err
:=
framework
.
WaitForPodNoLongerRunningInNamespace
(
c
,
podName
,
ns
,
""
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
test/e2e/framework/util.go
View file @
02985c9d
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"math"
"math"
"math/rand"
"math/rand"
"net"
"net"
...
@@ -5075,3 +5076,20 @@ func GetMasterAndWorkerNodesOrDie(c *client.Client) (sets.String, *api.NodeList)
...
@@ -5075,3 +5076,20 @@ func GetMasterAndWorkerNodesOrDie(c *client.Client) (sets.String, *api.NodeList)
}
}
return
masters
,
nodes
return
masters
,
nodes
}
}
func
CreateFileForGoBinData
(
gobindataPath
,
outputFilename
string
)
error
{
data
:=
ReadOrDie
(
gobindataPath
)
if
len
(
data
)
==
0
{
return
fmt
.
Errorf
(
"Failed to read gobindata from %v"
,
gobindataPath
)
}
fullPath
:=
filepath
.
Join
(
TestContext
.
OutputDir
,
outputFilename
)
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
fullPath
),
0777
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error while creating directory %v: %v"
,
filepath
.
Dir
(
fullPath
),
err
)
}
err
=
ioutil
.
WriteFile
(
fullPath
,
data
,
0644
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error while trying to write to file %v: %v"
,
fullPath
,
err
)
}
return
nil
}
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