Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Add recent logs test to Lats
Browse files Browse the repository at this point in the history
- Also includes cf cli in loggregator-acceptance-tests job spec

[#109838452]

Signed-off-by: Sam Nelson <snelson@pivotal.io>
  • Loading branch information
Nino Khodabandeh authored and Sam Nelson committed Sep 1, 2016
1 parent 86de531 commit 05c4de3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jobs/loggregator-acceptance-tests/spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: "The loggregator acceptance tests."
packages:
- golang1.7
- loggregator-acceptance-tests

- cli
templates:
run.erb: bin/run
config.json.erb: bin/config.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'json'

config = {
"AppDomain" => properties.system_domain,
"DopplerEndpoint" => "wss://doppler." + properties.system_domain + ":4443",
"SkipSSLVerify" => properties.ssl.skip_cert_verify,
"DropsondePort" => properties.metron_agent.dropsonde_incoming_port,
Expand Down
3 changes: 2 additions & 1 deletion jobs/loggregator-acceptance-tests/templates/run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

set -e

CLI_PATH=/var/vcap/packages/cli/bin
export GOROOT=$(readlink -nf /var/vcap/packages/golang1.7)
export PATH=${GOROOT}/bin:${PATH}
export PATH=${GOROOT}/bin:${CLI_PATH}:${PATH}

export GOPATH=/var/vcap/packages/loggregator-acceptance-tests
export PATH=${GOPATH}/bin:${PATH}
Expand Down
1 change: 1 addition & 0 deletions src/lats/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

type TestConfig struct {
AppDomain string
DopplerEndpoint string
SkipSSLVerify bool

Expand Down
48 changes: 48 additions & 0 deletions src/lats/logs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package lats_test

import (
"crypto/tls"
"lats/helpers"
"strings"
"time"

"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry/noaa/consumer"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

const (
cfSetupTimeOut = 10 * time.Second
cfPushTimeOut = 2 * time.Minute
defaultMemoryLimit = "256MB"
)

var _ = Describe("Logs", func() {
It("gets through recent logs", func() {

Expect(cf.Cf("api", "api."+config.AppDomain, "--skip-ssl-validation").Wait(cfSetupTimeOut)).To(Exit(0))
Expect(cf.Cf("auth", config.AdminUser, config.AdminPassword).Wait(cfSetupTimeOut)).To(Exit(0))
Expect(cf.Cf("create-org", "lats").Wait(cfSetupTimeOut)).To(Exit(0))
Expect(cf.Cf("create-space", "-o", "lats", "lats").Wait(cfSetupTimeOut)).To(Exit(0))
Expect(cf.Cf("target", "-o", "lats", "-s", "lats").Wait(cfSetupTimeOut)).To(Exit(0))
Expect(cf.Cf("push", "lumberjack", "--no-start",
"-b", "go_buildpack",
"-m", defaultMemoryLimit,
"-p", "../tools/lumberjack",
"-d", config.AppDomain).Wait(cfPushTimeOut)).To(Exit(0))

sess := cf.Cf("app", "lumberjack", "--guid")
Expect(sess.Wait(cfSetupTimeOut)).To(Exit(0))
appGuid := strings.TrimSpace(string(sess.Out.Contents()))

tlsConfig := &tls.Config{InsecureSkipVerify: true}
consumer := consumer.New(config.DopplerEndpoint, tlsConfig, nil)

token := helpers.GetAuthToken()
envelopes, err := consumer.RecentLogs(appGuid, token)
Expect(err).NotTo(HaveOccurred())
Expect(envelopes).ToNot(BeEmpty())
})
})

0 comments on commit 05c4de3

Please sign in to comment.