From f873bca335cd5286f1f6c08cc4ba37cadedf94ed Mon Sep 17 00:00:00 2001 From: Alan Cha Date: Fri, 8 Sep 2023 13:08:15 -0400 Subject: [PATCH] Modify metric endpoints (#1629) * Rename /metrics to /abnDashboard Signed-off-by: Alan Cha * Fix comments Signed-off-by: Alan Cha * Change experiment query parameter to test Signed-off-by: Alan Cha * Fix comment Signed-off-by: Alan Cha * Split application parameter into namespace and application Signed-off-by: Alan Cha * Change PUT /experimentResult to /testResult Signed-off-by: Alan Cha * Remove extraneous line Signed-off-by: Alan Cha * Change putExperimentResult to use test query param Signed-off-by: Alan Cha * Fix logging statement Signed-off-by: Alan Cha * Fix variable name Signed-off-by: Alan Cha * Up coverage Signed-off-by: Alan Cha --------- Signed-off-by: Alan Cha --- action/run_test.go | 2 +- base/collect_http.go | 13 +++++ base/collect_http_test.go | 44 ++++++++++++++++ base/experiment_test.go | 2 +- base/metrics.go | 16 +++--- base/test_helpers.go | 6 +-- cmd/krun_test.go | 2 +- driver/kubedriver_test.go | 2 +- metrics/server.go | 104 ++++++++++++++++++++------------------ metrics/server_test.go | 48 +++++++++--------- 10 files changed, 152 insertions(+), 87 deletions(-) diff --git a/action/run_test.go b/action/run_test.go index c8796c761..fb7b60b3d 100644 --- a/action/run_test.go +++ b/action/run_test.go @@ -44,7 +44,7 @@ func TestKubeRun(t *testing.T) { metricsServerCalled = true // check query parameters - assert.Equal(t, myName, req.URL.Query().Get("experiment")) + assert.Equal(t, myName, req.URL.Query().Get("test")) assert.Equal(t, myNamespace, req.URL.Query().Get("namespace")) // check payload diff --git a/base/collect_http.go b/base/collect_http.go index f1679e1b7..88ca5f6dc 100644 --- a/base/collect_http.go +++ b/base/collect_http.go @@ -1,6 +1,7 @@ package base import ( + "errors" "fmt" "io" "os" @@ -126,6 +127,18 @@ func (t *collectHTTPTask) validateInputs() error { // getFortioOptions constructs Fortio's HTTP runner options based on collect task inputs func getFortioOptions(c endpoint) (*fhttp.HTTPRunnerOptions, error) { + if c.QPS == nil { + return nil, errors.New("no value for QPS") + } + + if c.Connections == nil { + return nil, errors.New("no value for Connections") + } + + if c.AllowInitialErrors == nil { + return nil, errors.New("no value for AllowInitialErrors") + } + // basic runner fo := &fhttp.HTTPRunnerOptions{ RunnerOptions: periodic.RunnerOptions{ diff --git a/base/collect_http_test.go b/base/collect_http_test.go index b82762933..f8a9e8aa0 100644 --- a/base/collect_http_test.go +++ b/base/collect_http_test.go @@ -489,3 +489,47 @@ func TestRunCollectHTTPWithIncorrectNumVersions(t *testing.T) { // error ensures that Fortio results are not written to insights assert.Nil(t, exp.Result.Insights.TaskData) } + +func TestGetFortioOptions(t *testing.T) { + // check to catch nil QPS + _, err := getFortioOptions(endpoint{}) + assert.Error(t, err) + + // check for catch nil connections + QPS := float32(8) + _, err = getFortioOptions(endpoint{ + QPS: &QPS, + }) + assert.Error(t, err) + + // check to catch nil allowInitialErrors + connections := 8 + _, err = getFortioOptions(endpoint{ + QPS: &QPS, + Connections: &connections, + }) + assert.Error(t, err) + + numRequests := int64(5) + contentType := "testType" + payloadStr := "testPayload" + allowInitialErrors := true + + options, err := getFortioOptions(endpoint{ + NumRequests: &numRequests, + ContentType: &contentType, + PayloadStr: &payloadStr, + QPS: &QPS, + Connections: &connections, + AllowInitialErrors: &allowInitialErrors, + }) + + assert.NoError(t, err) + + s, _ := json.Marshal(options) + fmt.Println(string(s)) + + assert.Equal(t, numRequests, options.RunnerOptions.Exactly) + assert.Equal(t, contentType, options.ContentType) + assert.Equal(t, []byte(payloadStr), options.Payload) +} diff --git a/base/experiment_test.go b/base/experiment_test.go index 8be431d06..9b3e187c5 100644 --- a/base/experiment_test.go +++ b/base/experiment_test.go @@ -96,7 +96,7 @@ func TestRunExperiment(t *testing.T) { metricsServerCalled = true // check query parameters - assert.Equal(t, myName, req.URL.Query().Get("experiment")) + assert.Equal(t, myName, req.URL.Query().Get("test")) assert.Equal(t, myNamespace, req.URL.Query().Get("namespace")) // check payload diff --git a/base/metrics.go b/base/metrics.go index 396ff5dcf..b0deced6f 100644 --- a/base/metrics.go +++ b/base/metrics.go @@ -14,11 +14,11 @@ const ( // MetricsServerURL is the URL of the metrics server MetricsServerURL = "METRICS_SERVER_URL" - // MetricsPath is the path to the GET /metrics endpoint - MetricsPath = "/metrics" + // TestResultPath is the path to the PUT /testResult endpoint + TestResultPath = "/testResult" - // ExperimentResultPath is the path to the PUT /experimentResult endpoint - ExperimentResultPath = "/experimentResult" + // AbnDashboard is the path to the GET /abnDashboard endpoint + AbnDashboard = "/abnDashboard" // HTTPDashboardPath is the path to the GET /httpDashboard endpoint HTTPDashboardPath = "/httpDashboard" // GRPCDashboardPath is the path to the GET /grpcDashboard endpoint @@ -79,10 +79,10 @@ func callMetricsService(method, metricsServerURL, path string, queryParams map[s return nil } -// PutExperimentResultToMetricsService sends the experiment result to the metrics service +// PutExperimentResultToMetricsService sends the test result to the metrics service func PutExperimentResultToMetricsService(metricsServerURL, namespace, experiment string, experimentResult *ExperimentResult) error { - return callMetricsService(http.MethodPut, metricsServerURL, ExperimentResultPath, map[string]string{ - "namespace": namespace, - "experiment": experiment, + return callMetricsService(http.MethodPut, metricsServerURL, TestResultPath, map[string]string{ + "namespace": namespace, + "test": experiment, }, experimentResult) } diff --git a/base/test_helpers.go b/base/test_helpers.go index 6356ed77d..a5e99bcb0 100644 --- a/base/test_helpers.go +++ b/base/test_helpers.go @@ -104,7 +104,7 @@ type MetricsServerCallback func(req *http.Request) type MockMetricsServerInput struct { MetricsServerURL string - // PUT /experimentResult + // PUT /testResult ExperimentResultCallback MetricsServerCallback // GET /grpcDashboard GRPCDashboardCallback MetricsServerCallback @@ -115,10 +115,10 @@ type MockMetricsServerInput struct { // MockMetricsServer is a mock metrics server // use the callback functions in the MockMetricsServerInput to test if those endpoints are called func MockMetricsServer(input MockMetricsServerInput) { - // PUT /experimentResult + // PUT /testResult httpmock.RegisterResponder( http.MethodPut, - input.MetricsServerURL+ExperimentResultPath, + input.MetricsServerURL+TestResultPath, func(req *http.Request) (*http.Response, error) { if input.ExperimentResultCallback != nil { input.ExperimentResultCallback(req) diff --git a/cmd/krun_test.go b/cmd/krun_test.go index 2f5daf147..6327f6f17 100644 --- a/cmd/krun_test.go +++ b/cmd/krun_test.go @@ -43,7 +43,7 @@ func TestKRun(t *testing.T) { metricsServerCalled = true // check query parameters - assert.Equal(t, myName, req.URL.Query().Get("experiment")) + assert.Equal(t, myName, req.URL.Query().Get("test")) assert.Equal(t, myNamespace, req.URL.Query().Get("namespace")) // check payload diff --git a/driver/kubedriver_test.go b/driver/kubedriver_test.go index e74bfb526..3252faf07 100644 --- a/driver/kubedriver_test.go +++ b/driver/kubedriver_test.go @@ -43,7 +43,7 @@ func TestKubeRun(t *testing.T) { metricsServerCalled = true // check query parameters - assert.Equal(t, myName, req.URL.Query().Get("experiment")) + assert.Equal(t, myName, req.URL.Query().Get("test")) assert.Equal(t, myNamespace, req.URL.Query().Get("namespace")) // check payload diff --git a/metrics/server.go b/metrics/server.go index 7281c975c..857e9a904 100644 --- a/metrics/server.go +++ b/metrics/server.go @@ -13,7 +13,6 @@ import ( "github.com/bojand/ghz/runner" "github.com/iter8-tools/iter8/abn" - "github.com/iter8-tools/iter8/base" util "github.com/iter8-tools/iter8/base" "github.com/iter8-tools/iter8/base/log" "github.com/iter8-tools/iter8/controllers" @@ -88,7 +87,7 @@ type dashboardExperimentResult struct { Failure bool // Insights produced in this experiment - Insights *base.Insights + Insights *util.Insights // Iter8Version is the version of Iter8 CLI that created this result object Iter8Version string `json:"Iter8 version"` @@ -148,9 +147,8 @@ func Start(stopCh <-chan struct{}) error { } // configure endpoints - http.HandleFunc(util.MetricsPath, getMetrics) - - http.HandleFunc(util.ExperimentResultPath, putExperimentResult) + http.HandleFunc(util.TestResultPath, putExperimentResult) + http.HandleFunc(util.AbnDashboard, getAbnDashboard) http.HandleFunc(util.HTTPDashboardPath, getHTTPDashboard) http.HandleFunc(util.GRPCDashboardPath, getGRPCDashboard) @@ -178,10 +176,10 @@ func Start(stopCh <-chan struct{}) error { return nil } -// getMetrics handles GET /metrics with query parameter application=namespace/name -func getMetrics(w http.ResponseWriter, r *http.Request) { - log.Logger.Trace("getMetrics called") - defer log.Logger.Trace("getMetrics completed") +// getAbnDashboard handles GET /abnDashboard with query parameter application=name and namespace=namespace +func getAbnDashboard(w http.ResponseWriter, r *http.Request) { + log.Logger.Trace("getAbnDashboard called") + defer log.Logger.Trace("getAbnDashboard completed") // verify method if r.Method != http.MethodGet { @@ -193,17 +191,26 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { application := r.URL.Query().Get("application") if application == "" { http.Error(w, "no application specified", http.StatusBadRequest) + return + } + + namespace := r.URL.Query().Get("namespace") + if namespace == "" { + http.Error(w, "no namespace specified", http.StatusBadRequest) + return } - log.Logger.Tracef("getMetrics called for application %s", application) + + namespaceApplication := fmt.Sprintf("%s/%s", namespace, application) + + log.Logger.Tracef("getAbnDashboard called for application %s", namespaceApplication) // identify the routemap for the application - namespace, name := util.SplitApplication(application) - rm := allRoutemaps.GetAllRoutemaps().GetRoutemapFromNamespaceName(namespace, name) + rm := allRoutemaps.GetAllRoutemaps().GetRoutemapFromNamespaceName(namespace, application) if rm == nil || reflect.ValueOf(rm).IsNil() { - http.Error(w, fmt.Sprintf("unknown application %s", application), http.StatusBadRequest) + http.Error(w, fmt.Sprintf("unknown application %s", namespaceApplication), http.StatusBadRequest) return } - log.Logger.Tracef("getMetrics found routemap %v", rm) + log.Logger.Tracef("getAbnDashboard found routemap %v", rm) // initialize result result := make(map[string]*metricSummary, 0) @@ -217,7 +224,7 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { for v, version := range rm.GetVersions() { signature := version.GetSignature() if signature == nil { - log.Logger.Debugf("no signature for application %s (version %d)", application, v) + log.Logger.Debugf("no signature for application %s (version %d)", namespaceApplication, v) continue } @@ -225,9 +232,9 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { log.Logger.Error("no metrics client") continue } - versionmetrics, err := abn.MetricsClient.GetMetrics(application, v, *signature) + versionmetrics, err := abn.MetricsClient.GetMetrics(namespaceApplication, v, *signature) if err != nil { - log.Logger.Debugf("no metrics found for application %s (version %d; signature %s)", application, v, *signature) + log.Logger.Debugf("no metrics found for application %s (version %d; signature %s)", namespaceApplication, v, *signature) continue } @@ -247,7 +254,7 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { smT, err := calculateSummarizedMetric(metrics.MetricsOverTransactions) if err != nil { - log.Logger.Debugf("unable to compute summaried metrics over transactions for application %s (version %d; signature %s)", application, v, *signature) + log.Logger.Debugf("unable to compute summaried metrics over transactions for application %s (version %d; signature %s)", namespaceApplication, v, *signature) continue } else { entry.SummaryOverTransactions = append(entry.SummaryOverTransactions, &versionSummarizedMetric{ @@ -258,7 +265,7 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { smU, err := calculateSummarizedMetric(metrics.MetricsOverUsers) if err != nil { - log.Logger.Debugf("unable to compute summaried metrics over users for application %s (version %d; signature %s)", application, v, *signature) + log.Logger.Debugf("unable to compute summaried metrics over users for application %s (version %d; signature %s)", namespaceApplication, v, *signature) continue } entry.SummaryOverUsers = append(entry.SummaryOverUsers, &versionSummarizedMetric{ @@ -289,7 +296,7 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { for metric, byVersion := range byMetricOverTransactions { hT, err := calculateHistogram(byVersion, 0, 0) if err != nil { - log.Logger.Debugf("unable to compute histogram over transactions for application %s (metric %s)", application, metric) + log.Logger.Debugf("unable to compute histogram over transactions for application %s (metric %s)", namespaceApplication, metric) continue } else { resultEntry := result[metric] @@ -301,7 +308,7 @@ func getMetrics(w http.ResponseWriter, r *http.Request) { for metric, byVersion := range byMetricOverUsers { hT, err := calculateHistogram(byVersion, 0, 0) if err != nil { - log.Logger.Debugf("unable to compute histogram over users for application %s (metric %s)", application, metric) + log.Logger.Debugf("unable to compute histogram over users for application %s (metric %s)", namespaceApplication, metric) continue } else { resultEntry := result[metric] @@ -490,7 +497,7 @@ func getHTTPEndpointRow(httpRunnerResults *fhttp.HTTPRunnerResults) httpEndpoint return row } -func getHTTPDashboardHelper(experimentResult *base.ExperimentResult) httpDashboard { +func getHTTPDashboardHelper(experimentResult *util.ExperimentResult) httpDashboard { dashboard := httpDashboard{ Endpoints: map[string]httpEndpointRow{}, ExperimentResult: dashboardExperimentResult{ @@ -517,7 +524,7 @@ func getHTTPDashboardHelper(experimentResult *base.ExperimentResult) httpDashboa return dashboard } - httpResult := base.HTTPResult{} + httpResult := util.HTTPResult{} err = json.Unmarshal(httpTaskDataBytes, &httpResult) if err != nil { log.Logger.Error("cannot unmarshal http task data into HTTPResult") @@ -533,7 +540,7 @@ func getHTTPDashboardHelper(experimentResult *base.ExperimentResult) httpDashboa return dashboard } -// getHTTPDashboard handles GET /getHTTPDashboard with query parameter application=namespace/name +// getHTTPDashboard handles GET /getHTTPDashboard with query parameter test=name and namespace=namespace func getHTTPDashboard(w http.ResponseWriter, r *http.Request) { log.Logger.Trace("getHTTPGrafana called") defer log.Logger.Trace("getHTTPGrafana completed") @@ -551,13 +558,13 @@ func getHTTPDashboard(w http.ResponseWriter, r *http.Request) { return } - experiment := r.URL.Query().Get("experiment") - if experiment == "" { - http.Error(w, "no experiment specified", http.StatusBadRequest) + test := r.URL.Query().Get("test") + if test == "" { + http.Error(w, "no test specified", http.StatusBadRequest) return } - log.Logger.Tracef("getHTTPGrafana called for namespace %s and experiment %s", namespace, experiment) + log.Logger.Tracef("getHTTPGrafana called for namespace %s and test %s", namespace, test) // get fortioResult from metrics client if abn.MetricsClient == nil { @@ -565,17 +572,17 @@ func getHTTPDashboard(w http.ResponseWriter, r *http.Request) { return } - // get experimentResult from metrics client - experimentResult, err := abn.MetricsClient.GetExperimentResult(namespace, experiment) + // get testResult from metrics client + testResult, err := abn.MetricsClient.GetExperimentResult(namespace, test) if err != nil { - errorMessage := fmt.Sprintf("cannot get experiment result with namespace %s, experiment %s", namespace, experiment) + errorMessage := fmt.Sprintf("cannot get experiment result with namespace %s, test %s", namespace, test) log.Logger.Error(errorMessage) http.Error(w, errorMessage, http.StatusBadRequest) return } // JSON marshal the dashboard - dashboardBytes, err := json.Marshal(getHTTPDashboardHelper(experimentResult)) + dashboardBytes, err := json.Marshal(getHTTPDashboardHelper(testResult)) if err != nil { errorMessage := "cannot JSON marshal HTTP dashboard" log.Logger.Error(errorMessage) @@ -628,7 +635,7 @@ func getGRPCEndpointRow(ghzRunnerReport *runner.Report) ghzEndpointRow { return row } -func getGRPCDashboardHelper(experimentResult *base.ExperimentResult) ghzDashboard { +func getGRPCDashboardHelper(experimentResult *util.ExperimentResult) ghzDashboard { dashboard := ghzDashboard{ Endpoints: map[string]ghzEndpointRow{}, ExperimentResult: dashboardExperimentResult{ @@ -654,7 +661,7 @@ func getGRPCDashboardHelper(experimentResult *base.ExperimentResult) ghzDashboar return dashboard } - ghzResult := base.GHZResult{} + ghzResult := util.GHZResult{} err = json.Unmarshal(ghzTaskDataBytes, &ghzResult) if err != nil { log.Logger.Error("cannot unmarshal ghz task data into GHZResult") @@ -670,6 +677,7 @@ func getGRPCDashboardHelper(experimentResult *base.ExperimentResult) ghzDashboar return dashboard } +// getGRPCDashboard handles GET /getGRPCDashboard with query parameter test=name and namespace=namespace func getGRPCDashboard(w http.ResponseWriter, r *http.Request) { log.Logger.Trace("getGRPCDashboard called") defer log.Logger.Trace("getGRPCDashboard completed") @@ -687,13 +695,13 @@ func getGRPCDashboard(w http.ResponseWriter, r *http.Request) { return } - experiment := r.URL.Query().Get("experiment") - if experiment == "" { - http.Error(w, "no experiment specified", http.StatusBadRequest) + test := r.URL.Query().Get("test") + if test == "" { + http.Error(w, "no test specified", http.StatusBadRequest) return } - log.Logger.Tracef("getGRPCDashboard called for namespace %s and experiment %s", namespace, experiment) + log.Logger.Tracef("getGRPCDashboard called for namespace %s and test %s", namespace, test) // get ghz result from metrics client if abn.MetricsClient == nil { @@ -701,17 +709,17 @@ func getGRPCDashboard(w http.ResponseWriter, r *http.Request) { return } - // get experimentResult from metrics client - experimentResult, err := abn.MetricsClient.GetExperimentResult(namespace, experiment) + // get testResult from metrics client + testResult, err := abn.MetricsClient.GetExperimentResult(namespace, test) if err != nil { - errorMessage := fmt.Sprintf("cannot get experiment result with namespace %s, experiment %s", namespace, experiment) + errorMessage := fmt.Sprintf("cannot get experiment result with namespace %s, test %s", namespace, test) log.Logger.Error(errorMessage) http.Error(w, errorMessage, http.StatusBadRequest) return } // JSON marshal the dashboard - dashboardBytes, err := json.Marshal(getGRPCDashboardHelper(experimentResult)) + dashboardBytes, err := json.Marshal(getGRPCDashboardHelper(testResult)) if err != nil { errorMessage := "cannot JSON marshal gRPC dashboard" log.Logger.Error(errorMessage) @@ -724,10 +732,10 @@ func getGRPCDashboard(w http.ResponseWriter, r *http.Request) { _, _ = w.Write(dashboardBytes) } -// putExperimentResult handles PUT /experimentResult with query parameter application=namespace/name +// putExperimentResult handles PUT /testResult with query parameter test=name and namespace=namespace func putExperimentResult(w http.ResponseWriter, r *http.Request) { - log.Logger.Trace("putResult called") - defer log.Logger.Trace("putResult completed") + log.Logger.Trace("putExperimentResult called") + defer log.Logger.Trace("putExperimentResult completed") // verify method if r.Method != http.MethodPut { @@ -742,13 +750,13 @@ func putExperimentResult(w http.ResponseWriter, r *http.Request) { return } - experiment := r.URL.Query().Get("experiment") + experiment := r.URL.Query().Get("test") if experiment == "" { - http.Error(w, "no experiment specified", http.StatusBadRequest) + http.Error(w, "no test specified", http.StatusBadRequest) return } - log.Logger.Tracef("putResult called for namespace %s and experiment %s", namespace, experiment) + log.Logger.Tracef("putExperimentResult called for namespace %s and test %s", namespace, experiment) defer func() { err := r.Body.Close() diff --git a/metrics/server_test.go b/metrics/server_test.go index f818860c6..3d0e1e640 100644 --- a/metrics/server_test.go +++ b/metrics/server_test.go @@ -573,10 +573,10 @@ func TestReadConfigSetPort(t *testing.T) { assert.Equal(t, expectedPortNumber, *conf.Port) } -func TestGetMetricsInvalidMethod(t *testing.T) { +func TestGetABNDashboardInvalidMethod(t *testing.T) { w := httptest.NewRecorder() - req := httptest.NewRequest(http.MethodPost, "/metrics", nil) - getMetrics(w, req) + req := httptest.NewRequest(http.MethodPost, util.AbnDashboard, nil) + getAbnDashboard(w, req) res := w.Result() defer func() { err := res.Body.Close() @@ -585,10 +585,10 @@ func TestGetMetricsInvalidMethod(t *testing.T) { assert.Equal(t, http.StatusMethodNotAllowed, res.StatusCode) } -func TestGetMetricsMissingParameter(t *testing.T) { +func TestGetABNDashboardMissingParameter(t *testing.T) { w := httptest.NewRecorder() - req := httptest.NewRequest(http.MethodGet, "/metrics", nil) - getMetrics(w, req) + req := httptest.NewRequest(http.MethodGet, util.AbnDashboard, nil) + getAbnDashboard(w, req) res := w.Result() defer func() { err := res.Body.Close() @@ -597,10 +597,10 @@ func TestGetMetricsMissingParameter(t *testing.T) { assert.Equal(t, http.StatusBadRequest, res.StatusCode) } -func TestGetMetricsNoRouteMap(t *testing.T) { +func TestGetABNDashboardNoRouteMap(t *testing.T) { w := httptest.NewRecorder() - req := httptest.NewRequest(http.MethodGet, "/metrics?application=default%2Ftest", nil) - getMetrics(w, req) + req := httptest.NewRequest(http.MethodGet, util.AbnDashboard+"?application=test&namespace=default", nil) + getAbnDashboard(w, req) res := w.Result() defer func() { err := res.Body.Close() @@ -617,7 +617,7 @@ func (cm *testRoutemaps) GetAllRoutemaps() controllers.RoutemapsInterface { return &cm.allroutemaps } -func TestGetMetrics(t *testing.T) { +func TestGetABNDashboard(t *testing.T) { testRM := testRoutemaps{ allroutemaps: setupRoutemaps(t, *getTestRM("default", "test")), } @@ -655,8 +655,8 @@ func TestGetMetrics(t *testing.T) { w := httptest.NewRecorder() rm := allRoutemaps.GetAllRoutemaps().GetRoutemapFromNamespaceName("default", "test") assert.NotNil(t, rm) - req := httptest.NewRequest(http.MethodGet, "/metrics?application=default%2Ftest", nil) - getMetrics(w, req) + req := httptest.NewRequest(http.MethodGet, util.AbnDashboard+"?application=test&namespace=default", nil) + getAbnDashboard(w, req) res := w.Result() defer func() { err := res.Body.Close() @@ -891,7 +891,7 @@ func TestGetGRPCDashboardHelper(t *testing.T) { func TestPutExperimentResultInvalidMethod(t *testing.T) { w := httptest.NewRecorder() - req := httptest.NewRequest(http.MethodGet, util.ExperimentResultPath, nil) + req := httptest.NewRequest(http.MethodGet, util.TestResultPath, nil) putExperimentResult(w, req) res := w.Result() defer func() { @@ -917,7 +917,7 @@ func TestPutExperimentResultMissingParameter(t *testing.T) { }, { queryParams: url.Values{ - "experiment": {"default"}, + "test": {"default"}, }, expectedStatusCode: http.StatusBadRequest, }, @@ -926,7 +926,7 @@ func TestPutExperimentResultMissingParameter(t *testing.T) { for _, test := range tests { w := httptest.NewRecorder() - u, err := url.ParseRequestURI(util.ExperimentResultPath) + u, err := url.ParseRequestURI(util.TestResultPath) assert.NoError(t, err) u.RawQuery = test.queryParams.Encode() urlStr := fmt.Sprintf("%v", u) @@ -954,11 +954,11 @@ func TestPutExperimentResult(t *testing.T) { w := httptest.NewRecorder() // construct inputs to putExperimentResult - u, err := url.ParseRequestURI(util.ExperimentResultPath) + u, err := url.ParseRequestURI(util.TestResultPath) assert.NoError(t, err) params := url.Values{ - "namespace": {"default"}, - "experiment": {"default"}, + "namespace": {"default"}, + "test": {"default"}, } u.RawQuery = params.Encode() urlStr := fmt.Sprintf("%v", u) @@ -1021,7 +1021,7 @@ func TestGetHTTPDashboardMissingParameter(t *testing.T) { }, { queryParams: url.Values{ - "experiment": {"default"}, + "test": {"default"}, }, expectedStatusCode: http.StatusBadRequest, }, @@ -1079,8 +1079,8 @@ func TestGetHTTPDashboard(t *testing.T) { u, err := url.ParseRequestURI(util.HTTPDashboardPath) assert.NoError(t, err) params := url.Values{ - "namespace": {"default"}, - "experiment": {"default"}, + "namespace": {"default"}, + "test": {"default"}, } u.RawQuery = params.Encode() urlStr := fmt.Sprintf("%v", u) @@ -1133,7 +1133,7 @@ func TestGetGRPCDashboardMissingParameter(t *testing.T) { }, { queryParams: url.Values{ - "experiment": {"default"}, + "test": {"default"}, }, expectedStatusCode: http.StatusBadRequest, }, @@ -1191,8 +1191,8 @@ func TestGetGRPCDashboard(t *testing.T) { u, err := url.ParseRequestURI(util.GRPCDashboardPath) assert.NoError(t, err) params := url.Values{ - "namespace": {"default"}, - "experiment": {"default"}, + "namespace": {"default"}, + "test": {"default"}, } u.RawQuery = params.Encode() urlStr := fmt.Sprintf("%v", u)