basic.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package elasticsearch
  14. import (
  15. "time"
  16. "k8s.io/kubernetes/test/e2e/framework"
  17. e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
  18. instrumentation "k8s.io/kubernetes/test/e2e/instrumentation/common"
  19. "k8s.io/kubernetes/test/e2e/instrumentation/logging/utils"
  20. "github.com/onsi/ginkgo"
  21. )
  22. var _ = instrumentation.SIGDescribe("Cluster level logging using Elasticsearch [Feature:Elasticsearch]", func() {
  23. f := framework.NewDefaultFramework("es-logging")
  24. ginkgo.BeforeEach(func() {
  25. // TODO: For now assume we are only testing cluster logging with Elasticsearch
  26. // on GCE. Once we are sure that Elasticsearch cluster level logging
  27. // works for other providers we should widen this scope of this test.
  28. e2eskipper.SkipUnlessProviderIs("gce")
  29. })
  30. ginkgo.It("should check that logs from containers are ingested into Elasticsearch", func() {
  31. ingestionInterval := 10 * time.Second
  32. ingestionTimeout := 10 * time.Minute
  33. p, err := newEsLogProvider(f)
  34. framework.ExpectNoError(err, "Failed to create Elasticsearch logs provider")
  35. err = p.Init()
  36. defer p.Cleanup()
  37. framework.ExpectNoError(err, "Failed to init Elasticsearch logs provider")
  38. err = utils.EnsureLoggingAgentDeployment(f, p.LoggingAgentName())
  39. framework.ExpectNoError(err, "Fluentd deployed incorrectly")
  40. pod, err := utils.StartAndReturnSelf(utils.NewRepeatingLoggingPod("synthlogger", "test"), f)
  41. framework.ExpectNoError(err, "Failed to start a pod")
  42. ginkgo.By("Waiting for logs to ingest")
  43. c := utils.NewLogChecker(p, utils.UntilFirstEntry, utils.JustTimeout, pod.Name())
  44. err = utils.WaitForLogs(c, ingestionInterval, ingestionTimeout)
  45. framework.ExpectNoError(err)
  46. })
  47. })