<commit_before>package acceptance_test

import (
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
	"time"

	acceptance "github.com/cloudfoundry/bosh-bootloader/acceptance-tests"
	"github.com/cloudfoundry/bosh-bootloader/testhelpers"

	"github.com/cloudfoundry/bosh-bootloader/acceptance-tests/actors"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("concourse deployment test", func() {
	var (
		bbl           actors.BBL
		state         acceptance.State
		lbURL         string
		configuration acceptance.Config
		boshCLI       actors.BOSHCLI
		sshSession    *gexec.Session
		username      string
		password      string
		address       string
		caCertPath    string
	)

	BeforeEach(func() {
		var err error
		configuration, err = acceptance.LoadConfig()
		Expect(err).NotTo(HaveOccurred())

		bbl = actors.NewBBL(configuration.StateFileDir, pathToBBL, configuration, "concourse-env")
		state = acceptance.NewState(configuration.StateFileDir)

		session := bbl.Up("--name", bbl.PredefinedEnvID())
		Eventually(session, 40*time.Minute).Should(gexec.Exit(0))

		certPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_CERT)
		Expect(err).NotTo(HaveOccurred())

		keyPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_KEY)
		Expect(err).NotTo(HaveOccurred())

		session = bbl.CreateLB("concourse", certPath, keyPath, "")
		Eventually(session, 10*time.Minute).Should(gexec.Exit(0))

		lbURL, err = actors.LBURL(configuration, bbl, state)
		Expect(err).NotTo(HaveOccurred())

		boshCLI = actors.NewBOSHCLI()

		username = bbl.DirectorUsername()
		password = bbl.DirectorPassword()
		address = bbl.DirectorAddress()
		caCertPath = bbl.DirectorCACert()
	})

	AfterEach(func() {
		if sshSession != nil {
			boshCLI.DeleteDeployment(address, caCertPath, username, password, "concourse")
			sshSession.Interrupt()
			Eventually(sshSession, "5s").Should(gexec.Exit())
		}
		session := bbl.Destroy()
		Eventually(session, 10*time.Minute).Should(gexec.Exit())
	})

	It("is able to deploy concourse and teardown infrastructure", func() {
		By("creating an ssh tunnel to the director in print-env", func() {
			sshSession = bbl.StartSSHTunnel()
		})

		By("uploading stemcell", func() {
			err := boshCLI.UploadStemcell(address, caCertPath, username, password, configuration.StemcellPath)
			Expect(err).NotTo(HaveOccurred())
		})

		By("running bosh deploy and checking all the vms are running", func() {
			err := boshCLI.Deploy(address, caCertPath, username, password, "concourse",
				fmt.Sprintf("%s/concourse-deployment.yml", configuration.ConcourseDeploymentPath),
				"concourse-vars.yml",
				[]string{fmt.Sprintf("%s/operations/%s.yml", configuration.ConcourseDeploymentPath, configuration.IAAS)},
				map[string]string{"domain": lbURL},<commit_msg>bump timeout for deleting deployments<commit_after>package acceptance_test

import (
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
	"time"

	acceptance "github.com/cloudfoundry/bosh-bootloader/acceptance-tests"
	"github.com/cloudfoundry/bosh-bootloader/testhelpers"

	"github.com/cloudfoundry/bosh-bootloader/acceptance-tests/actors"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("concourse deployment test", func() {
	var (
		bbl           actors.BBL
		state         acceptance.State
		lbURL         string
		configuration acceptance.Config
		boshCLI       actors.BOSHCLI
		sshSession    *gexec.Session
		username      string
		password      string
		address       string
		caCertPath    string
	)

	BeforeEach(func() {
		var err error
		configuration, err = acceptance.LoadConfig()
		Expect(err).NotTo(HaveOccurred())

		bbl = actors.NewBBL(configuration.StateFileDir, pathToBBL, configuration, "concourse-env")
		state = acceptance.NewState(configuration.StateFileDir)

		session := bbl.Up("--name", bbl.PredefinedEnvID())
		Eventually(session, 40*time.Minute).Should(gexec.Exit(0))

		certPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_CERT)
		Expect(err).NotTo(HaveOccurred())

		keyPath, err := testhelpers.WriteContentsToTempFile(testhelpers.BBL_KEY)
		Expect(err).NotTo(HaveOccurred())

		session = bbl.CreateLB("concourse", certPath, keyPath, "")
		Eventually(session, 10*time.Minute).Should(gexec.Exit(0))

		lbURL, err = actors.LBURL(configuration, bbl, state)
		Expect(err).NotTo(HaveOccurred())

		boshCLI = actors.NewBOSHCLI()

		username = bbl.DirectorUsername()
		password = bbl.DirectorPassword()
		address = bbl.DirectorAddress()
		caCertPath = bbl.DirectorCACert()
	})

	AfterEach(func() {
		if sshSession != nil {
			boshCLI.DeleteDeployment(address, caCertPath, username, password, "concourse")
			sshSession.Interrupt()
			Eventually(sshSession, "10s").Should(gexec.Exit())
		}
		session := bbl.Destroy()
		Eventually(session, 10*time.Minute).Should(gexec.Exit())
	})

	It("is able to deploy concourse and teardown infrastructure", func() {
		By("creating an ssh tunnel to the director in print-env", func() {
			sshSession = bbl.StartSSHTunnel()
		})

		By("uploading stemcell", func() {
			err := boshCLI.UploadStemcell(address, caCertPath, username, password, configuration.StemcellPath)
			Expect(err).NotTo(HaveOccurred())
		})

		By("running bosh deploy and checking all the vms are running", func() {
			err := boshCLI.Deploy(address, caCertPath, username, password, "concourse",
				fmt.Sprintf("%s/concourse-deployment.yml", configuration.ConcourseDeploymentPath),
				"concourse-vars.yml",
				[]string{fmt.Sprintf("%s/operations/%s.yml", configuration.ConcourseDeploymentPath, configuration.IAAS)},
				map[string]string{"domain": lbURL},
{'fraction_non_alphanumeric': 0.13260831433081915, 'fraction_numerical': 0.00333274864058937, 'mean_word_length': 4.617733990147784, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7474497', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1898, 'n_words': 331}