當前位置: 首頁>>代碼示例>>Golang>>正文


Golang lagertest.NewTestLogger函數代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/lager/lagertest.NewTestLogger函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewTestLogger函數的具體用法?Golang NewTestLogger怎麽用?Golang NewTestLogger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewTestLogger函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewETCDHelper

func NewETCDHelper(serializationFormat *format.Format, cryptor encryption.Cryptor, client etcd.StoreClient, clock clock.Clock) *ETCDHelper {
	logger := lagertest.NewTestLogger("etcd-helper")

	return &ETCDHelper{
		client:     client,
		format:     serializationFormat,
		serializer: format.NewSerializer(cryptor),
		logger:     logger,
		clock:      clock,
	}
}
開發者ID:cfibmers,項目名稱:bbs,代碼行數:11,代碼來源:etcd_helper.go

示例2: Start

func Start(bin, initBin, nstarBin, dadooBin, grootfsBin, rootfs, tarBin string, argv ...string) *RunningGarden {
	runner := NewGardenRunner(bin, initBin, nstarBin, dadooBin, grootfsBin, rootfs, tarBin, "unix", fmt.Sprintf("/tmp/garden_%d.sock", GinkgoParallelNode()), argv...)

	r := &RunningGarden{
		runner:   runner,
		DepotDir: runner.DepotDir,

		DataDir:   DataDir,
		GraphPath: runner.GraphPath,
		Tmpdir:    runner.TmpDir,
		logger:    lagertest.NewTestLogger("garden-runner"),

		debugIP:   runner.DebugIp,
		debugPort: runner.DebugPort,

		Client: client.New(connection.New(runner.Network, runner.Addr)),
	}

	r.process = ifrit.Invoke(r.runner)
	r.Pid = runner.Cmd.Process.Pid

	return r
}
開發者ID:cloudfoundry,項目名稱:guardian,代碼行數:23,代碼來源:runner.go

