mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
cleanup redundant code of TestEndpoints
(#6022)
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
This commit is contained in:
parent
4c648eddf4
commit
8744afdd1e
|
@ -224,22 +224,13 @@ func TestEndpoints(t *testing.T) {
|
||||||
test_metric1{foo="boo"} 1+0x100
|
test_metric1{foo="boo"} 1+0x100
|
||||||
test_metric2{foo="boo"} 1+0x100
|
test_metric2{foo="boo"} 1+0x100
|
||||||
`)
|
`)
|
||||||
if err != nil {
|
testutil.Ok(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer suite.Close()
|
defer suite.Close()
|
||||||
|
|
||||||
if err := suite.Run(); err != nil {
|
testutil.Ok(t, suite.Run())
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
var algr rulesRetrieverMock
|
|
||||||
algr.testing = t
|
|
||||||
algr.AlertingRules()
|
|
||||||
algr.RuleGroups()
|
|
||||||
|
|
||||||
t.Run("local", func(t *testing.T) {
|
t.Run("local", func(t *testing.T) {
|
||||||
var algr rulesRetrieverMock
|
var algr rulesRetrieverMock
|
||||||
algr.testing = t
|
algr.testing = t
|
||||||
|
@ -271,19 +262,13 @@ func TestEndpoints(t *testing.T) {
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
u, err := url.Parse(server.URL)
|
u, err := url.Parse(server.URL)
|
||||||
if err != nil {
|
testutil.Ok(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
al := promlog.AllowedLevel{}
|
al := promlog.AllowedLevel{}
|
||||||
if err := al.Set("debug"); err != nil {
|
testutil.Ok(t, al.Set("debug"))
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
af := promlog.AllowedFormat{}
|
af := promlog.AllowedFormat{}
|
||||||
if err := af.Set("logfmt"); err != nil {
|
testutil.Ok(t, af.Set("logfmt"))
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
promlogConfig := promlog.Config{
|
promlogConfig := promlog.Config{
|
||||||
Level: &al,
|
Level: &al,
|
||||||
|
@ -294,7 +279,6 @@ func TestEndpoints(t *testing.T) {
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
defer os.RemoveAll(dbDir)
|
defer os.RemoveAll(dbDir)
|
||||||
|
|
||||||
testutil.Ok(t, err)
|
|
||||||
remote := remote.NewStorage(promlog.New(&promlogConfig), prometheus.DefaultRegisterer, func() (int64, error) {
|
remote := remote.NewStorage(promlog.New(&promlogConfig), prometheus.DefaultRegisterer, func() (int64, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}, dbDir, 1*time.Second)
|
}, dbDir, 1*time.Second)
|
||||||
|
@ -308,9 +292,7 @@ func TestEndpoints(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
testutil.Ok(t, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var algr rulesRetrieverMock
|
var algr rulesRetrieverMock
|
||||||
algr.testing = t
|
algr.testing = t
|
||||||
|
|
Loading…
Reference in a new issue