当前位置: 首页>>代码示例>>Golang>>正文


Golang metrics.MetricsGrabber类代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/metrics.MetricsGrabber的典型用法代码示例。如果您正苦于以下问题:Golang MetricsGrabber类的具体用法?Golang MetricsGrabber怎么用?Golang MetricsGrabber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MetricsGrabber类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

import (
	"strings"

	"k8s.io/kubernetes/pkg/api/v1"
	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
	"k8s.io/kubernetes/pkg/metrics"
	"k8s.io/kubernetes/test/e2e/framework"

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

var _ = framework.KubeDescribe("MetricsGrabber", func() {
	f := framework.NewDefaultFramework("metrics-grabber")
	var c clientset.Interface
	var grabber *metrics.MetricsGrabber
	BeforeEach(func() {
		var err error
		c = f.ClientSet
		framework.ExpectNoError(err)
		grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true)
		framework.ExpectNoError(err)
	})

	It("should grab all metrics from API server.", func() {
		By("Connecting to /metrics endpoint")
		response, err := grabber.GrabFromApiServer()
		framework.ExpectNoError(err)
		Expect(response).NotTo(BeEmpty())
	})
开发者ID:kubernetes,项目名称:kubernetes,代码行数:30,代码来源:metrics_grabber_test.go

示例2: checkMetrics

}

func checkMetrics(response metrics.Metrics, assumedMetrics map[string][]string) {
	invalidLabels := make(map[string]sets.String)
	unknownLabels := make(map[string]sets.String)
	validateLabelSet(metrics.CommonMetrics, response, invalidLabels, unknownLabels)
	validateLabelSet(assumedMetrics, response, invalidLabels, unknownLabels)

	Expect(unknownLabels).To(BeEmpty())
	Expect(invalidLabels).To(BeEmpty())
}

var _ = Describe("MetricsGrabber", func() {
	framework := NewFramework("metrics-grabber")
	var c *client.Client
	var grabber *metrics.MetricsGrabber
	BeforeEach(func() {
		var err error
		c = framework.Client
		expectNoError(err)
		grabber, err = metrics.NewMetricsGrabber(c, true, true, true, true)
		expectNoError(err)
	})

	It("should grab all metrics from API server.", func() {
		By("Connecting to /metrics endpoint")
		unknownMetrics := sets.NewString()
		response, err := grabber.GrabFromApiServer(unknownMetrics)
		expectNoError(err)
		Expect(unknownMetrics).To(BeEmpty())
开发者ID:michaelcoyote,项目名称:kubernetes,代码行数:30,代码来源:metrics_grabber_test.go


注:本文中的k8s/io/kubernetes/pkg/metrics.MetricsGrabber类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。