Skip to content

Commit

Permalink
fixing unit test, update licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlyF committed Nov 19, 2019
1 parent 0e1576e commit 0ac91d1
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 44 deletions.
16 changes: 4 additions & 12 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
branch = "release-1.15"

[[constraint]]
name = "github.com/kubernetes/cri-api"
name = "k8s.io/cri-api"
branch = "release-1.15"

[[override]]
Expand Down
4 changes: 1 addition & 3 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ core,sigs.k8s.io/yaml,Apache-2.0
core,k8s.io/component-base,Apache-2.0
core,github.com/armon/go-metrics,Apache-2.0
core,k8s.io/klog,Apache-2.0
core,k8s.io/cloud-provider,Apache-2.0
core,github.com/munnerz/goautoneg,Apache-2.0
core,google.golang.org/appengine,Apache-2.0
core,github.com/hashicorp/go-immutable-radix,Apache-2.0
Expand Down Expand Up @@ -151,8 +150,7 @@ core,k8s.io/client-go,Apache-2.0
core,k8s.io/kube-openapi,Apache-2.0
core,k8s.io/metrics,Apache-2.0
core,k8s.io/utils,Apache-2.0
core,k8s.io/apiextensions-apiserver,Apache-2.0
core,github.com/docker/spdystream,Apache-2.0
core,k8s.io/cri-api,Apache-2.0
core,github.com/opencontainers/go-digest,Apache-2.0
core,github.com/philhofer/fwd,MIT
core,github.com/DataDog/datadog-go,MIT
Expand Down
8 changes: 4 additions & 4 deletions pkg/clusteragent/custommetrics/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestExternalMetricValueKeyFunc(t *testing.T) {
Namespace: "default",
},
},
output: "external_metric-default-horizontal-bar-foo",
output: "external_metric-horizontal-default-bar-foo",
},
{
desc: "custom case",
Expand All @@ -210,7 +210,7 @@ func TestExternalMetricValueKeyFunc(t *testing.T) {
Namespace: "DefauLt",
},
},
output: "external_metric-DefauLt-horizontal-bar-FoO",
output: "external_metric-horizontal-DefauLt-bar-FoO",
},
{
desc: "default case",
Expand All @@ -222,7 +222,7 @@ func TestExternalMetricValueKeyFunc(t *testing.T) {
Namespace: "default",
},
},
output: "external_metric-default-watermark-bar-foo",
output: "external_metric-watermark-default-bar-foo",
},
{
desc: "custom case",
Expand All @@ -234,7 +234,7 @@ func TestExternalMetricValueKeyFunc(t *testing.T) {
Namespace: "DefauLt",
},
},
output: "external_metric-DefauLt-watermark-bar-FoO",
output: "external_metric-watermark-DefauLt-bar-FoO",
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/corechecks/containers/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
package containers

