github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/builds_test.go (about)

     1  package tests
     2  
     3  import (
     4  	"github.com/deis/workflow-e2e/tests/cmd"
     5  	"github.com/deis/workflow-e2e/tests/cmd/apps"
     6  	"github.com/deis/workflow-e2e/tests/cmd/auth"
     7  	"github.com/deis/workflow-e2e/tests/cmd/builds"
     8  	"github.com/deis/workflow-e2e/tests/model"
     9  	"github.com/deis/workflow-e2e/tests/settings"
    10  	"github.com/deis/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  				// quay.io gives a "permission denied" 400 error
    84  				nonexistentImage = "quay.io/deis/nonexistent:dummy"
    85  				sess, err = cmd.Start("deis pull --app=%s %s", &user, app.Name, nonexistentImage)
    86  				Expect(err).NotTo(HaveOccurred())
    87  				Eventually(sess).Should(Say("Creating build..."))
    88  				Eventually(sess.Err).Should(Say("Permission Denied attempting to pull image"))
    89  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Exit(1))
    90  
    91  				// test that the old rc is not deleted after a failed build
    92  				procsListing := listProcs(user, app, "").Out.Contents()
    93  				procs := scrapeProcs(app.Name, procsListing)
    94  				Expect(len(procs)).To(Equal(1))
    95  			})
    96  
    97  			Specify("that user can create multiple builds of that app with DEPLOY_BATCHES set to 5", func() {
    98  				builds.Pull(user, app)
    99  
   100  				// scale to 11
   101  				sess, err := cmd.Start("deis ps:scale cmd=11 --app=%s", &user, app.Name)
   102  				Eventually(sess).Should(Say("Scaling processes... but first,"))
   103  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say(`done in \d+s`))
   104  				Eventually(sess).Should(Say("=== %s Processes", app.Name))
   105  				Expect(err).NotTo(HaveOccurred())
   106  				Eventually(sess).Should(Exit(0))
   107  
   108  				// configure 5 pods being rolled at once
   109  				sess, err = cmd.Start("deis config:set -a %s DEPLOY_BATCHES=5", &user, app.Name)
   110  				Expect(err).NotTo(HaveOccurred())
   111  				Eventually(sess).Should(Say("Creating config"))
   112  				Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Config", app.Name))
   113  				Eventually(sess).Should(Say(`DEPLOY_BATCHES\s+5`))
   114  				Expect(err).NotTo(HaveOccurred())
   115  				Eventually(sess).Should(Exit(0))
   116  
   117  			})
   118  
   119  		})
   120  
   121  		Context("who owns an existing app that has already been deployed", func() {
   122  
   123  			var app model.App
   124  
   125  			BeforeEach(func() {
   126  				app = apps.Create(user, "--no-remote")
   127  				builds.Create(user, app)
   128  			})
   129  
   130  			AfterEach(func() {
   131  				apps.Destroy(user, app)
   132  			})
   133  
   134  			Specify("that user can list that app's builds", func() {
   135  				sess, err := cmd.Start("deis builds:list -a %s", &user, app.Name)
   136  				Eventually(sess).Should(Say(uuidRegExp))
   137  				Eventually(sess).Should(Exit(0))
   138  				Expect(err).NotTo(HaveOccurred())
   139  			})
   140  
   141  			Specify("that user can create a new build of that app from an existing image", func() {
   142  				builds.Create(user, app)
   143  			})
   144  
   145  			Specify("that user can create a new build of that app from an existing image using `deis pull`", func() {
   146  				builds.Pull(user, app)
   147  			})
   148  
   149  		})
   150  
   151  	})
   152  
   153  })