Integate metering module and support metering data csv format export.

Signed-off-by: Rao Yunkun <yunkunrao@yunify.com>
This commit is contained in:
Rao Yunkun
2021-03-25 10:01:38 +08:00
parent ac275b6e98
commit d08e402384
23 changed files with 664 additions and 350 deletions

View File

@@ -39,6 +39,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/kubeedge"
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
"kubesphere.io/kubesphere/pkg/simple/client/logging"
"kubesphere.io/kubesphere/pkg/simple/client/metering"
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
"kubesphere.io/kubesphere/pkg/simple/client/multicluster"
"kubesphere.io/kubesphere/pkg/simple/client/network"
@@ -170,6 +171,9 @@ func newTestConfig() (*Config, error) {
KubeEdgeOptions: &kubeedge.Options{
Endpoint: "http://edge-watcher.kubeedge.svc/api/",
},
MeteringOptions: &metering.Options{
Enable: false,
},
}
return conf, nil
}
@@ -185,6 +189,13 @@ func saveTestConfig(t *testing.T, conf *Config) {
}
}
func testMeteringConfig(t *testing.T, conf *Config) {
conf.ToMap()
if conf.MeteringOptions != nil {
t.Fatalf("setting metering options failed")
}
}
func cleanTestConfig(t *testing.T) {
file := fmt.Sprintf("%s.yaml", defaultConfigurationName)
if _, err := os.Stat(file); os.IsNotExist(err) {
@@ -214,4 +225,7 @@ func TestGet(t *testing.T) {
if diff := cmp.Diff(conf, conf2); diff != "" {
t.Fatal(diff)
}
testMeteringConfig(t, conf)
}