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
0694dd70
Commit
0694dd70
authored
Feb 15, 2018
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating code to use TempDir in manifest test
parent
271c267f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
ingress_utils.go
test/e2e/framework/ingress_utils.go
+9
-9
manifest.go
test/e2e/manifest/manifest.go
+1
-1
manifest_test.go
test/e2e/manifest/manifest_test.go
+13
-2
No files found.
test/e2e/framework/ingress_utils.go
View file @
0694dd70
...
...
@@ -1128,12 +1128,12 @@ func (j *IngressTestJig) CreateIngress(manifestPath, ns string, ingAnnotations m
j
.
Ingress
.
Annotations
[
k
]
=
v
}
j
.
Logger
.
Infof
(
fmt
.
Sprintf
(
"creating"
+
j
.
Ingress
.
Name
+
" ingress"
))
j
.
Ingress
,
err
=
j
.
R
unCreate
(
j
.
Ingress
)
j
.
Ingress
,
err
=
j
.
r
unCreate
(
j
.
Ingress
)
ExpectNoError
(
err
)
}
//
R
unCreate runs the required command to create the given ingress.
func
(
j
*
IngressTestJig
)
R
unCreate
(
ing
*
extensions
.
Ingress
)
(
*
extensions
.
Ingress
,
error
)
{
//
r
unCreate runs the required command to create the given ingress.
func
(
j
*
IngressTestJig
)
r
unCreate
(
ing
*
extensions
.
Ingress
)
(
*
extensions
.
Ingress
,
error
)
{
if
j
.
Class
!=
MulticlusterIngressClassValue
{
return
j
.
Client
.
ExtensionsV1beta1
()
.
Ingresses
(
ing
.
Namespace
)
.
Create
(
ing
)
}
...
...
@@ -1146,8 +1146,8 @@ func (j *IngressTestJig) RunCreate(ing *extensions.Ingress) (*extensions.Ingress
return
ing
,
err
}
//
R
unUpdate runs the required command to update the given ingress.
func
(
j
*
IngressTestJig
)
R
unUpdate
(
ing
*
extensions
.
Ingress
)
(
*
extensions
.
Ingress
,
error
)
{
//
r
unUpdate runs the required command to update the given ingress.
func
(
j
*
IngressTestJig
)
r
unUpdate
(
ing
*
extensions
.
Ingress
)
(
*
extensions
.
Ingress
,
error
)
{
if
j
.
Class
!=
MulticlusterIngressClassValue
{
return
j
.
Client
.
ExtensionsV1beta1
()
.
Ingresses
(
ing
.
Namespace
)
.
Update
(
ing
)
}
...
...
@@ -1171,7 +1171,7 @@ func (j *IngressTestJig) Update(update func(ing *extensions.Ingress)) {
Failf
(
"failed to get ingress %q: %v"
,
name
,
err
)
}
update
(
j
.
Ingress
)
j
.
Ingress
,
err
=
j
.
R
unUpdate
(
j
.
Ingress
)
j
.
Ingress
,
err
=
j
.
r
unUpdate
(
j
.
Ingress
)
if
err
==
nil
{
DescribeIng
(
j
.
Ingress
.
Namespace
)
return
...
...
@@ -1223,7 +1223,7 @@ func (j *IngressTestJig) TryDeleteIngress() {
}
func
(
j
*
IngressTestJig
)
TryDeleteGivenIngress
(
ing
*
extensions
.
Ingress
)
{
if
err
:=
j
.
R
unDelete
(
ing
,
j
.
Class
);
err
!=
nil
{
if
err
:=
j
.
r
unDelete
(
ing
,
j
.
Class
);
err
!=
nil
{
j
.
Logger
.
Infof
(
"Error while deleting the ingress %v/%v with class %s: %v"
,
ing
.
Namespace
,
ing
.
Name
,
j
.
Class
,
err
)
}
}
...
...
@@ -1235,8 +1235,8 @@ func (j *IngressTestJig) TryDeleteGivenService(svc *v1.Service) {
}
}
//
R
unDelete runs the required command to delete the given ingress.
func
(
j
*
IngressTestJig
)
R
unDelete
(
ing
*
extensions
.
Ingress
,
class
string
)
error
{
//
r
unDelete runs the required command to delete the given ingress.
func
(
j
*
IngressTestJig
)
r
unDelete
(
ing
*
extensions
.
Ingress
,
class
string
)
error
{
if
j
.
Class
!=
MulticlusterIngressClassValue
{
return
j
.
Client
.
ExtensionsV1beta1
()
.
Ingresses
(
ing
.
Namespace
)
.
Delete
(
ing
.
Name
,
nil
)
}
...
...
test/e2e/manifest/manifest.go
View file @
0694dd70
...
...
@@ -92,7 +92,7 @@ func IngressFromManifest(fileName string) (*extensions.Ingress, error) {
}
// IngressToManifest generates a yaml file in the given path with the given ingress.
//
Returns the file name and error, if there was any
.
//
Assumes that a directory exists at the given path
.
func
IngressToManifest
(
ing
*
extensions
.
Ingress
,
path
string
)
error
{
serialized
,
err
:=
util
.
MarshalToYaml
(
ing
,
extensions
.
SchemeGroupVersion
)
if
err
!=
nil
{
...
...
test/e2e/manifest/manifest_test.go
View file @
0694dd70
...
...
@@ -17,6 +17,9 @@ limitations under the License.
package
manifest
import
(
"io/ioutil"
"os"
"path/filepath"
"testing"
extensions
"k8s.io/api/extensions/v1beta1"
...
...
@@ -24,12 +27,20 @@ import (
func
TestIngressToManifest
(
t
*
testing
.
T
)
{
ing
:=
&
extensions
.
Ingress
{}
// Create a temp dir.
tmpDir
,
err
:=
ioutil
.
TempDir
(
""
,
"kubemci"
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error in creating temp dir: %s"
,
err
)
}
defer
os
.
RemoveAll
(
tmpDir
)
ingPath
:=
filepath
.
Join
(
tmpDir
,
"ing.yaml"
)
// Write the ingress to a file and ensure that there is no error.
if
err
:=
IngressToManifest
(
ing
,
"/tmp/ing.yaml"
);
err
!=
nil
{
if
err
:=
IngressToManifest
(
ing
,
ingPath
);
err
!=
nil
{
t
.
Fatalf
(
"Error in creating file: %s"
,
err
)
}
// Writing it again should not return an error.
if
err
:=
IngressToManifest
(
ing
,
"/tmp/ing.yaml"
);
err
!=
nil
{
if
err
:=
IngressToManifest
(
ing
,
ingPath
);
err
!=
nil
{
t
.
Fatalf
(
"Error in creating file: %s"
,
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