Add metering api.

Signed-off-by: yunkunrao <yunkunrao@yunify.com>
This commit is contained in:
yunkunrao
2020-10-16 11:01:50 +08:00
committed by Rao Yunkun
parent 2f5202f38a
commit e9073f0486
31 changed files with 4794 additions and 101 deletions

View File

@@ -18,6 +18,9 @@ package v1alpha3
import (
"fmt"
"testing"
"time"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -25,8 +28,6 @@ import (
"kubesphere.io/kubesphere/pkg/informers"
model "kubesphere.io/kubesphere/pkg/models/monitoring"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring"
"testing"
"time"
)
func TestIsRangeQuery(t *testing.T) {
@@ -84,6 +85,7 @@ func TestParseRequestParams(t *testing.T) {
metricFilter: ".*",
namedMetrics: model.ClusterMetrics,
option: monitoring.ClusterOption{},
Operation: OperationQuery,
},
expectedErr: false,
},
@@ -114,6 +116,7 @@ func TestParseRequestParams(t *testing.T) {
ResourceFilter: ".*",
NamespaceName: "default",
},
Operation: OperationQuery,
},
expectedErr: false,
},
@@ -181,6 +184,7 @@ func TestParseRequestParams(t *testing.T) {
metricFilter: "etcd_server_list",
namedMetrics: model.EtcdMetrics,
option: monitoring.ComponentOption{},
Operation: OperationQuery,
},
expectedErr: false,
},
@@ -208,6 +212,7 @@ func TestParseRequestParams(t *testing.T) {
order: "desc",
page: 1,
limit: 10,
Operation: OperationQuery,
},
expectedErr: false,
},
@@ -217,7 +222,7 @@ func TestParseRequestParams(t *testing.T) {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
client := fake.NewSimpleClientset(&tt.namespace)
fakeInformerFactory := informers.NewInformerFactories(client, nil, nil, nil, nil, nil)
handler := newHandler(client, nil, nil, fakeInformerFactory, nil)
handler := NewHandler(client, nil, nil, fakeInformerFactory, nil, nil)
result, err := handler.makeQueryOptions(tt.params, tt.lvl)
if err != nil {