From 5e1348b2696720506d9bda31d0d8fa40b5c34e0a Mon Sep 17 00:00:00 2001 From: an qin Date: Fri, 10 Jan 2020 17:28:06 +0800 Subject: [PATCH 1/2] Revert "Merge pull request #552 from qibobo/dev_qy_upgrade_prometheusgo" This reverts commit 12d173b43762eb52ccc43c4a5bd08312b89cdd9d, reversing changes made to bc8e77c49cec993f616aea6199af9d29328078c6. --- .gitmodules | 3 - src/autoscaler/healthendpoint/registrar.go | 7 +- .../metricscollector/fakes/fake_policy_db.go | 437 ++++++++++++++++++ .../operator/fakes/fake_policy_db.go | 437 ++++++++++++++++++ src/github.com/cespare/xxhash | 1 - src/github.com/prometheus/client_golang | 2 +- src/github.com/prometheus/client_model | 2 +- src/github.com/prometheus/common | 2 +- src/github.com/prometheus/procfs | 2 +- 9 files changed, 879 insertions(+), 14 deletions(-) create mode 100644 src/autoscaler/metricscollector/fakes/fake_policy_db.go create mode 100644 src/autoscaler/operator/fakes/fake_policy_db.go delete mode 160000 src/github.com/cespare/xxhash diff --git a/.gitmodules b/.gitmodules index f5b9d5f24..b1edbb550 100644 --- a/.gitmodules +++ b/.gitmodules @@ -148,9 +148,6 @@ [submodule "src/github.com/juju/ratelimit"] path = src/github.com/juju/ratelimit url = https://github.com/juju/ratelimit -[submodule "src/github.com/cespare/xxhash"] - path = src/github.com/cespare/xxhash - url = https://github.com/cespare/xxhash.git [submodule "src/github.com/jmoiron/sqlx"] path = src/github.com/jmoiron/sqlx url = https://github.com/jmoiron/sqlx diff --git a/src/autoscaler/healthendpoint/registrar.go b/src/autoscaler/healthendpoint/registrar.go index 04ed3ed69..905af190b 100644 --- a/src/autoscaler/healthendpoint/registrar.go +++ b/src/autoscaler/healthendpoint/registrar.go @@ -10,12 +10,7 @@ import ( func RegisterCollectors(registrar prometheus.Registerer, collectors []prometheus.Collector, includeDefault bool, logger lager.Logger) { if includeDefault { - err := registrar.Register(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{ - PidFn: func() (int, error) { - return os.Getpid(), nil - }, - Namespace: "", - })) + err := registrar.Register(prometheus.NewProcessCollector(os.Getpid(), "")) if err != nil { logger.Error("Failed to register process collector", err) } diff --git a/src/autoscaler/metricscollector/fakes/fake_policy_db.go b/src/autoscaler/metricscollector/fakes/fake_policy_db.go new file mode 100644 index 000000000..88a0f4769 --- /dev/null +++ b/src/autoscaler/metricscollector/fakes/fake_policy_db.go @@ -0,0 +1,437 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "autoscaler/db" + "autoscaler/healthendpoint" + "autoscaler/models" + "sync" + "time" + + "code.cloudfoundry.org/clock" +) + +type FakePolicyDB struct { + GetAppIdsStub func() (map[string]bool, error) + getAppIdsMutex sync.RWMutex + getAppIdsArgsForCall []struct{} + getAppIdsReturns struct { + result1 map[string]bool + result2 error + } + getAppIdsReturnsOnCall map[int]struct { + result1 map[string]bool + result2 error + } + GetAppPolicyStub func(appId string) (*models.ScalingPolicy, error) + getAppPolicyMutex sync.RWMutex + getAppPolicyArgsForCall []struct { + appId string + } + getAppPolicyReturns struct { + result1 *models.ScalingPolicy + result2 error + } + getAppPolicyReturnsOnCall map[int]struct { + result1 *models.ScalingPolicy + result2 error + } + RetrievePoliciesStub func() ([]*models.PolicyJson, error) + retrievePoliciesMutex sync.RWMutex + retrievePoliciesArgsForCall []struct{} + retrievePoliciesReturns struct { + result1 []*models.PolicyJson + result2 error + } + retrievePoliciesReturnsOnCall map[int]struct { + result1 []*models.PolicyJson + result2 error + } + CloseStub func() error + closeMutex sync.RWMutex + closeArgsForCall []struct{} + closeReturns struct { + result1 error + } + closeReturnsOnCall map[int]struct { + result1 error + } + EmitHealthMetricsStub func(h healthendpoint.Health, cclock clock.Clock, interval time.Duration) + emitHealthMetricsMutex sync.RWMutex + emitHealthMetricsArgsForCall []struct { + h healthendpoint.Health + cclock clock.Clock + interval time.Duration + } + DeletePolicyStub func(appId string) error + deletePolicyMutex sync.RWMutex + deletePolicyArgsForCall []struct { + appId string + } + deletePolicyReturns struct { + result1 error + } + deletePolicyReturnsOnCall map[int]struct { + result1 error + } + GetCustomMetricsCredsStub func(appId string) (string, string, error) + getCustomMetricsCredsMutex sync.RWMutex + getCustomMetricsCredsArgsForCall []struct { + appId string + } + getCustomMetricsCredsReturns struct { + result1 string + result2 string + result3 error + } + getCustomMetricsCredsReturnsOnCall map[int]struct { + result1 string + result2 string + result3 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakePolicyDB) GetAppIds() (map[string]bool, error) { + fake.getAppIdsMutex.Lock() + ret, specificReturn := fake.getAppIdsReturnsOnCall[len(fake.getAppIdsArgsForCall)] + fake.getAppIdsArgsForCall = append(fake.getAppIdsArgsForCall, struct{}{}) + fake.recordInvocation("GetAppIds", []interface{}{}) + fake.getAppIdsMutex.Unlock() + if fake.GetAppIdsStub != nil { + return fake.GetAppIdsStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.getAppIdsReturns.result1, fake.getAppIdsReturns.result2 +} + +func (fake *FakePolicyDB) GetAppIdsCallCount() int { + fake.getAppIdsMutex.RLock() + defer fake.getAppIdsMutex.RUnlock() + return len(fake.getAppIdsArgsForCall) +} + +func (fake *FakePolicyDB) GetAppIdsReturns(result1 map[string]bool, result2 error) { + fake.GetAppIdsStub = nil + fake.getAppIdsReturns = struct { + result1 map[string]bool + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppIdsReturnsOnCall(i int, result1 map[string]bool, result2 error) { + fake.GetAppIdsStub = nil + if fake.getAppIdsReturnsOnCall == nil { + fake.getAppIdsReturnsOnCall = make(map[int]struct { + result1 map[string]bool + result2 error + }) + } + fake.getAppIdsReturnsOnCall[i] = struct { + result1 map[string]bool + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppPolicy(appId string) (*models.ScalingPolicy, error) { + fake.getAppPolicyMutex.Lock() + ret, specificReturn := fake.getAppPolicyReturnsOnCall[len(fake.getAppPolicyArgsForCall)] + fake.getAppPolicyArgsForCall = append(fake.getAppPolicyArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("GetAppPolicy", []interface{}{appId}) + fake.getAppPolicyMutex.Unlock() + if fake.GetAppPolicyStub != nil { + return fake.GetAppPolicyStub(appId) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.getAppPolicyReturns.result1, fake.getAppPolicyReturns.result2 +} + +func (fake *FakePolicyDB) GetAppPolicyCallCount() int { + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + return len(fake.getAppPolicyArgsForCall) +} + +func (fake *FakePolicyDB) GetAppPolicyArgsForCall(i int) string { + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + return fake.getAppPolicyArgsForCall[i].appId +} + +func (fake *FakePolicyDB) GetAppPolicyReturns(result1 *models.ScalingPolicy, result2 error) { + fake.GetAppPolicyStub = nil + fake.getAppPolicyReturns = struct { + result1 *models.ScalingPolicy + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppPolicyReturnsOnCall(i int, result1 *models.ScalingPolicy, result2 error) { + fake.GetAppPolicyStub = nil + if fake.getAppPolicyReturnsOnCall == nil { + fake.getAppPolicyReturnsOnCall = make(map[int]struct { + result1 *models.ScalingPolicy + result2 error + }) + } + fake.getAppPolicyReturnsOnCall[i] = struct { + result1 *models.ScalingPolicy + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) RetrievePolicies() ([]*models.PolicyJson, error) { + fake.retrievePoliciesMutex.Lock() + ret, specificReturn := fake.retrievePoliciesReturnsOnCall[len(fake.retrievePoliciesArgsForCall)] + fake.retrievePoliciesArgsForCall = append(fake.retrievePoliciesArgsForCall, struct{}{}) + fake.recordInvocation("RetrievePolicies", []interface{}{}) + fake.retrievePoliciesMutex.Unlock() + if fake.RetrievePoliciesStub != nil { + return fake.RetrievePoliciesStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.retrievePoliciesReturns.result1, fake.retrievePoliciesReturns.result2 +} + +func (fake *FakePolicyDB) RetrievePoliciesCallCount() int { + fake.retrievePoliciesMutex.RLock() + defer fake.retrievePoliciesMutex.RUnlock() + return len(fake.retrievePoliciesArgsForCall) +} + +func (fake *FakePolicyDB) RetrievePoliciesReturns(result1 []*models.PolicyJson, result2 error) { + fake.RetrievePoliciesStub = nil + fake.retrievePoliciesReturns = struct { + result1 []*models.PolicyJson + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) RetrievePoliciesReturnsOnCall(i int, result1 []*models.PolicyJson, result2 error) { + fake.RetrievePoliciesStub = nil + if fake.retrievePoliciesReturnsOnCall == nil { + fake.retrievePoliciesReturnsOnCall = make(map[int]struct { + result1 []*models.PolicyJson + result2 error + }) + } + fake.retrievePoliciesReturnsOnCall[i] = struct { + result1 []*models.PolicyJson + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) Close() error { + fake.closeMutex.Lock() + ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] + fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{}) + fake.recordInvocation("Close", []interface{}{}) + fake.closeMutex.Unlock() + if fake.CloseStub != nil { + return fake.CloseStub() + } + if specificReturn { + return ret.result1 + } + return fake.closeReturns.result1 +} + +func (fake *FakePolicyDB) CloseCallCount() int { + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + return len(fake.closeArgsForCall) +} + +func (fake *FakePolicyDB) CloseReturns(result1 error) { + fake.CloseStub = nil + fake.closeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) CloseReturnsOnCall(i int, result1 error) { + fake.CloseStub = nil + if fake.closeReturnsOnCall == nil { + fake.closeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.closeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) EmitHealthMetrics(h healthendpoint.Health, cclock clock.Clock, interval time.Duration) { + fake.emitHealthMetricsMutex.Lock() + fake.emitHealthMetricsArgsForCall = append(fake.emitHealthMetricsArgsForCall, struct { + h healthendpoint.Health + cclock clock.Clock + interval time.Duration + }{h, cclock, interval}) + fake.recordInvocation("EmitHealthMetrics", []interface{}{h, cclock, interval}) + fake.emitHealthMetricsMutex.Unlock() + if fake.EmitHealthMetricsStub != nil { + fake.EmitHealthMetricsStub(h, cclock, interval) + } +} + +func (fake *FakePolicyDB) EmitHealthMetricsCallCount() int { + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + return len(fake.emitHealthMetricsArgsForCall) +} + +func (fake *FakePolicyDB) EmitHealthMetricsArgsForCall(i int) (healthendpoint.Health, clock.Clock, time.Duration) { + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + return fake.emitHealthMetricsArgsForCall[i].h, fake.emitHealthMetricsArgsForCall[i].cclock, fake.emitHealthMetricsArgsForCall[i].interval +} + +func (fake *FakePolicyDB) DeletePolicy(appId string) error { + fake.deletePolicyMutex.Lock() + ret, specificReturn := fake.deletePolicyReturnsOnCall[len(fake.deletePolicyArgsForCall)] + fake.deletePolicyArgsForCall = append(fake.deletePolicyArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("DeletePolicy", []interface{}{appId}) + fake.deletePolicyMutex.Unlock() + if fake.DeletePolicyStub != nil { + return fake.DeletePolicyStub(appId) + } + if specificReturn { + return ret.result1 + } + return fake.deletePolicyReturns.result1 +} + +func (fake *FakePolicyDB) DeletePolicyCallCount() int { + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + return len(fake.deletePolicyArgsForCall) +} + +func (fake *FakePolicyDB) DeletePolicyArgsForCall(i int) string { + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + return fake.deletePolicyArgsForCall[i].appId +} + +func (fake *FakePolicyDB) DeletePolicyReturns(result1 error) { + fake.DeletePolicyStub = nil + fake.deletePolicyReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) DeletePolicyReturnsOnCall(i int, result1 error) { + fake.DeletePolicyStub = nil + if fake.deletePolicyReturnsOnCall == nil { + fake.deletePolicyReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.deletePolicyReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) GetCustomMetricsCreds(appId string) (string, string, error) { + fake.getCustomMetricsCredsMutex.Lock() + ret, specificReturn := fake.getCustomMetricsCredsReturnsOnCall[len(fake.getCustomMetricsCredsArgsForCall)] + fake.getCustomMetricsCredsArgsForCall = append(fake.getCustomMetricsCredsArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("GetCustomMetricsCreds", []interface{}{appId}) + fake.getCustomMetricsCredsMutex.Unlock() + if fake.GetCustomMetricsCredsStub != nil { + return fake.GetCustomMetricsCredsStub(appId) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fake.getCustomMetricsCredsReturns.result1, fake.getCustomMetricsCredsReturns.result2, fake.getCustomMetricsCredsReturns.result3 +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsCallCount() int { + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + return len(fake.getCustomMetricsCredsArgsForCall) +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsArgsForCall(i int) string { + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + return fake.getCustomMetricsCredsArgsForCall[i].appId +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsReturns(result1 string, result2 string, result3 error) { + fake.GetCustomMetricsCredsStub = nil + fake.getCustomMetricsCredsReturns = struct { + result1 string + result2 string + result3 error + }{result1, result2, result3} +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsReturnsOnCall(i int, result1 string, result2 string, result3 error) { + fake.GetCustomMetricsCredsStub = nil + if fake.getCustomMetricsCredsReturnsOnCall == nil { + fake.getCustomMetricsCredsReturnsOnCall = make(map[int]struct { + result1 string + result2 string + result3 error + }) + } + fake.getCustomMetricsCredsReturnsOnCall[i] = struct { + result1 string + result2 string + result3 error + }{result1, result2, result3} +} + +func (fake *FakePolicyDB) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.getAppIdsMutex.RLock() + defer fake.getAppIdsMutex.RUnlock() + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + fake.retrievePoliciesMutex.RLock() + defer fake.retrievePoliciesMutex.RUnlock() + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakePolicyDB) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ db.PolicyDB = new(FakePolicyDB) diff --git a/src/autoscaler/operator/fakes/fake_policy_db.go b/src/autoscaler/operator/fakes/fake_policy_db.go new file mode 100644 index 000000000..88a0f4769 --- /dev/null +++ b/src/autoscaler/operator/fakes/fake_policy_db.go @@ -0,0 +1,437 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "autoscaler/db" + "autoscaler/healthendpoint" + "autoscaler/models" + "sync" + "time" + + "code.cloudfoundry.org/clock" +) + +type FakePolicyDB struct { + GetAppIdsStub func() (map[string]bool, error) + getAppIdsMutex sync.RWMutex + getAppIdsArgsForCall []struct{} + getAppIdsReturns struct { + result1 map[string]bool + result2 error + } + getAppIdsReturnsOnCall map[int]struct { + result1 map[string]bool + result2 error + } + GetAppPolicyStub func(appId string) (*models.ScalingPolicy, error) + getAppPolicyMutex sync.RWMutex + getAppPolicyArgsForCall []struct { + appId string + } + getAppPolicyReturns struct { + result1 *models.ScalingPolicy + result2 error + } + getAppPolicyReturnsOnCall map[int]struct { + result1 *models.ScalingPolicy + result2 error + } + RetrievePoliciesStub func() ([]*models.PolicyJson, error) + retrievePoliciesMutex sync.RWMutex + retrievePoliciesArgsForCall []struct{} + retrievePoliciesReturns struct { + result1 []*models.PolicyJson + result2 error + } + retrievePoliciesReturnsOnCall map[int]struct { + result1 []*models.PolicyJson + result2 error + } + CloseStub func() error + closeMutex sync.RWMutex + closeArgsForCall []struct{} + closeReturns struct { + result1 error + } + closeReturnsOnCall map[int]struct { + result1 error + } + EmitHealthMetricsStub func(h healthendpoint.Health, cclock clock.Clock, interval time.Duration) + emitHealthMetricsMutex sync.RWMutex + emitHealthMetricsArgsForCall []struct { + h healthendpoint.Health + cclock clock.Clock + interval time.Duration + } + DeletePolicyStub func(appId string) error + deletePolicyMutex sync.RWMutex + deletePolicyArgsForCall []struct { + appId string + } + deletePolicyReturns struct { + result1 error + } + deletePolicyReturnsOnCall map[int]struct { + result1 error + } + GetCustomMetricsCredsStub func(appId string) (string, string, error) + getCustomMetricsCredsMutex sync.RWMutex + getCustomMetricsCredsArgsForCall []struct { + appId string + } + getCustomMetricsCredsReturns struct { + result1 string + result2 string + result3 error + } + getCustomMetricsCredsReturnsOnCall map[int]struct { + result1 string + result2 string + result3 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakePolicyDB) GetAppIds() (map[string]bool, error) { + fake.getAppIdsMutex.Lock() + ret, specificReturn := fake.getAppIdsReturnsOnCall[len(fake.getAppIdsArgsForCall)] + fake.getAppIdsArgsForCall = append(fake.getAppIdsArgsForCall, struct{}{}) + fake.recordInvocation("GetAppIds", []interface{}{}) + fake.getAppIdsMutex.Unlock() + if fake.GetAppIdsStub != nil { + return fake.GetAppIdsStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.getAppIdsReturns.result1, fake.getAppIdsReturns.result2 +} + +func (fake *FakePolicyDB) GetAppIdsCallCount() int { + fake.getAppIdsMutex.RLock() + defer fake.getAppIdsMutex.RUnlock() + return len(fake.getAppIdsArgsForCall) +} + +func (fake *FakePolicyDB) GetAppIdsReturns(result1 map[string]bool, result2 error) { + fake.GetAppIdsStub = nil + fake.getAppIdsReturns = struct { + result1 map[string]bool + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppIdsReturnsOnCall(i int, result1 map[string]bool, result2 error) { + fake.GetAppIdsStub = nil + if fake.getAppIdsReturnsOnCall == nil { + fake.getAppIdsReturnsOnCall = make(map[int]struct { + result1 map[string]bool + result2 error + }) + } + fake.getAppIdsReturnsOnCall[i] = struct { + result1 map[string]bool + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppPolicy(appId string) (*models.ScalingPolicy, error) { + fake.getAppPolicyMutex.Lock() + ret, specificReturn := fake.getAppPolicyReturnsOnCall[len(fake.getAppPolicyArgsForCall)] + fake.getAppPolicyArgsForCall = append(fake.getAppPolicyArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("GetAppPolicy", []interface{}{appId}) + fake.getAppPolicyMutex.Unlock() + if fake.GetAppPolicyStub != nil { + return fake.GetAppPolicyStub(appId) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.getAppPolicyReturns.result1, fake.getAppPolicyReturns.result2 +} + +func (fake *FakePolicyDB) GetAppPolicyCallCount() int { + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + return len(fake.getAppPolicyArgsForCall) +} + +func (fake *FakePolicyDB) GetAppPolicyArgsForCall(i int) string { + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + return fake.getAppPolicyArgsForCall[i].appId +} + +func (fake *FakePolicyDB) GetAppPolicyReturns(result1 *models.ScalingPolicy, result2 error) { + fake.GetAppPolicyStub = nil + fake.getAppPolicyReturns = struct { + result1 *models.ScalingPolicy + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) GetAppPolicyReturnsOnCall(i int, result1 *models.ScalingPolicy, result2 error) { + fake.GetAppPolicyStub = nil + if fake.getAppPolicyReturnsOnCall == nil { + fake.getAppPolicyReturnsOnCall = make(map[int]struct { + result1 *models.ScalingPolicy + result2 error + }) + } + fake.getAppPolicyReturnsOnCall[i] = struct { + result1 *models.ScalingPolicy + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) RetrievePolicies() ([]*models.PolicyJson, error) { + fake.retrievePoliciesMutex.Lock() + ret, specificReturn := fake.retrievePoliciesReturnsOnCall[len(fake.retrievePoliciesArgsForCall)] + fake.retrievePoliciesArgsForCall = append(fake.retrievePoliciesArgsForCall, struct{}{}) + fake.recordInvocation("RetrievePolicies", []interface{}{}) + fake.retrievePoliciesMutex.Unlock() + if fake.RetrievePoliciesStub != nil { + return fake.RetrievePoliciesStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fake.retrievePoliciesReturns.result1, fake.retrievePoliciesReturns.result2 +} + +func (fake *FakePolicyDB) RetrievePoliciesCallCount() int { + fake.retrievePoliciesMutex.RLock() + defer fake.retrievePoliciesMutex.RUnlock() + return len(fake.retrievePoliciesArgsForCall) +} + +func (fake *FakePolicyDB) RetrievePoliciesReturns(result1 []*models.PolicyJson, result2 error) { + fake.RetrievePoliciesStub = nil + fake.retrievePoliciesReturns = struct { + result1 []*models.PolicyJson + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) RetrievePoliciesReturnsOnCall(i int, result1 []*models.PolicyJson, result2 error) { + fake.RetrievePoliciesStub = nil + if fake.retrievePoliciesReturnsOnCall == nil { + fake.retrievePoliciesReturnsOnCall = make(map[int]struct { + result1 []*models.PolicyJson + result2 error + }) + } + fake.retrievePoliciesReturnsOnCall[i] = struct { + result1 []*models.PolicyJson + result2 error + }{result1, result2} +} + +func (fake *FakePolicyDB) Close() error { + fake.closeMutex.Lock() + ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] + fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{}) + fake.recordInvocation("Close", []interface{}{}) + fake.closeMutex.Unlock() + if fake.CloseStub != nil { + return fake.CloseStub() + } + if specificReturn { + return ret.result1 + } + return fake.closeReturns.result1 +} + +func (fake *FakePolicyDB) CloseCallCount() int { + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + return len(fake.closeArgsForCall) +} + +func (fake *FakePolicyDB) CloseReturns(result1 error) { + fake.CloseStub = nil + fake.closeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) CloseReturnsOnCall(i int, result1 error) { + fake.CloseStub = nil + if fake.closeReturnsOnCall == nil { + fake.closeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.closeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) EmitHealthMetrics(h healthendpoint.Health, cclock clock.Clock, interval time.Duration) { + fake.emitHealthMetricsMutex.Lock() + fake.emitHealthMetricsArgsForCall = append(fake.emitHealthMetricsArgsForCall, struct { + h healthendpoint.Health + cclock clock.Clock + interval time.Duration + }{h, cclock, interval}) + fake.recordInvocation("EmitHealthMetrics", []interface{}{h, cclock, interval}) + fake.emitHealthMetricsMutex.Unlock() + if fake.EmitHealthMetricsStub != nil { + fake.EmitHealthMetricsStub(h, cclock, interval) + } +} + +func (fake *FakePolicyDB) EmitHealthMetricsCallCount() int { + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + return len(fake.emitHealthMetricsArgsForCall) +} + +func (fake *FakePolicyDB) EmitHealthMetricsArgsForCall(i int) (healthendpoint.Health, clock.Clock, time.Duration) { + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + return fake.emitHealthMetricsArgsForCall[i].h, fake.emitHealthMetricsArgsForCall[i].cclock, fake.emitHealthMetricsArgsForCall[i].interval +} + +func (fake *FakePolicyDB) DeletePolicy(appId string) error { + fake.deletePolicyMutex.Lock() + ret, specificReturn := fake.deletePolicyReturnsOnCall[len(fake.deletePolicyArgsForCall)] + fake.deletePolicyArgsForCall = append(fake.deletePolicyArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("DeletePolicy", []interface{}{appId}) + fake.deletePolicyMutex.Unlock() + if fake.DeletePolicyStub != nil { + return fake.DeletePolicyStub(appId) + } + if specificReturn { + return ret.result1 + } + return fake.deletePolicyReturns.result1 +} + +func (fake *FakePolicyDB) DeletePolicyCallCount() int { + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + return len(fake.deletePolicyArgsForCall) +} + +func (fake *FakePolicyDB) DeletePolicyArgsForCall(i int) string { + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + return fake.deletePolicyArgsForCall[i].appId +} + +func (fake *FakePolicyDB) DeletePolicyReturns(result1 error) { + fake.DeletePolicyStub = nil + fake.deletePolicyReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) DeletePolicyReturnsOnCall(i int, result1 error) { + fake.DeletePolicyStub = nil + if fake.deletePolicyReturnsOnCall == nil { + fake.deletePolicyReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.deletePolicyReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePolicyDB) GetCustomMetricsCreds(appId string) (string, string, error) { + fake.getCustomMetricsCredsMutex.Lock() + ret, specificReturn := fake.getCustomMetricsCredsReturnsOnCall[len(fake.getCustomMetricsCredsArgsForCall)] + fake.getCustomMetricsCredsArgsForCall = append(fake.getCustomMetricsCredsArgsForCall, struct { + appId string + }{appId}) + fake.recordInvocation("GetCustomMetricsCreds", []interface{}{appId}) + fake.getCustomMetricsCredsMutex.Unlock() + if fake.GetCustomMetricsCredsStub != nil { + return fake.GetCustomMetricsCredsStub(appId) + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fake.getCustomMetricsCredsReturns.result1, fake.getCustomMetricsCredsReturns.result2, fake.getCustomMetricsCredsReturns.result3 +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsCallCount() int { + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + return len(fake.getCustomMetricsCredsArgsForCall) +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsArgsForCall(i int) string { + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + return fake.getCustomMetricsCredsArgsForCall[i].appId +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsReturns(result1 string, result2 string, result3 error) { + fake.GetCustomMetricsCredsStub = nil + fake.getCustomMetricsCredsReturns = struct { + result1 string + result2 string + result3 error + }{result1, result2, result3} +} + +func (fake *FakePolicyDB) GetCustomMetricsCredsReturnsOnCall(i int, result1 string, result2 string, result3 error) { + fake.GetCustomMetricsCredsStub = nil + if fake.getCustomMetricsCredsReturnsOnCall == nil { + fake.getCustomMetricsCredsReturnsOnCall = make(map[int]struct { + result1 string + result2 string + result3 error + }) + } + fake.getCustomMetricsCredsReturnsOnCall[i] = struct { + result1 string + result2 string + result3 error + }{result1, result2, result3} +} + +func (fake *FakePolicyDB) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.getAppIdsMutex.RLock() + defer fake.getAppIdsMutex.RUnlock() + fake.getAppPolicyMutex.RLock() + defer fake.getAppPolicyMutex.RUnlock() + fake.retrievePoliciesMutex.RLock() + defer fake.retrievePoliciesMutex.RUnlock() + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + fake.emitHealthMetricsMutex.RLock() + defer fake.emitHealthMetricsMutex.RUnlock() + fake.deletePolicyMutex.RLock() + defer fake.deletePolicyMutex.RUnlock() + fake.getCustomMetricsCredsMutex.RLock() + defer fake.getCustomMetricsCredsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakePolicyDB) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ db.PolicyDB = new(FakePolicyDB) diff --git a/src/github.com/cespare/xxhash b/src/github.com/cespare/xxhash deleted file mode 160000 index d7df74196..000000000 --- a/src/github.com/cespare/xxhash +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d7df74196a9e781ede915320c11c378c1b2f3a1f diff --git a/src/github.com/prometheus/client_golang b/src/github.com/prometheus/client_golang index 554505791..82f5ff156 160000 --- a/src/github.com/prometheus/client_golang +++ b/src/github.com/prometheus/client_golang @@ -1 +1 @@ -Subproject commit 55450579111f95e3722cb93dec62fe9e847d6130 +Subproject commit 82f5ff156b29e276022b1a958f7d385870fb9814 diff --git a/src/github.com/prometheus/client_model b/src/github.com/prometheus/client_model index 14fe0d1b0..99fa1f4be 160000 --- a/src/github.com/prometheus/client_model +++ b/src/github.com/prometheus/client_model @@ -1 +1 @@ -Subproject commit 14fe0d1b01d4d5fc031dd4bec1823bd3ebbe8016 +Subproject commit 99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c diff --git a/src/github.com/prometheus/common b/src/github.com/prometheus/common index 287d3e634..d811d2e9b 160000 --- a/src/github.com/prometheus/common +++ b/src/github.com/prometheus/common @@ -1 +1 @@ -Subproject commit 287d3e634a1e550c9e463dd7e5a75a422c614505 +Subproject commit d811d2e9bf898806ecfb6ef6296774b13ffc314c diff --git a/src/github.com/prometheus/procfs b/src/github.com/prometheus/procfs index 499c85531..8b1c2da0d 160000 --- a/src/github.com/prometheus/procfs +++ b/src/github.com/prometheus/procfs @@ -1 +1 @@ -Subproject commit 499c85531f756d1129edd26485a5f73871eeb308 +Subproject commit 8b1c2da0d56deffdbb9e48d4414b4e674bd8083e From a17fe417c444eab7210dbdb2664ee04025aa5dbe Mon Sep 17 00:00:00 2001 From: an qin Date: Fri, 10 Jan 2020 17:30:22 +0800 Subject: [PATCH 2/2] Revert "upgrade prometheus client_golang to v1.2.1" This reverts commit 994eab534be621a988946c13939f5aceafe19595. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index b1edbb550..d51a0e8be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -150,4 +150,4 @@ url = https://github.com/juju/ratelimit [submodule "src/github.com/jmoiron/sqlx"] path = src/github.com/jmoiron/sqlx - url = https://github.com/jmoiron/sqlx + url = https://github.com/jmoiron/sqlx \ No newline at end of file