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
e52e299d
Commit
e52e299d
authored
May 22, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8706 from lavalamp/e2e-timeout
Use e2e framework in more tests
parents
e58674b3
05d2ae56
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
81 deletions
+27
-81
dns.go
test/e2e/dns.go
+9
-20
empty_dir.go
test/e2e/empty_dir.go
+3
-12
framework.go
test/e2e/framework.go
+5
-0
secrets.go
test/e2e/secrets.go
+6
-26
service_accounts.go
test/e2e/service_accounts.go
+4
-23
No files found.
test/e2e/dns.go
View file @
e52e299d
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
@@ -38,25 +37,15 @@ var dnsServiceLableSelector = labels.Set{
...
@@ -38,25 +37,15 @@ var dnsServiceLableSelector = labels.Set{
}
.
AsSelector
()
}
.
AsSelector
()
var
_
=
Describe
(
"DNS"
,
func
()
{
var
_
=
Describe
(
"DNS"
,
func
()
{
var
c
*
client
.
Client
f
:=
NewFramework
(
"dns"
)
// Use this in tests. They're unique for each test to prevent name collisions.
var
testNamespace
string
BeforeEach
(
func
()
{
var
err
error
c
,
err
=
loadClient
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
ns
,
err
:=
createTestingNS
(
"dns"
,
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
testNamespace
=
ns
.
Name
})
It
(
"should provide DNS for the cluster"
,
func
()
{
It
(
"should provide DNS for the cluster"
,
func
()
{
if
providerIs
(
"vagrant"
)
{
if
providerIs
(
"vagrant"
)
{
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
return
return
}
}
podClient
:=
c
.
Pods
(
api
.
NamespaceDefault
)
podClient
:=
f
.
Client
.
Pods
(
api
.
NamespaceDefault
)
By
(
"Waiting for DNS Service to be Running"
)
By
(
"Waiting for DNS Service to be Running"
)
dnsPods
,
err
:=
podClient
.
List
(
dnsServiceLableSelector
,
fields
.
Everything
())
dnsPods
,
err
:=
podClient
.
List
(
dnsServiceLableSelector
,
fields
.
Everything
())
...
@@ -66,7 +55,7 @@ var _ = Describe("DNS", func() {
...
@@ -66,7 +55,7 @@ var _ = Describe("DNS", func() {
if
len
(
dnsPods
.
Items
)
!=
1
{
if
len
(
dnsPods
.
Items
)
!=
1
{
Failf
(
"Unexpected number of pods (%d) matches the label selector %v"
,
len
(
dnsPods
.
Items
),
dnsServiceLableSelector
.
String
())
Failf
(
"Unexpected number of pods (%d) matches the label selector %v"
,
len
(
dnsPods
.
Items
),
dnsServiceLableSelector
.
String
())
}
}
expectNoError
(
waitForPodRunning
(
c
,
dnsPods
.
Items
[
0
]
.
Name
))
expectNoError
(
waitForPodRunning
(
f
.
Client
,
dnsPods
.
Items
[
0
]
.
Name
))
// All the names we need to be able to resolve.
// All the names we need to be able to resolve.
// TODO: Spin up a separate test service and test that dns works for that service.
// TODO: Spin up a separate test service and test that dns works for that service.
...
@@ -99,7 +88,7 @@ var _ = Describe("DNS", func() {
...
@@ -99,7 +88,7 @@ var _ = Describe("DNS", func() {
},
},
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"dns-test-"
+
string
(
util
.
NewUUID
()),
Name
:
"dns-test-"
+
string
(
util
.
NewUUID
()),
Namespace
:
testNamespac
e
,
Namespace
:
f
.
Namespace
.
Nam
e
,
},
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
Volumes
:
[]
api
.
Volume
{
...
@@ -138,7 +127,7 @@ var _ = Describe("DNS", func() {
...
@@ -138,7 +127,7 @@ var _ = Describe("DNS", func() {
}
}
By
(
"submitting the pod to kubernetes"
)
By
(
"submitting the pod to kubernetes"
)
podClient
=
c
.
Pods
(
testNamespac
e
)
podClient
=
f
.
Client
.
Pods
(
f
.
Namespace
.
Nam
e
)
defer
func
()
{
defer
func
()
{
By
(
"deleting the pod"
)
By
(
"deleting the pod"
)
defer
GinkgoRecover
()
defer
GinkgoRecover
()
...
@@ -148,7 +137,7 @@ var _ = Describe("DNS", func() {
...
@@ -148,7 +137,7 @@ var _ = Describe("DNS", func() {
Failf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
)
Failf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
)
}
}
expectNoError
(
waitForPodRunningInNamespace
(
c
,
pod
.
Name
,
testNamespac
e
))
expectNoError
(
f
.
WaitForPodRunning
(
pod
.
Nam
e
))
By
(
"retrieving the pod"
)
By
(
"retrieving the pod"
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
...
@@ -165,10 +154,10 @@ var _ = Describe("DNS", func() {
...
@@ -165,10 +154,10 @@ var _ = Describe("DNS", func() {
for
_
,
name
:=
range
namesToResolve
{
for
_
,
name
:=
range
namesToResolve
{
for
_
,
proto
:=
range
[]
string
{
"udp"
,
"tcp"
}
{
for
_
,
proto
:=
range
[]
string
{
"udp"
,
"tcp"
}
{
testCase
:=
fmt
.
Sprintf
(
"%s@%s"
,
proto
,
name
)
testCase
:=
fmt
.
Sprintf
(
"%s@%s"
,
proto
,
name
)
_
,
err
:=
c
.
Get
()
.
_
,
err
:=
f
.
Client
.
Get
()
.
Prefix
(
"proxy"
)
.
Prefix
(
"proxy"
)
.
Resource
(
"pods"
)
.
Resource
(
"pods"
)
.
Namespace
(
testNamespac
e
)
.
Namespace
(
f
.
Namespace
.
Nam
e
)
.
Name
(
pod
.
Name
)
.
Name
(
pod
.
Name
)
.
Suffix
(
"results"
,
testCase
)
.
Suffix
(
"results"
,
testCase
)
.
Do
()
.
Raw
()
Do
()
.
Raw
()
...
...
test/e2e/empty_dir.go
View file @
e52e299d
...
@@ -22,22 +22,13 @@ import (
...
@@ -22,22 +22,13 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
)
)
var
_
=
Describe
(
"emptyDir"
,
func
()
{
var
_
=
Describe
(
"emptyDir"
,
func
()
{
var
(
f
:=
NewFramework
(
"emptydir"
)
c
*
client
.
Client
)
BeforeEach
(
func
()
{
var
err
error
c
,
err
=
loadClient
()
expectNoError
(
err
)
})
It
(
"volume on tmpfs should have the correct mode"
,
func
()
{
It
(
"volume on tmpfs should have the correct mode"
,
func
()
{
volumePath
:=
"/test-volume"
volumePath
:=
"/test-volume"
...
@@ -50,7 +41,7 @@ var _ = Describe("emptyDir", func() {
...
@@ -50,7 +41,7 @@ var _ = Describe("emptyDir", func() {
fmt
.
Sprintf
(
"--fs_type=%v"
,
volumePath
),
fmt
.
Sprintf
(
"--fs_type=%v"
,
volumePath
),
fmt
.
Sprintf
(
"--file_mode=%v"
,
volumePath
),
fmt
.
Sprintf
(
"--file_mode=%v"
,
volumePath
),
}
}
testContainerOutput
(
"emptydir r/w on tmpfs"
,
c
,
pod
,
[]
string
{
f
.
TestContainerOutput
(
"emptydir r/w on tmpfs"
,
pod
,
[]
string
{
"mount type of
\"
/test-volume
\"
: tmpfs"
,
"mount type of
\"
/test-volume
\"
: tmpfs"
,
"mode of file
\"
/test-volume
\"
: dtrwxrwxrwx"
,
// we expect the sticky bit (mode flag t) to be set for the dir
"mode of file
\"
/test-volume
\"
: dtrwxrwxrwx"
,
// we expect the sticky bit (mode flag t) to be set for the dir
})
})
...
@@ -69,7 +60,7 @@ var _ = Describe("emptyDir", func() {
...
@@ -69,7 +60,7 @@ var _ = Describe("emptyDir", func() {
fmt
.
Sprintf
(
"--rw_new_file=%v"
,
filePath
),
fmt
.
Sprintf
(
"--rw_new_file=%v"
,
filePath
),
fmt
.
Sprintf
(
"--file_mode=%v"
,
filePath
),
fmt
.
Sprintf
(
"--file_mode=%v"
,
filePath
),
}
}
testContainerOutput
(
"emptydir r/w on tmpfs"
,
c
,
pod
,
[]
string
{
f
.
TestContainerOutput
(
"emptydir r/w on tmpfs"
,
pod
,
[]
string
{
"mount type of
\"
/test-volume
\"
: tmpfs"
,
"mount type of
\"
/test-volume
\"
: tmpfs"
,
"mode of file
\"
/test-volume/test-file
\"
: -rw-r--r--"
,
"mode of file
\"
/test-volume/test-file
\"
: -rw-r--r--"
,
"content of file
\"
/test-volume/test-file
\"
: mount-tester new file"
,
"content of file
\"
/test-volume/test-file
\"
: mount-tester new file"
,
...
...
test/e2e/framework.go
View file @
e52e299d
...
@@ -94,3 +94,8 @@ func (f *Framework) afterEach() {
...
@@ -94,3 +94,8 @@ func (f *Framework) afterEach() {
func
(
f
*
Framework
)
WaitForPodRunning
(
podName
string
)
error
{
func
(
f
*
Framework
)
WaitForPodRunning
(
podName
string
)
error
{
return
waitForPodRunningInNamespace
(
f
.
Client
,
podName
,
f
.
Namespace
.
Name
)
return
waitForPodRunningInNamespace
(
f
.
Client
,
podName
,
f
.
Namespace
.
Name
)
}
}
// Runs the given pod and verifies that its output matches the desired output.
func
(
f
*
Framework
)
TestContainerOutput
(
scenarioName
string
,
pod
*
api
.
Pod
,
expectedOutput
[]
string
)
{
testContainerOutputInNamespace
(
scenarioName
,
f
.
Client
,
pod
,
expectedOutput
,
f
.
Namespace
.
Name
)
}
test/e2e/secrets.go
View file @
e52e299d
...
@@ -20,33 +20,13 @@ import (
...
@@ -20,33 +20,13 @@ import (
"fmt"
"fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
)
)
var
_
=
Describe
(
"Secrets"
,
func
()
{
var
_
=
Describe
(
"Secrets"
,
func
()
{
var
c
*
client
.
Client
f
:=
NewFramework
(
"secrets"
)
var
ns
string
BeforeEach
(
func
()
{
var
err
error
c
,
err
=
loadClient
()
expectNoError
(
err
)
ns_
,
err
:=
createTestingNS
(
"secrets"
,
c
)
ns
=
ns_
.
Name
expectNoError
(
err
)
})
AfterEach
(
func
()
{
// Clean up the namespace if a non-default one was used
if
ns
!=
api
.
NamespaceDefault
{
By
(
"Cleaning up the namespace"
)
err
:=
c
.
Namespaces
()
.
Delete
(
ns
)
expectNoError
(
err
)
}
})
It
(
"should be consumable from pods"
,
func
()
{
It
(
"should be consumable from pods"
,
func
()
{
name
:=
"secret-test-"
+
string
(
util
.
NewUUID
())
name
:=
"secret-test-"
+
string
(
util
.
NewUUID
())
...
@@ -55,7 +35,7 @@ var _ = Describe("Secrets", func() {
...
@@ -55,7 +35,7 @@ var _ = Describe("Secrets", func() {
secret
:=
&
api
.
Secret
{
secret
:=
&
api
.
Secret
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
ns
,
Namespace
:
f
.
Namespace
.
Name
,
Name
:
name
,
Name
:
name
,
},
},
Data
:
map
[
string
][]
byte
{
Data
:
map
[
string
][]
byte
{
...
@@ -68,12 +48,12 @@ var _ = Describe("Secrets", func() {
...
@@ -68,12 +48,12 @@ var _ = Describe("Secrets", func() {
By
(
fmt
.
Sprintf
(
"Creating secret with name %s"
,
secret
.
Name
))
By
(
fmt
.
Sprintf
(
"Creating secret with name %s"
,
secret
.
Name
))
defer
func
()
{
defer
func
()
{
By
(
"Cleaning up the secret"
)
By
(
"Cleaning up the secret"
)
if
err
:=
c
.
Secrets
(
ns
)
.
Delete
(
secret
.
Name
);
err
!=
nil
{
if
err
:=
f
.
Client
.
Secrets
(
f
.
Namespace
.
Name
)
.
Delete
(
secret
.
Name
);
err
!=
nil
{
Failf
(
"unable to delete secret %v: %v"
,
secret
.
Name
,
err
)
Failf
(
"unable to delete secret %v: %v"
,
secret
.
Name
,
err
)
}
}
}()
}()
var
err
error
var
err
error
if
secret
,
err
=
c
.
Secrets
(
ns
)
.
Create
(
secret
);
err
!=
nil
{
if
secret
,
err
=
f
.
Client
.
Secrets
(
f
.
Namespace
.
Name
)
.
Create
(
secret
);
err
!=
nil
{
Failf
(
"unable to create test secret %s: %v"
,
secret
.
Name
,
err
)
Failf
(
"unable to create test secret %s: %v"
,
secret
.
Name
,
err
)
}
}
...
@@ -112,9 +92,9 @@ var _ = Describe("Secrets", func() {
...
@@ -112,9 +92,9 @@ var _ = Describe("Secrets", func() {
},
},
}
}
testContainerOutputInNamespace
(
"consume secrets"
,
c
,
pod
,
[]
string
{
testContainerOutputInNamespace
(
"consume secrets"
,
f
.
Client
,
pod
,
[]
string
{
"content of file
\"
/etc/secret-volume/data-1
\"
: value-1"
,
"content of file
\"
/etc/secret-volume/data-1
\"
: value-1"
,
"mode of file
\"
/etc/secret-volume/data-1
\"
: -r--r--r--"
,
"mode of file
\"
/etc/secret-volume/data-1
\"
: -r--r--r--"
,
},
ns
)
},
f
.
Namespace
.
Name
)
})
})
})
})
test/e2e/service_accounts.go
View file @
e52e299d
...
@@ -32,26 +32,7 @@ import (
...
@@ -32,26 +32,7 @@ import (
)
)
var
_
=
Describe
(
"ServiceAccounts"
,
func
()
{
var
_
=
Describe
(
"ServiceAccounts"
,
func
()
{
var
c
*
client
.
Client
f
:=
NewFramework
(
"svcaccounts"
)
var
ns
string
BeforeEach
(
func
()
{
var
err
error
c
,
err
=
loadClient
()
expectNoError
(
err
)
ns_
,
err
:=
createTestingNS
(
"service-accounts"
,
c
)
ns
=
ns_
.
Name
expectNoError
(
err
)
})
AfterEach
(
func
()
{
// Clean up the namespace if a non-default one was used
if
ns
!=
api
.
NamespaceDefault
{
By
(
"Cleaning up the namespace"
)
err
:=
c
.
Namespaces
()
.
Delete
(
ns
)
expectNoError
(
err
)
}
})
It
(
"should mount an API token into pods"
,
func
()
{
It
(
"should mount an API token into pods"
,
func
()
{
var
tokenName
string
var
tokenName
string
...
@@ -61,7 +42,7 @@ var _ = Describe("ServiceAccounts", func() {
...
@@ -61,7 +42,7 @@ var _ = Describe("ServiceAccounts", func() {
expectNoError
(
wait
.
Poll
(
time
.
Millisecond
*
500
,
time
.
Second
*
10
,
func
()
(
bool
,
error
)
{
expectNoError
(
wait
.
Poll
(
time
.
Millisecond
*
500
,
time
.
Second
*
10
,
func
()
(
bool
,
error
)
{
By
(
"getting the auto-created API token"
)
By
(
"getting the auto-created API token"
)
tokenSelector
:=
fields
.
SelectorFromSet
(
map
[
string
]
string
{
client
.
SecretType
:
string
(
api
.
SecretTypeServiceAccountToken
)})
tokenSelector
:=
fields
.
SelectorFromSet
(
map
[
string
]
string
{
client
.
SecretType
:
string
(
api
.
SecretTypeServiceAccountToken
)})
secrets
,
err
:=
c
.
Secrets
(
ns
)
.
List
(
labels
.
Everything
(),
tokenSelector
)
secrets
,
err
:=
f
.
Client
.
Secrets
(
f
.
Namespace
.
Name
)
.
List
(
labels
.
Everything
(),
tokenSelector
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -94,8 +75,8 @@ var _ = Describe("ServiceAccounts", func() {
...
@@ -94,8 +75,8 @@ var _ = Describe("ServiceAccounts", func() {
},
},
}
}
testContainerOutputInNamespace
(
"consume service account token"
,
c
,
pod
,
[]
string
{
f
.
TestContainerOutput
(
"consume service account token"
,
pod
,
[]
string
{
fmt
.
Sprintf
(
`content of file "%s/%s": %s`
,
serviceaccount
.
DefaultAPITokenMountPath
,
api
.
ServiceAccountTokenKey
,
tokenContent
),
fmt
.
Sprintf
(
`content of file "%s/%s": %s`
,
serviceaccount
.
DefaultAPITokenMountPath
,
api
.
ServiceAccountTokenKey
,
tokenContent
),
}
,
ns
)
})
})
})
})
})
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