Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure e2e Tests to Improve Organization #979

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ ci_run && {
echo "Go Build successfull"
export TEST_CLIENT_BINARY=$PWD/tkn
fi
go_test_e2e ./test/e2e || failed=1
go_test_e2e ./test/e2e/... || failed=1
(( failed )) && fail_test
}

Expand Down
104 changes: 53 additions & 51 deletions test/e2e/pipeline_e2e_test.go → test/e2e/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// +build e2e
// Copyright © 2020 The Tekton Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package e2e
package pipeline

import (
"encoding/json"
Expand All @@ -24,6 +25,7 @@ import (

"github.com/AlecAivazis/survey/v2/terminal"
"github.com/Netflix/go-expect"
"github.com/tektoncd/cli/test/e2e"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tb "github.com/tektoncd/pipeline/test/builder"
"gotest.tools/v3/assert"
Expand All @@ -42,11 +44,11 @@ const (

func TestPipelinesE2E(t *testing.T) {
t.Parallel()
c, namespace := Setup(t)
knativetest.CleanupOnInterrupt(func() { TearDown(t, c, namespace) }, t.Logf)
defer TearDown(t, c, namespace)
c, namespace := e2e.Setup(t)
knativetest.CleanupOnInterrupt(func() { e2e.TearDown(t, c, namespace) }, t.Logf)
defer e2e.TearDown(t, c, namespace)

tkn, err := NewTknRunner(namespace)
tkn, err := e2e.NewTknRunner(namespace)
if err != nil {
t.Fatalf("Error creating tknRunner %+v", err)
}
Expand Down Expand Up @@ -75,11 +77,11 @@ func TestPipelinesE2E(t *testing.T) {

t.Run("Get list of Tasks from namespace "+namespace, func(t *testing.T) {
res := tkn.Run("task", "list")
expected := ListAllTasksOutput(t, c, map[int]interface{}{
0: &TaskData{
expected := e2e.ListAllTasksOutput(t, c, map[int]interface{}{
0: &e2e.TaskData{
Name: TaskName2,
},
1: &TaskData{
1: &e2e.TaskData{
Name: TaskName1,
},
})
Expand All @@ -94,8 +96,8 @@ func TestPipelinesE2E(t *testing.T) {
t.Run("Get list of Pipelines from namespace "+namespace, func(t *testing.T) {
res := tkn.Run("pipelines", "list")

expected := ListAllPipelinesOutput(t, c, map[int]interface{}{
0: &PipelinesListData{
expected := e2e.ListAllPipelinesOutput(t, c, map[int]interface{}{
0: &e2e.PipelinesListData{
Name: tePipelineName,
Status: "---",
},
Expand All @@ -108,7 +110,7 @@ func TestPipelinesE2E(t *testing.T) {
})

})
// Bug to fix

t.Run("Get list of pipelines from other namespace [default] should throw Error", func(t *testing.T) {
res := tkn.RunNoNamespace("pipelines", "list", "-n", "default")

Expand All @@ -123,10 +125,10 @@ func TestPipelinesE2E(t *testing.T) {
res := tkn.Run("pipelines", "list",
`-o=jsonpath={range.items[*]}{.metadata.name}{"\n"}{end}`)

expected := ListResourceNamesForJSONPath(
GetPipelineListWithTestData(t, c,
expected := e2e.ListResourceNamesForJSONPath(
e2e.GetPipelineListWithTestData(t, c,
map[int]interface{}{
0: &PipelinesListData{
0: &e2e.PipelinesListData{
Name: tePipelineName,
Status: "---",
},
Expand Down Expand Up @@ -156,20 +158,20 @@ func TestPipelinesE2E(t *testing.T) {
t.Run("Validate Pipeline describe command in namespace "+namespace, func(t *testing.T) {
res := tkn.Run("pipeline", "describe", tePipelineName)

expected := GetPipelineDescribeOutput(t, c, tePipelineName,
expected := e2e.GetPipelineDescribeOutput(t, c, tePipelineName,
map[int]interface{}{
0: &PipelineDescribeData{
0: &e2e.PipelineDescribeData{
Name: tePipelineName,
Resources: map[string]string{
"source-repo": "git",
},
Task: map[int]interface{}{
0: &TaskRefData{
0: &e2e.TaskRefData{
TaskName: "first-create-file",
TaskRef: TaskName1,
RunAfter: nil,
},
1: &TaskRefData{
1: &e2e.TaskRefData{
TaskName: "then-check",
TaskRef: TaskName2,
RunAfter: nil,
Expand Down Expand Up @@ -198,9 +200,9 @@ func TestPipelinesE2E(t *testing.T) {

time.Sleep(1 * time.Second)

pipelineGeneratedName = GetPipelineRunListWithName(c, tePipelineName).Items[0].Name
pipelineGeneratedName = e2e.GetPipelineRunListWithName(c, tePipelineName).Items[0].Name
vars["Element"] = pipelineGeneratedName
expected := ProcessString(`(Pipelinerun started: {{.Element}}
expected := e2e.ProcessString(`(Pipelinerun started: {{.Element}}
Waiting for logs to be available...
.*)`, vars)

Expand All @@ -217,12 +219,12 @@ Waiting for logs to be available...
t.Run("Get list of Taskruns from namespace "+namespace, func(t *testing.T) {
res := tkn.Run("taskrun", "list")

expected := ListAllTaskRunsOutput(t, c, false, map[int]interface{}{
0: &TaskRunData{
expected := e2e.ListAllTaskRunsOutput(t, c, false, map[int]interface{}{
0: &e2e.TaskRunData{
Name: "output-pipeline-run-",
Status: "Succeeded",
},
1: &TaskRunData{
1: &e2e.TaskRunData{
Name: "output-pipeline-run-",
Status: "Succeeded",
},
Expand All @@ -239,20 +241,20 @@ Waiting for logs to be available...
t.Run("Validate Pipeline describe command in namespace "+namespace+" after PipelineRun completed successfully", func(t *testing.T) {
res := tkn.Run("pipeline", "describe", tePipelineName)

expected := GetPipelineDescribeOutput(t, c, tePipelineName,
expected := e2e.GetPipelineDescribeOutput(t, c, tePipelineName,
map[int]interface{}{
0: &PipelineDescribeData{
0: &e2e.PipelineDescribeData{
Name: tePipelineName,
Resources: map[string]string{
"source-repo": "git",
},
Task: map[int]interface{}{
0: &TaskRefData{
0: &e2e.TaskRefData{
TaskName: "first-create-file",
TaskRef: TaskName1,
RunAfter: nil,
},
1: &TaskRefData{
1: &e2e.TaskRefData{
TaskName: "then-check",
TaskRef: TaskName2,
RunAfter: nil,
Expand All @@ -273,7 +275,7 @@ Waiting for logs to be available...
})

t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
RunInteractiveTests(t, namespace, tkn.Path(), &Prompt{
e2e.RunInteractiveTests(t, namespace, tkn.Path(), &e2e.Prompt{
CmdArgs: []string{"pipeline", "logs", "-f", "-n", namespace},
Procedure: func(c *expect.Console) error {
if _, err := c.ExpectString("Select pipeline:"); err != nil {
Expand All @@ -300,11 +302,11 @@ Waiting for logs to be available...

func TestPipelinesNegativeE2E(t *testing.T) {
t.Parallel()
c, namespace := Setup(t)
knativetest.CleanupOnInterrupt(func() { TearDown(t, c, namespace) }, t.Logf)
defer TearDown(t, c, namespace)
c, namespace := e2e.Setup(t)
knativetest.CleanupOnInterrupt(func() { e2e.TearDown(t, c, namespace) }, t.Logf)
defer e2e.TearDown(t, c, namespace)

tkn, err := NewTknRunner(namespace)
tkn, err := e2e.NewTknRunner(namespace)
if err != nil {
t.Fatalf("Error creating tknRunner %+v", err)
}
Expand Down Expand Up @@ -334,8 +336,8 @@ func TestPipelinesNegativeE2E(t *testing.T) {
t.Run("Get list of Pipelines from namespace "+namespace, func(t *testing.T) {
res := tkn.Run("pipelines", "list")

expected := ListAllPipelinesOutput(t, c, map[int]interface{}{
0: &PipelinesListData{
expected := e2e.ListAllPipelinesOutput(t, c, map[int]interface{}{
0: &e2e.PipelinesListData{
Name: tePipelineName,
Status: "---",
},
Expand Down Expand Up @@ -363,10 +365,10 @@ func TestPipelinesNegativeE2E(t *testing.T) {
res := tkn.Run("pipelines", "list",
`-o=jsonpath={range.items[*]}{.metadata.name}{"\n"}{end}`)

expected := ListResourceNamesForJSONPath(
GetPipelineListWithTestData(t, c,
expected := e2e.ListResourceNamesForJSONPath(
e2e.GetPipelineListWithTestData(t, c,
map[int]interface{}{
0: &PipelinesListData{
0: &e2e.PipelinesListData{
Name: tePipelineName,
Status: "---",
},
Expand Down Expand Up @@ -395,20 +397,20 @@ func TestPipelinesNegativeE2E(t *testing.T) {
t.Run("Validate Pipeline describe command in namespace "+namespace, func(t *testing.T) {
res := tkn.Run("pipeline", "describe", tePipelineName)

expected := GetPipelineDescribeOutput(t, c, tePipelineName,
expected := e2e.GetPipelineDescribeOutput(t, c, tePipelineName,
map[int]interface{}{
0: &PipelineDescribeData{
0: &e2e.PipelineDescribeData{
Name: tePipelineName,
Resources: map[string]string{
"source-repo": "git",
},
Task: map[int]interface{}{
0: &TaskRefData{
0: &e2e.TaskRefData{
TaskName: "first-create-file",
TaskRef: TaskName1,
RunAfter: nil,
},
1: &TaskRefData{
1: &e2e.TaskRefData{
TaskName: "then-check",
TaskRef: TaskName2,
RunAfter: nil,
Expand All @@ -434,9 +436,9 @@ func TestPipelinesNegativeE2E(t *testing.T) {
"--showlog",
"true")

pipelineGeneratedName = GetPipelineRunListWithName(c, tePipelineName).Items[0].Name
pipelineGeneratedName = e2e.GetPipelineRunListWithName(c, tePipelineName).Items[0].Name
vars["Element"] = pipelineGeneratedName
expected := ProcessString(`(Pipelinerun started: {{.Element}}
expected := e2e.ProcessString(`(Pipelinerun started: {{.Element}}
Waiting for logs to be available...
.*)`, vars)

Expand All @@ -451,20 +453,20 @@ Waiting for logs to be available...
t.Run("Validate Pipeline describe command in namespace "+namespace+" after PipelineRun completed successfully", func(t *testing.T) {
res := tkn.Run("pipeline", "describe", tePipelineName)

expected := GetPipelineDescribeOutput(t, c, tePipelineName,
expected := e2e.GetPipelineDescribeOutput(t, c, tePipelineName,
map[int]interface{}{
0: &PipelineDescribeData{
0: &e2e.PipelineDescribeData{
Name: tePipelineName,
Resources: map[string]string{
"source-repo": "git",
},
Task: map[int]interface{}{
0: &TaskRefData{
0: &e2e.TaskRefData{
TaskName: "first-create-file",
TaskRef: TaskName1,
RunAfter: nil,
},
1: &TaskRefData{
1: &e2e.TaskRefData{
TaskName: "then-check",
TaskRef: TaskName2,
RunAfter: nil,
Expand All @@ -488,11 +490,11 @@ Waiting for logs to be available...

func TestDeletePipelinesE2E(t *testing.T) {
t.Parallel()
c, namespace := Setup(t)
knativetest.CleanupOnInterrupt(func() { TearDown(t, c, namespace) }, t.Logf)
defer TearDown(t, c, namespace)
c, namespace := e2e.Setup(t)
knativetest.CleanupOnInterrupt(func() { e2e.TearDown(t, c, namespace) }, t.Logf)
defer e2e.TearDown(t, c, namespace)

tkn, err := NewTknRunner(namespace)
tkn, err := e2e.NewTknRunner(namespace)
if err != nil {
t.Fatalf("Error creating tknRunner %+v", err)
}
Expand Down
Loading