github.com/deiscc/workflow-e2e@v0.0.0-20181208071258-117299af888f/tests/builds_test.go (about)

     1  package tests
     2  
     3  import (
     4  	"github.com/deiscc/workflow-e2e/tests/cmd"
     5  	"github.com/deiscc/workflow-e2e/tests/cmd/apps"
     6  	"github.com/deiscc/workflow-e2e/tests/cmd/auth"
     7  	"github.com/deiscc/workflow-e2e/tests/cmd/builds"
     8  	"github.com/deiscc/workflow-e2e/tests/model"
     9  	"github.com/deiscc/workflow-e2e/tests/settings"
    10  	"github.com/deiscc/workflow-e2e/tests/util"
    11  
    12  	. "github.com/onsi/ginkgo"
    13  	. "github.com/onsi/gomega"
    14  	. "github.com/onsi/gomega/gbytes"
    15  	. "github.com/onsi/gomega/gexec"
    16  )
    17  
    18  var _ = Describe("deis builds", func() {
    19  
    20  	Context("with an existing user", func() {
    21  
    22  		uuidRegExp := `[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}`
    23  
    24  		var user model.User
    25  
    26  		BeforeEach(func() {
    27  			user = auth.RegisterAndLogin()
    28  		})
    29  
    30  		AfterEach(func() {
    31  			auth.Cancel(user)
    32  		})
    33  
    34  		Context("and an app that does not exist", func() {
    35  
    36  			bogusAppName := "bogus-app-name"
    37  
    38  			Specify("that user cannot create a build for that app", func() {
    39  				sess, err := cmd.Start("deis builds:create -a %s %s", &user, bogusAppName, builds.ExampleImage)
    40  				Eventually(sess.Err).Should(Say(util.PrependError(apps.ErrNoAppMatch)))
    41  				Expect(err).NotTo(HaveOccurred())
    42  				Eventually(sess).Should(Exit(1))
    43  			})
    44  
    45  		})
    46  
    47  		Context("who owns an existing app that has not been deployed", func() {
    48  
    49  			var app model.App
    50  
    51  			BeforeEach(func() {
    52  				app = apps.Create(user, "--no-remote")
    53  			})
    54  
    55  			AfterEach(func() {
    56  				apps.Destroy(user, app)
    57  			})
    58  
    59  			Specify("that user can list that app's builds", func() {
    60  				sess, err := cmd.Start("deis builds:list -a %s", &user, app.Name)
    61  				Eventually(sess).ShouldNot(Say(uuidRegExp))
    62  				Eventually(sess).Should(Exit(0))
    63  				Expect(err).NotTo(HaveOccurred())
    64  			})
    65  
    66  			Specify("that user can create a new build of that app from an existing image", func() {
    67  				builds.Create(user, app)
    68  			})
    69  
    70  			Specify("that user can create a new build of that app from an existing image using `deis pull`", func() {
    71  				builds.Pull(user, app)
    72  			})
    73  
    74  			Specify("that user can't create a new build of that app from a nonexistent image using `deis pull`", func() {
    75  				builds.Create(user, app)
    76  				// Docker Hub gives a "not found" 400 error
    77  				nonexistentImage := "deis/nonexistent:dummy"
    78  				sess, err := cmd.Start("deis pull --app=%s %s", &user, app.Name, nonexistentImage)
    79  				Expect(err).NotTo(HaveOccurred())
    80  				Eventually(sess).Should(Say("Creating build..."))
    81  				Eventually(sess.Err).Should(Say(`image .* not found`))
    82  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Exit(1))
    83  
    84  				// test that the old rc is not deleted after a failed build
    85  				procsListing := listProcs(user, app, "").Out.Contents()
    86  				procs := scrapeProcs(app.Name, procsListing)
    87  				Expect(len(procs)).To(Equal(1))
    88  			})
    89  
    90  			Specify("that user can create multiple builds of that app with DEPLOY_BATCHES set to 5", func() {
    91  				builds.Pull(user, app)
    92  
    93  				// scale to 11
    94  				sess, err := cmd.Start("deis ps:scale cmd=11 --app=%s", &user, app.Name)
    95  				Eventually(sess).Should(Say("Scaling processes... but first,"))
    96  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say(`done in \d+s`))
    97  				Eventually(sess).Should(Say("=== %s Processes", app.Name))
    98  				Expect(err).NotTo(HaveOccurred())
    99  				Eventually(sess).Should(Exit(0))
   100  
   101  				// configure 5 pods being rolled at once
   102  				sess, err = cmd.Start("deis config:set -a %s DEPLOY_BATCHES=5", &user, app.Name)
   103  				Expect(err).NotTo(HaveOccurred())
   104  				Eventually(sess).Should(Say("Creating config"))
   105  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Config", app.Name))
   106  				Eventually(sess).Should(Say(`DEPLOY_BATCHES\s+5`))
   107  				Expect(err).NotTo(HaveOccurred())
   108  				Eventually(sess).Should(Exit(0))
   109  
   110  			})
   111  
   112  		})
   113  
   114  		Context("who owns an existing app that has already been deployed", func() {
   115  
   116  			var app model.App
   117  
   118  			BeforeEach(func() {
   119  				app = apps.Create(user, "--no-remote")
   120  				builds.Create(user, app)
   121  			})
   122  
   123  			AfterEach(func() {
   124  				apps.Destroy(user, app)
   125  			})
   126  
   127  			Specify("that user can list that app's builds", func() {
   128  				sess, err := cmd.Start("deis builds:list -a %s", &user, app.Name)
   129  				Eventually(sess).Should(Say(uuidRegExp))
   130  				Eventually(sess).Should(Exit(0))
   131  				Expect(err).NotTo(HaveOccurred())
   132  			})
   133  
   134  			Specify("that user can create a new build of that app from an existing image", func() {
   135  				builds.Create(user, app)
   136  			})
   137  
   138  			Specify("that user can create a new build of that app from an existing image using `deis pull`", func() {
   139  				builds.Pull(user, app)
   140  			})
   141  
   142  		})
   143  
   144  	})
   145  
   146  })