console: remove /fields endpoint as we don't use it

This commit is contained in:
Vincent Bernat
2022-05-15 15:22:04 +02:00
parent 04d818e00f
commit eefd7088b9
5 changed files with 0 additions and 118 deletions

View File

@@ -33,24 +33,6 @@ func (bi *Bimap[K, V]) LoadKey(v V) (K, bool) {
return k, ok
}
// Keys returns a slice of the keys in the bimap.
func (bi *Bimap[K, V]) Keys() []K {
var keys []K
for k := range bi.forward {
keys = append(keys, k)
}
return keys
}
// Values returns a slice of the values in the bimap.
func (bi *Bimap[K, V]) Values() []V {
var values []V
for v := range bi.inverse {
values = append(values, v)
}
return values
}
// String returns a string representation of the bimap.
func (bi *Bimap[K, V]) String() string {
return fmt.Sprintf("Bi%v", bi.forward)

View File

@@ -59,29 +59,3 @@ func TestBimapLoadKey(t *testing.T) {
}
}
}
func TestBimapKeys(t *testing.T) {
input := helpers.NewBimap(map[int]string{
1: "hello",
2: "world",
3: "happy",
})
got := input.Keys()
expected := []int{1, 2, 3}
if diff := helpers.Diff(got, expected); diff != "" {
t.Errorf("Keys() (-want, +got):\n%s", diff)
}
}
func TestBimapValues(t *testing.T) {
input := helpers.NewBimap(map[int]string{
1: "hello",
2: "world",
3: "happy",
})
got := input.Values()
expected := []string{"hello", "world", "happy"}
if diff := helpers.Diff(got, expected); diff != "" {
t.Errorf("Values() (-want, +got):\n%s", diff)
}
}

View File

@@ -513,7 +513,3 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) {
gc.JSON(http.StatusOK, output)
}
func (c *Component) graphFieldsHandlerFunc(gc *gin.Context) {
gc.JSON(http.StatusOK, graphColumnMap.Values())
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
netHTTP "net/http"
"sort"
"strings"
"testing"
"time"
@@ -521,71 +520,3 @@ func TestGraphHandler(t *testing.T) {
t.Fatalf("POST /api/v0/console/graph (-got, +want):\n%s", diff)
}
}
func TestGraphFieldsHandler(t *testing.T) {
r := reporter.NewMock(t)
ch, _ := clickhousedb.NewMock(t, r)
h := http.NewMock(t, r)
c, err := New(r, Configuration{}, Dependencies{
Daemon: daemon.NewMock(t),
HTTP: h,
ClickHouseDB: ch,
})
if err != nil {
t.Fatalf("New() error:\n%+v", err)
}
helpers.StartStop(t, c)
resp, err := netHTTP.Get(fmt.Sprintf("http://%s/api/v0/console/graph/fields", h.Address))
if err != nil {
t.Fatalf("POST /api/v0/console/graph/fields:\n%+v", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
t.Errorf("POST /api/v0/console/graph/fields: got status code %d, not 200", resp.StatusCode)
}
gotContentType := resp.Header.Get("Content-Type")
if gotContentType != "application/json; charset=utf-8" {
t.Errorf("POST /api/v0/console/graph/fields Content-Type (-got, +want):\n-%s\n+%s",
gotContentType, "application/json; charset=utf-8")
}
decoder := json.NewDecoder(resp.Body)
var got []string
if err := decoder.Decode(&got); err != nil {
t.Fatalf("POST /api/v0/console/graph error:\n%+v", err)
}
expected := []string{
"ExporterAddress",
"ExporterName",
"ExporterGroup",
"SrcAddr",
"DstAddr",
"SrcAS",
"DstAS",
"SrcCountry",
"DstCountry",
"InIfName",
"OutIfName",
"InIfDescription",
"OutIfDescription",
"InIfSpeed",
"OutIfSpeed",
"InIfConnectivity",
"OutIfConnectivity",
"InIfProvider",
"OutIfProvider",
"InIfBoundary",
"OutIfBoundary",
"EType",
"Proto",
"SrcPort",
"DstPort",
"ForwardingStatus",
}
sort.Strings(expected)
sort.Strings(got)
if diff := helpers.Diff(got, expected); diff != "" {
t.Fatalf("POST /api/v0/console/graph/fields (-got, +want):\n%s", diff)
}
}

View File

@@ -82,7 +82,6 @@ func (c *Component) Start() error {
c.d.HTTP.GinRouter.GET("/api/v0/console/widget/top/:name", c.widgetTopHandlerFunc)
c.d.HTTP.GinRouter.GET("/api/v0/console/widget/graph", c.widgetGraphHandlerFunc)
c.d.HTTP.GinRouter.POST("/api/v0/console/graph", c.graphHandlerFunc)
c.d.HTTP.GinRouter.GET("/api/v0/console/graph/fields", c.graphFieldsHandlerFunc)
c.t.Go(func() error {
ticker := time.NewTicker(10 * time.Second)