package compute_engine

import (
	"testing"

	"github.com/pingcap-inc/clinic/pkg/config"
)

// https://f9wnps9xua.execute-api.cn-north-1.amazonaws.com.cn
var cfg config.Config = config.Config{
	ReportConfig: config.ReportConfig{
		ComputeEngineEndPoint: "https://f9wnps9xua.execute-api.cn-north-1.amazonaws.com.cn",
	},
}

var cli = NewCMClient(&cfg)

func TestCMClient_DoHealthReport(t *testing.T) {
	ha := HealthArgs{
		ClusterID: "7011343775512531968",
		StartTS:   1656093600,
		StopTS:    1656095400,
		OrgID:     "186",
		Packages:  []string{"381400e3e43db372-7186e31a0cfdb1f2-7fa23fab97916e3"},
	}
	_, err := cli.DoHealthReport(ha)
	if err != nil {
		t.Error("call health report failed", err)
		return
	}
}

func TestFetchReport(t *testing.T) {
	reportUUID := "e2b6a704-a77e-41c9-82a2-79e344026d0f"
	_, err := cli.FetchReport(reportUUID)
	if err != nil {
		t.Error("fetch report failed", err)
		return
	}
}

func TestDoComparisionReport(t *testing.T) {
	ca := ComparisonReportArgs{
		ClusterID:  "7078236677907728927",
		OrgType:    "op",
		OrgID:      "200",
		StartTime1: 1648541700,
		EndTime1:   1648543400,
		StartTime2: 1648543400,
		EndTime2:   1648545300,
		PackageID1: []string{"e3781755dd429379-becbc7c8e8befa58-a1e15bd9a0d4b1ab"},
		PackageID2: []string{"e3781755dd429379-becbc7c8e8befa58-a1e15bd9a0d4b1ab"},
	}
	_, err := cli.DoComparisonReport(ca)
	if err != nil {
		t.Error("do comparison faile", err)
		return
	}
}

func TestFetchComparisonReport(t *testing.T) {
	reportUUID := "7fe4c9b5-e8b8-4b5f-8b46-ae6ee83cb27f"
	_, err := cli.FetchComparisonReport(reportUUID)
	if err != nil {
		t.Error("fetch report failed", err)
		return
	}
}