示例3:

	BeforeEach(func() {
		fakeSpecParser = new(fakes.FakeSpecParser)
		fakeSubnetPool = new(fake_subnet_pool.FakePool)
		fakeConfigCreator = new(fakes.FakeConfigCreator)
		fakeConfigStore = new(fakes.FakeConfigStore)
		fakePortForwarder = new(fakes.FakePortForwarder)
		fakePortPool = new(fakes.FakePortPool)
		fakeFirewallOpener = new(fakes.FakeFirewallOpener)
		fakeConfigurer = new(fakes.FakeConfigurer)

		containerSpec = garden.ContainerSpec{
			Handle:  "some-handle",
			Network: "1.2.3.4/30",
		}

		logger = lagertest.NewTestLogger("test")
		networker = kawasaki.New(
			fakeSpecParser,
			fakeSubnetPool,
			fakeConfigCreator,
			fakeConfigStore,
			fakeConfigurer,
			fakePortPool,
			fakePortForwarder,
			fakeFirewallOpener,
		)

		ip, subnet, err := net.ParseCIDR("123.123.123.12/24")
		Expect(err).NotTo(HaveOccurred())
		networkConfig = kawasaki.NetworkConfig{
			HostIntf:        "banana-iface",
開發者ID:cloudfoundry,項目名稱:guardian,代碼行數:31,代碼來源:networker_test.go

示例4:

		mountDir               string
		backingFile            *os.File
		logger                 lager.Logger
	)

	Describe("DiffSize", func() {
		const quotaMB = 10

		BeforeEach(func() {
			fakeAUFSDiffPathFinder = new(fakes.FakeAUFSDiffPathFinder)

			diffSizer = &quota_manager.AUFSDiffSizer{
				fakeAUFSDiffPathFinder,
			}

			logger = lagertest.NewTestLogger("AUFSQuotaManager-test")

			var err error
			mountDir, err = ioutil.TempDir("", "quota_manager_test")
			Expect(err).NotTo(HaveOccurred())

			backingFile, err = ioutil.TempFile("", "quota_manager_backing_store")
			Expect(err).NotTo(HaveOccurred())

			cmd := exec.Command("truncate", "-s", fmt.Sprintf("%dM", quotaMB), backingFile.Name())
			cmd.Stdout = GinkgoWriter
			cmd.Stderr = GinkgoWriter
			Expect(cmd.Run()).To(Succeed())

			cmd = exec.Command("mkfs.ext4", "-F", backingFile.Name())
			cmd.Stdout = GinkgoWriter
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:31,代碼來源:aufs_diff_sizer_linux_test.go

示例5:

	"github.com/onsi/gomega/gbytes"
)

const uuid_regex = `^[[:xdigit:]]{8}(-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}$`

// 64-bit random hexadecimal string
const b3_id_regex = `^[[:xdigit:]]{16}$`

var _ = Describe("Headers", func() {
	Describe("SetVcapRequestIdHeader", func() {
		var (
			logger lager.Logger
			req    *http.Request
		)
		BeforeEach(func() {
			logger = lagertest.NewTestLogger("headers-test")
			var err error
			req, err = http.NewRequest("GET", "test.endpoint", nil)
			Expect(err).ToNot(HaveOccurred())
		})
		JustBeforeEach(func() {
			commonhttp.SetVcapRequestIdHeader(req, logger)
		})

		Context("when X-Vcap-Request-Id is not set", func() {
			It("sets the X-Vcap-Request-Id header", func() {
				reqID := req.Header.Get(commonhttp.VcapRequestIdHeader)
				Expect(reqID).ToNot(BeEmpty())
				Expect(reqID).To(MatchRegexp(uuid_regex))
			})
開發者ID:cloudfoundry,項目名稱:gorouter,代碼行數:30,代碼來源:headers_test.go

示例6:

		natsClient   *nats.Conn
		startMsgChan chan struct{}

		logger lager.Logger
	)

	BeforeEach(func() {
		natsPort = test_util.NextAvailPort()

		natsRunner = test_util.NewNATSRunner(int(natsPort))
		natsRunner.Start()
		natsClient = natsRunner.MessageBus

		registry = new(fakes.FakeRegistryInterface)

		logger = lagertest.NewTestLogger("mbus-test")

		startMsgChan = make(chan struct{})

		subOpts = &mbus.SubscriberOpts{
			ID: "Fake-Subscriber-ID",
			MinimumRegisterIntervalInSeconds: 60,
			PruneThresholdInSeconds:          120,
		}

		sub = mbus.NewSubscriber(logger, natsClient, registry, startMsgChan, subOpts)
	})

	AfterEach(func() {
		if natsRunner != nil {
			natsRunner.Stop()
開發者ID:cloudfoundry,項目名稱:gorouter,代碼行數:31,代碼來源:subscriber_test.go

示例7:

	"code.cloudfoundry.org/voldriver"
	"code.cloudfoundry.org/volman/vollocal"
	"code.cloudfoundry.org/volman/volmanfakes"

	"code.cloudfoundry.org/clock/fakeclock"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"code.cloudfoundry.org/voldriver/voldriverfakes"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"
)

var _ = Describe("Volman", func() {
	var (
		logger = lagertest.NewTestLogger("client-test")

		fakeDriverFactory *volmanfakes.FakeDriverFactory
		fakeDriver        *voldriverfakes.FakeDriver
		fakeClock         *fakeclock.FakeClock

		scanInterval time.Duration

		driverRegistry vollocal.DriverRegistry
		driverSyncer   vollocal.DriverSyncer

		process ifrit.Process
	)

	BeforeEach(func() {
		fakeDriverFactory = new(volmanfakes.FakeDriverFactory)
開發者ID:cloudfoundry-incubator,項目名稱:volman,代碼行數:30,代碼來源:client_local_test.go

示例8:

			pollErrChan chan error

			pollURL                *url.URL
			originalUploadResponse *http.Response
			closeChan              chan struct{}
		)

		BeforeEach(func() {
			closeChan = make(chan struct{})
		})

		JustBeforeEach(func() {
			httpClient := &http.Client{
				Transport: transport,
			}
			u = ccclient.NewPoller(lagertest.NewTestLogger("test"), httpClient, 10*time.Millisecond)
			pollErrChan = make(chan error, 1)
			go func(pec chan error) {
				defer GinkgoRecover()
				pec <- u.Poll(pollURL, originalUploadResponse, closeChan)
			}(pollErrChan)
		})

		Context("when the initial response is invalid", func() {
			BeforeEach(func() {
				originalUploadResponse = responseWithBody("garbage")
			})

			It("returns an error", func() {
				Eventually(pollErrChan).Should(Receive(HaveOccurred()))
			})
開發者ID:cloudfoundry,項目名稱:cc-uploader,代碼行數:31,代碼來源:poller_test.go

示例9:

		fakeBackingStoreMgr = new(fakes.FakeBackingStoreMgr)
		fakeRetrier = new(fakes.FakeRetrier)
		fakeUnmount = func(path string) error {
			return nil
		}
	})

	JustBeforeEach(func() {
		driver = &aufs.QuotaedDriver{
			GraphDriver:     fakeGraphDriver,
			Unmount:         fakeUnmount,
			BackingStoreMgr: fakeBackingStoreMgr,
			LoopMounter:     fakeLoopMounter,
			Retrier:         fakeRetrier,
			RootPath:        rootPath,
			Logger:          lagertest.NewTestLogger("test"),
		}
	})

	Describe("GetQuotaed", func() {
		It("should create a backing store file", func() {
			id := "banana-id"
			quota := int64(12 * 1024)

			_, err := driver.GetQuotaed(id, "", quota)
			Expect(err).NotTo(HaveOccurred())

			Expect(fakeBackingStoreMgr.CreateCallCount()).To(Equal(1))
			gottenId, gottenQuota := fakeBackingStoreMgr.CreateArgsForCall(0)
			Expect(gottenId).To(Equal(id))
			Expect(gottenQuota).To(Equal(quota))
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:31,代碼來源:aufs_test.go

示例10:

			return nil
		}

		namespacer = &rootfs_provider.UidNamespacer{
			Translator: translator,
		}
	})

	It("returns a cache key describing the namespacer", func() {
		translator.CacheKeyReturns("namespaced-2")
		Expect(namespacer.CacheKey()).To(Equal("namespaced-2"))
	})

	It("translate the root directory", func() {
		err := namespacer.Namespace(lagertest.NewTestLogger("test"), rootfs)

		info, err := os.Stat(rootfs)
		Expect(err).NotTo(HaveOccurred())

		Expect(translated).To(ContainElement(translation{
			path:    rootfs,
			size:    info.Size(),
			mode:    info.Mode(),
			modTime: info.ModTime(),
			err:     nil,
		}))
	})

	It("translates all of the uids", func() {
		err := namespacer.Namespace(lagertest.NewTestLogger("test"), rootfs)
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:30,代碼來源:namespace_test.go

示例11:

	. "github.com/onsi/gomega"
	"github.com/opencontainers/runc/libcontainer/user"
	"github.com/opencontainers/runtime-spec/specs-go"
)

var _ = Describe("Execer", func() {
	var (
		logger *lagertest.TestLogger

		execPreparer *fakes.FakeExecPreparer
		execRunner   *fakes.FakeExecRunner
		execer       *runrunc.Execer
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		execRunner = new(fakes.FakeExecRunner)
		execPreparer = new(fakes.FakeExecPreparer)

		execer = runrunc.NewExecer(
			execPreparer,
			execRunner,
		)
	})

	It("runs the execRunner with the prepared process spec", func() {
		execPreparer.PrepareStub = func(log lager.Logger, bundlePath string, spec garden.ProcessSpec) (*runrunc.PreparedSpec, error) {
			return &runrunc.PreparedSpec{
				Process: specs.Process{
					Args: []string{spec.Path, bundlePath},
				},
開發者ID:cloudfoundry,項目名稱:guardian,代碼行數:31,代碼來源:exec_test.go

示例12:

			filename        string
			incomingRequest *http.Request
		)

		BeforeEach(func() {
			uploadURL, _ = url.Parse("http://example.com")
			filename = "filename"
			incomingRequest = createValidRequest()
		})

		Context("when not cancelling", func() {
			JustBeforeEach(func() {
				httpClient := &http.Client{
					Transport: transport,
				}
				u = ccclient.NewUploader(lagertest.NewTestLogger("test"), httpClient)
				response, uploadErr = u.Upload(uploadURL, filename, incomingRequest, make(chan struct{}))
			})

			Context("Validating the content length of the request", func() {
				BeforeEach(func() {
					transport = http.DefaultTransport
					filename = "filename"
					incomingRequest = &http.Request{}
				})

				It("fails early if the content length is 0", func() {
					Expect(response.StatusCode).To(Equal(http.StatusLengthRequired))

					Expect(uploadErr).To(HaveOccurred())
				})
開發者ID:cloudfoundry,項目名稱:cc-uploader,代碼行數:31,代碼來源:uploader_test.go

示例13:

		driverRegistry vollocal.DriverRegistry
		driverSyncer   vollocal.DriverSyncer
		purger         vollocal.MountPurger

		fakeDriverFactory *volmanfakes.FakeDriverFactory
		fakeDriver        *voldriverfakes.FakeDriver
		fakeClock         clock.Clock

		scanInterval time.Duration

		process ifrit.Process
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("mount-purger")

		driverRegistry = vollocal.NewDriverRegistry()

		purger = vollocal.NewMountPurger(logger, driverRegistry)
	})

	It("should succeed when there are no drivers", func() {
		err := purger.PurgeMounts(logger)
		Expect(err).NotTo(HaveOccurred())
	})

	Context("when there is a driver", func() {
		BeforeEach(func() {
			err := voldriver.WriteDriverSpec(logger, defaultPluginsDirectory, "fakedriver", "spec", []byte("http://0.0.0.0:8080"))
			Expect(err).NotTo(HaveOccurred())
開發者ID:cloudfoundry-incubator,項目名稱:volman,代碼行數:30,代碼來源:mount_purger_test.go

示例14:

			return filepath.Join(fakeCgroupDir, name, subsystem), nil
		}

		fakeRetrier.RunStub = func(fn func() error) error {
			return fn()
		}

		subject = stopper.New(fakeCgroupResolver, fakeKiller, fakeRetrier)
	})

	AfterEach(func() {
		os.RemoveAll(fakeCgroupDir)
	})

	It("does not send any signal to processes in the exceptions list", func() {
		Expect(subject.StopAll(lagertest.NewTestLogger("test"), "foo", []int{3, 5}, false)).To(Succeed())
		Expect(fakeKiller).To(HaveKilled(0, syscall.SIGTERM, 1, 9))
		Expect(fakeKiller).To(HaveKilled(1, syscall.SIGKILL, 1, 9))
	})

	Context("when the kill flag is true", func() {
		It("sends a KILL to all processes found in the cgroup", func() {
			Expect(subject.StopAll(lagertest.NewTestLogger("test"), "foo", nil, true)).To(Succeed())
			Expect(fakeKiller).To(HaveKilled(0, syscall.SIGKILL, 1, 3, 5, 9))
		})

		It("does not send TERM to processes found in the cgroup", func() {
			Expect(subject.StopAll(lagertest.NewTestLogger("test"), "foo", nil, true)).To(Succeed())
			Expect(fakeKiller).NotTo(HaveKilled(0, syscall.SIGTERM, 1, 3, 5, 9))
		})
	})
開發者ID:cloudfoundry,項目名稱:guardian,代碼行數:31,代碼來源:stopper_linux_test.go

示例15:

		fakeClock      *fakeclock.FakeClock

		pmn ifrit.Process
	)

	BeforeEach(func() {
		reportInterval = 100 * time.Millisecond

		fakeClock = fakeclock.NewFakeClock(time.Unix(123, 456))

		sender = fake.NewFakeMetricSender()
		dropsonde_metrics.Initialize(sender, nil)
	})

	JustBeforeEach(func() {
		pmn = ifrit.Invoke(metrics.NewPeriodicMetronNotifier(lagertest.NewTestLogger("test")))
	})

	AfterEach(func() {
		pmn.Signal(os.Interrupt)
		Eventually(pmn.Wait(), 2*time.Second).Should(Receive())
	})

	Context("when the metron notifier starts up", func() {
		It("should emit an event that BBS has started", func() {
			Eventually(func() uint64 {
				return sender.GetCounter("BBSMasterElected")
			}).Should(Equal(uint64(1)))
		})
	})
})
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:31,代碼來源:periodic_metron_notifier_test.go


注:本文中的code/cloudfoundry/org/lager/lagertest.NewTestLogger函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。