diff --git a/test/e2e/framework/ingress_utils.go b/test/e2e/framework/ingress_utils.go index e66d09ddbfd..d75ae004fea 100644 --- a/test/e2e/framework/ingress_utils.go +++ b/test/e2e/framework/ingress_utils.go @@ -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.RunCreate(j.Ingress) + j.Ingress, err = j.runCreate(j.Ingress) ExpectNoError(err) } -// RunCreate runs the required command to create the given ingress. -func (j *IngressTestJig) RunCreate(ing *extensions.Ingress) (*extensions.Ingress, error) { +// runCreate runs the required command to create the given ingress. +func (j *IngressTestJig) runCreate(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 } -// RunUpdate runs the required command to update the given ingress. -func (j *IngressTestJig) RunUpdate(ing *extensions.Ingress) (*extensions.Ingress, error) { +// runUpdate runs the required command to update the given ingress. +func (j *IngressTestJig) runUpdate(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.RunUpdate(j.Ingress) + j.Ingress, err = j.runUpdate(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.RunDelete(ing, j.Class); err != nil { + if err := j.runDelete(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) { } } -// RunDelete runs the required command to delete the given ingress. -func (j *IngressTestJig) RunDelete(ing *extensions.Ingress, class string) error { +// runDelete runs the required command to delete the given ingress. +func (j *IngressTestJig) runDelete(ing *extensions.Ingress, class string) error { if j.Class != MulticlusterIngressClassValue { return j.Client.ExtensionsV1beta1().Ingresses(ing.Namespace).Delete(ing.Name, nil) } diff --git a/test/e2e/manifest/manifest.go b/test/e2e/manifest/manifest.go index 01d7aa1ff90..1bd78e32703 100644 --- a/test/e2e/manifest/manifest.go +++ b/test/e2e/manifest/manifest.go @@ -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 { diff --git a/test/e2e/manifest/manifest_test.go b/test/e2e/manifest/manifest_test.go index ae2145218a0..91ac882d5ba 100644 --- a/test/e2e/manifest/manifest_test.go +++ b/test/e2e/manifest/manifest_test.go @@ -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) } }