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

Add integration test to run a helm deploy pipeline #160

Merged
merged 8 commits into from
Oct 20, 2018

Conversation

nader-ziada
Copy link
Member

@nader-ziada nader-ziada commented Oct 17, 2018

Related to: #63

Proposed changes

  • Create a pipeline of two tasks,
  • First task build and push an image
  • Second task helm deploys that image
  • Verify the service created is reachable

/cc @bobcatfish

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 17, 2018
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pivotal-nader-ziada

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [pivotal-nader-ziada]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 17, 2018
@nader-ziada
Copy link
Member Author

/cc @shashwathi

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I LOVE that all the helm setup is being done via the Pipeline itself! So cool!!

Just a few minor comments, only big thing is the cleanup request :D

/meow space

😍

@@ -30,7 +30,7 @@ import (

const (
interval = 1 * time.Second
timeout = 2 * time.Minute
timeout = 4 * time.Minute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point, what do you think about adding a timeout argument to the polling functions, so that each test can pass its own timeout? e.g. the helloworld task probably needs < 1 minute, kaniko needs 2 minutes, this one needs 4 minutes. it will help to keep track of why the timeout is what it is, and also will ensure tests don't wait for longer than they need to

test/helm_task_test.go Show resolved Hide resolved
test/helm_task_test.go Show resolved Hide resolved
Name: "kaniko",
Image: "gcr.io/kaniko-project/executor",
Args: []string{"--dockerfile=/workspace/Dockerfile",
fmt.Sprintf("--destination=%s", imageName),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wanted, we have templating working now, so you could use Task params for the image name and path

"--set",
"image.repository=${inputs.params.image}",
},
}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think something is off with the indentation b/w these

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fixed it

Name: "helm-init",
Image: "alpine/helm",
Args: []string{"init"},
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if the teardown step in the test should invoke a Task or something to remove helm, so that ppl who run this test aren't left with helm running in their clusters (or will the namespace take care of that?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the namespace will not take care of that, but I was worried if if things fail running another task might not work for whatever reason and I wasn't sure how else to remove it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't the cluster get deleted after the test run in Prow?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried if if things fail running another task might not work for whatever reason and I wasn't sure how else to remove it

That's true, so a couple options:

  • Try to do it anyway but don't actually fail anything if the teardown fails (just log it)
  • Try to do teardown without using Pipeline/Task, e.g. call out to kubectl

doesn't the cluster get deleted after the test run in Prow?

Yeah I think so! So we're fine for Prow, I'm more concerned about ppl running this on their own clusters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will get the test green first then add the cleanup

}
}

func getelmDeployPipeline(namespace string) *v1alpha1.Pipeline {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@knative-prow-robot
Copy link

@bobcatfish: Bad category. Please see http://thecatapi.com/api/categories/list

In response to this:

I LOVE that all the helm setup is being done via the Pipeline itself! So cool!!

Just a few minor comments, only big thing is the cleanup request :D

/meow space

😍

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -30,7 +30,7 @@ import (

const (
interval = 1 * time.Second
timeout = 2 * time.Minute
timeout = 4 * time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we had to increase the timeout?

test/crd_checks.go Show resolved Hide resolved
}

logger.Infof("Creating Pipeline %s", helmDeployPipelineName)
if _, err := c.PipelineClient.Create(getelmDeployPipeline(namespace)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling mistake. getelmDeployPipeline

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

t.Errorf("Error getting service at %s %s", helmDeployServiceName, err)
}
var serviceIp string
ingress := k8sService.Status.LoadBalancer.Ingress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might result in null pointer exception if there was an error above in L97.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add a check

test/helm_task_test.go Show resolved Hide resolved
test/helm_task_test.go Outdated Show resolved Hide resolved
test/helm_task_test.go Show resolved Hide resolved
}
}

func getelmDeployPipeline(namespace string) *v1alpha1.Pipeline {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix spell error.

}
}

func getelmDeployPipelineRun(namespace string) *v1alpha1.PipelineRun {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix spell error

@bobcatfish
Copy link
Collaborator

image

wut

/meow space

@tektoncd tektoncd deleted a comment from knative-prow-robot Oct 17, 2018
@bobcatfish
Copy link
Collaborator

/meow space

@knative-prow-robot
Copy link

@bobcatfish: cat image

In response to this:

/meow space

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@nader-ziada nader-ziada force-pushed the helm-task branch 4 times, most recently from eb2c3b6 to 0f03523 Compare October 18, 2018 14:16
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 18, 2018
@nader-ziada nader-ziada force-pushed the helm-task branch 3 times, most recently from d45879f to 323f693 Compare October 18, 2018 20:01
@nader-ziada
Copy link
Member Author

Added cleanup task after the test is runs to remove tiller from cluster

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is almost done!!

}

// cleanup task to remove helm from cluster, will not fail the test if it fails, just log
removeHelmFromCluster(c, t, namespace, logger)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should make sure this runs if the test is interrupted or fails, e.g. like we do with the teardown (and/or move it to the teardown):

	knativetest.CleanupOnInterrupt(func() { tearDown(logger, c.KubeClient, namespace) }, logger)
	defer tearDown(logger, c.KubeClient, namespace)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

 - tektoncd#63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
- Before a pipeline run creates a taskrun for the next task, it needs to
check the passed constraints to respect dependecnies between tasks
- add implementation of canTaskRun and unit tests
- add a task to delete tiller at the end of the helm task test
- call helm cleanup if test is interrupted or fails
- cleanup service account and cluster role binding
@bobcatfish
Copy link
Collaborator

Just a quick note that we should leave #63 open after this b/c we still need to do some work to respect the cluster parameters (e.g. mount and create a kubeconfig that helm can use?). At the moment, we can only deploy to the cluster that the Pipeline CRD is already running in.

(Apologies if I added this comment already, I thought I did but I can't find it 😅 )

@nader-ziada
Copy link
Member Author

@bobcatfish should the different cluster be a different issue since this is not yet implemented in the controllers?

@nader-ziada
Copy link
Member Author

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 19, 2018
will follow up with another pr to update helm test to use this
instead of external repo, but need it to be in git source
@nader-ziada
Copy link
Member Author

/retest

@nader-ziada
Copy link
Member Author

@tejal29 can you take another look, pr is ready for review now. Thanks

The only thing remaining is to not use the external repo, but will have to do another pr to change that because we need the folder in test to exist first in the soure repo.

@nader-ziada
Copy link
Member Author

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 19, 2018
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!
/lgtm

@shashwathi
Copy link
Contributor

This PR also addresses : #148

@knative-prow-robot knative-prow-robot merged commit 6e96911 into tektoncd:master Oct 20, 2018
@bobcatfish
Copy link
Collaborator

@bobcatfish should the different cluster be a different issue since this is not yet implemented in the controllers?

sure that's fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants