taskcat icon indicating copy to clipboard operation
taskcat copied to clipboard

Feature: Pre and Post Hooks

Open tonynv opened this issue 6 years ago • 8 comments

tests:
    sometest:
     parameter_input: 
     template_file: 
     pre_test: 
            s3path:
            localpath:
     post_test:
            s3path:
            localpath:

tonynv avatar Nov 14 '18 17:11 tonynv

@avattathil what's your ideal use-case? It's not clear from the proposed config. Caveat, I need more :coffee:

andrew-glenn avatar Nov 15 '18 15:11 andrew-glenn

@agamzn the basic use-case is to be able to run pre and post jobs. The scripts can be any language the os can support bash|python|curl|some endpoint essentially asubprocess.call

Here are some example:

pre_test:

  • setup boto profile
  • set env variables
  • do a pip upgrade
  • do a git pull to get the latest changes
  • set a notification that test a test is starting
  • check if license in override file is still valid (check against some api)
  • update override file before start
  • wait for some operation to complete before starting

post_test:

  • do a git commit
  • email taskcat_outputs
  • curl some endpoint to trigger a build (ex: docker hub)
  • test the stack by checking some end point of port
  • start another taskcat run
  • some other call back

ifs3pathis defined - taskcat will pull down and execute the script iflocalpathis defined - taskcat will execute the script locally

Also update the initial spec with some added context

tonynv avatar Nov 16 '18 02:11 tonynv

I would like to see this feature as well. I'm looking into use taskcat to test templates as part of a process to populate/update Service Catalog offerings. I would like to also use taskcat to test the results of a template being deployed.

This feature would allow me to test the assumptions of a service catalog offering are successful. e.g: If I have a Service Catalog offering to provision a WordPress site I should be able to hit the WordPress site using the ALB created by the template.

kddejong avatar Jan 09 '19 21:01 kddejong

@kddejong - do you expect to use python or bash?

andrew-glenn avatar Jan 09 '19 21:01 andrew-glenn

For us we would prefer Python.

kddejong avatar Jan 09 '19 23:01 kddejong

I'm also interested in this feature. But mine is a bit different. I'm not sure my requirement can be considered the same as this request.

I would like to insert some customized operation after taskcat successfully completed the stack creation but before taskcat tries to delete the whole stack.

My use case is that I have my product template run my own application inside the EC2 provisioned by the template and my template will automatically attach a few EBS to the EC2 instance which will be actually used by my application running inside the EC2. So when taskcat completes the creation, EBS are attached, and taskcat will fail when try to delete the whole stack because EBS prevent themselves being deleted due to the attachment.

So it would be great that I can inject some customized operation before taskcat tries to destroy the whole set of resources after creation success. Or it would also be helpful if I can specify which resource can be force removed by the automated deletion done by taskcat after successful creation.

zliu avatar Dec 23 '19 06:12 zliu

@zliu - Your use case fits this feature request. :)

The intention is that post-hooks would indeed run prior to stack deletion. Our original use case (team side) was more comprehensive testing - ie - making sure a certain port is open, or an application responds in a specific way.

andrew-glenn avatar Dec 23 '19 15:12 andrew-glenn

tonynv -> me

andrew-glenn avatar Dec 30 '20 22:12 andrew-glenn