import (
pb "github.com/kubernetes/cri-api/pkg/apis/runtime/v1alpha2"
yaml "gopkg.in/yaml.v2"
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

"github.com/DataDog/datadog-agent/pkg/aggregator"
"github.com/DataDog/datadog-agent/pkg/autodiscovery/integration"
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/corechecks/containers/cri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package containers
import (
"testing"

pb "github.com/kubernetes/cri-api/pkg/apis/runtime/v1alpha2"
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

"github.com/DataDog/datadog-agent/pkg/aggregator/mocksender"
core "github.com/DataDog/datadog-agent/pkg/collector/corechecks"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/containers/cri/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/util/log"
"github.com/DataDog/datadog-agent/pkg/util/retry"
pb "github.com/kubernetes/cri-api/pkg/apis/runtime/v1alpha2"
"google.golang.org/grpc"
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)

var (
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/kubernetes/apiserver/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func startAutoscalersController(ctx ControllerContext) error {
if config.Datadog.GetBool("watermark_pod_autoscaler_controller.enabled") {
autoscalersController.wpaEnabled = true
autoscalersController, err = ExtendToWPAController(autoscalersController, ctx.WPAInformerFactory.Datadoghq().V1alpha1().WatermarkPodAutoscalers())
if err != nil {
return err
}
go autoscalersController.RunWPA(ctx.StopCh)
}

Expand Down
19 changes: 11 additions & 8 deletions pkg/util/kubernetes/apiserver/hpa_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ func TestUpdate(t *testing.T) {
// Start the DCA with already existing Data
// Check if nothing in local store and Global Store is full we update the Global Store metrics correctly
metricsToStore := map[string]custommetrics.ExternalMetricValue{
"external_metric-default-foo-metric1": {
"external_metric-horizontal-default-foo-metric1": {
MetricName: "metric1",
Labels: map[string]string{"foo": "bar"},
Ref: custommetrics.ObjectReference{
Type: "horizontal",
Name: "foo",
Namespace: "default",
},
Expand Down Expand Up @@ -215,10 +216,11 @@ func TestUpdate(t *testing.T) {
// Fresh start
// Check if local store is not empty
hctrl.toStore.m.Lock()
hctrl.toStore.data["external_metric-default-foo-metric2"] = custommetrics.ExternalMetricValue{
hctrl.toStore.data["external_metric-horizontal-default-foo-metric2"] = custommetrics.ExternalMetricValue{
MetricName: "metric2",
Labels: map[string]string{"foo": "bar"},
Ref: custommetrics.ObjectReference{
Type: "horizontal",
Name: "foo",
Namespace: "default",
},
Expand All @@ -235,10 +237,11 @@ func TestUpdate(t *testing.T) {
// Check that if there is conflicting info from the local store and the Global Store that we merge correctly
// Check conflict on metric name and labels
hctrl.toStore.m.Lock()
hctrl.toStore.data["external_metric-default-foo-metric2"] = custommetrics.ExternalMetricValue{
hctrl.toStore.data["external_metric-horizontal-default-foo-metric2"] = custommetrics.ExternalMetricValue{
MetricName: "metric2",
Labels: map[string]string{"foo": "baz"},
Ref: custommetrics.ObjectReference{
Type: "horizontal",
Name: "foo",
Namespace: "default",
},
Expand Down Expand Up @@ -573,10 +576,10 @@ func TestAutoscalerControllerGC(t *testing.T) {
{
caseName: "hpa exists for metric",
metrics: map[string]custommetrics.ExternalMetricValue{
"external_metric-default-foo-requests_per_s": {
"external_metric-horizontal-default-foo-requests_per_s": {
MetricName: "requests_per_s",
Labels: map[string]string{"bar": "baz"},
Ref: custommetrics.ObjectReference{Name: "foo", Namespace: "default", UID: "1111"},
Ref: custommetrics.ObjectReference{Type: "horizontal", Name: "foo", Namespace: "default", UID: "1111"},
Timestamp: 12,
Value: 1,
Valid: false,
Expand Down Expand Up @@ -607,7 +610,7 @@ func TestAutoscalerControllerGC(t *testing.T) {
{
MetricName: "requests_per_s",
Labels: map[string]string{"bar": "baz"},
Ref: custommetrics.ObjectReference{Name: "foo", Namespace: "default", UID: "1111"},
Ref: custommetrics.ObjectReference{Type: "horizontal", Name: "foo", Namespace: "default", UID: "1111"},
Timestamp: 12,
Value: 1,
Valid: false,
Expand All @@ -617,10 +620,10 @@ func TestAutoscalerControllerGC(t *testing.T) {
{
caseName: "no hpa for metric",
metrics: map[string]custommetrics.ExternalMetricValue{
"external_metric-default-foo-requests_per_s_b": {
"external_metric-horizontal-default-foo-requests_per_s_b": {
MetricName: "requests_per_s_b",
Labels: map[string]string{"bar": "baz"},
Ref: custommetrics.ObjectReference{Name: "foo", Namespace: "default", UID: "1111"},
Ref: custommetrics.ObjectReference{Type: "horizontal", Name: "foo", Namespace: "default", UID: "1111"},
Timestamp: 12,
Value: 1,
Valid: false,
Expand Down
48 changes: 35 additions & 13 deletions pkg/util/kubernetes/hpa/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,22 @@ func TestInspect(t *testing.T) {
{
MetricName: "requests_per_s",
Labels: map[string]string{"dcos_version": "1.9.4"},
Timestamp: 0,
Value: 0,
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
},
Timestamp: 0,
Value: 0,
Valid: false,
},
{
MetricName: "requests_per_s",
Labels: map[string]string{"dcos_version": "2.1.9"},
Timestamp: 0,
Value: 0,
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
},
Timestamp: 0,
Value: 0,
Valid: false,
},
},
},
Expand Down Expand Up @@ -298,10 +304,13 @@ func TestInspect(t *testing.T) {
[]custommetrics.ExternalMetricValue{
{
MetricName: "foo",
Labels: nil,
Timestamp: 0,
Value: 0,
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
},
Labels: nil,
Timestamp: 0,
Value: 0,
Valid: false,
},
},
},
Expand Down Expand Up @@ -341,9 +350,12 @@ func TestInspect(t *testing.T) {
{
MetricName: metricNameUpper,
Labels: map[string]string{"dcos_version": "1.9.4"},
Timestamp: 0,
Value: 0,
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
},
Timestamp: 0,
Value: 0,
Valid: false,
},
},
},
Expand Down Expand Up @@ -404,6 +416,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "tagbar"},
Valid: true,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(5),
Name: "foo",
Namespace: "nsbar",
Expand All @@ -414,6 +427,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "dre"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(6),
Name: "foo",
Namespace: "baz",
Expand All @@ -424,6 +438,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "tu"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(7),
Name: "bar",
Namespace: "zanzi",
Expand All @@ -436,6 +451,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "dre"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(6),
Name: "foo",
Namespace: "baz",
Expand Down Expand Up @@ -468,6 +484,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: true,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(5),
Namespace: "bar",
Name: "foo",
Expand All @@ -478,6 +495,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(7),
Namespace: "baz",
Name: "foo",
Expand All @@ -490,6 +508,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(7),
Name: "foo",
Namespace: "baz",
Expand Down Expand Up @@ -522,6 +541,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: true,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(5),
Namespace: "bar",
Name: "foo",
Expand All @@ -532,6 +552,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(7),
Namespace: "baz",
Name: "foo",
Expand All @@ -544,6 +565,7 @@ func TestDiffExternalMetrics(t *testing.T) {
Labels: map[string]string{"foo": "bar"},
Valid: false,
Ref: custommetrics.ObjectReference{
Type: "horizontal",
UID: string(7),
Name: "foo",
Namespace: "baz",
Expand Down

0 comments on commit 0ac91d1

Please sign in to comment.