Exemple #1
0
func TestOriginTable(t *testing.T) {
	if _, ok := render.OriginTable(test.Report, "not-found"); ok {
		t.Errorf("unknown origin ID gave unexpected success")
	}
	for originID, want := range map[string]render.Table{
		test.Client54001NodeID: {
			Title:   "Origin Endpoint",
			Numeric: false,
			Rows: []render.Row{
				{"Endpoint", test.ClientIP, ""},
				{"Port", test.ClientPort54001, ""},
			},
		},
		test.ClientAddressNodeID: {
			Title:   "Origin Address",
			Numeric: false,
			Rows: []render.Row{
				{"Address", test.ClientIP, ""},
			},
		},
		test.ServerProcessNodeID: {
			Title:   "Origin Process",
			Numeric: false,
			Rank:    2,
			Rows: []render.Row{
				{"Name (comm)", "apache", ""},
				{"PID", test.ServerPID, ""},
			},
		},
		test.ServerHostNodeID: {
			Title:   "Origin Host",
			Numeric: false,
			Rank:    1,
			Rows: []render.Row{
				{"Host name", test.ServerHostName, ""},
				{"Load", "0.01 0.01 0.01", ""},
				{"Operating system", "Linux", ""},
			},
		},
	} {
		have, ok := render.OriginTable(test.Report, originID)
		if !ok {
			t.Errorf("%q: not OK", originID)
			continue
		}
		if !reflect.DeepEqual(want, have) {
			t.Errorf("%q: %s", originID, test.Diff(want, have))
		}
	}
}
Exemple #2
0
func TestOriginTable(t *testing.T) {
	if _, ok := render.OriginTable(test.Report, "not-found", false, false); ok {
		t.Errorf("unknown origin ID gave unexpected success")
	}
	for originID, want := range map[string]render.Table{test.ServerProcessNodeID: {
		Title:   fmt.Sprintf(`Process "apache" (%s)`, test.ServerPID),
		Numeric: false,
		Rank:    2,
		Rows:    []render.Row{},
	},
		test.ServerHostNodeID: {
			Title:   fmt.Sprintf("Host %q", test.ServerHostName),
			Numeric: false,
			Rank:    1,
			Rows: []render.Row{
				{"Load", "0.01 0.01 0.01", "", false},
				{"Operating system", "Linux", "", false},
			},
		},
	} {
		have, ok := render.OriginTable(test.Report, originID, false, false)
		if !ok {
			t.Errorf("%q: not OK", originID)
			continue
		}
		if !reflect.DeepEqual(want, have) {
			t.Errorf("%q: %s", originID, test.Diff(want, have))
		}
	}

	// Test host/container tags
	for originID, want := range map[string]render.Table{
		test.ServerProcessNodeID: {
			Title:   fmt.Sprintf(`Process "apache" (%s)`, test.ServerPID),
			Numeric: false,
			Rank:    2,
			Rows: []render.Row{
				{"Host", test.ServerHostID, "", false},
				{"Container ID", test.ServerContainerID, "", false},
			},
		},
		test.ServerContainerNodeID: {
			Title:   `Container "server"`,
			Numeric: false,
			Rank:    3,
			Rows: []render.Row{
				{"Host", test.ServerHostID, "", false},
				{"ID", test.ServerContainerID, "", false},
				{"Image ID", test.ServerContainerImageID, "", false},
				{fmt.Sprintf(`Label %q`, render.AmazonECSContainerNameLabel), `server`, "", false},
				{`Label "foo1"`, `bar1`, "", false},
				{`Label "foo2"`, `bar2`, "", false},
			},
		},
	} {
		have, ok := render.OriginTable(test.Report, originID, true, true)
		if !ok {
			t.Errorf("%q: not OK", originID)
			continue
		}
		if !reflect.DeepEqual(want, have) {
			t.Errorf("%q: %s", originID, test.Diff(want, have))
		}
	}

}
Exemple #3
0
func TestOriginTable(t *testing.T) {
	if _, ok := render.OriginTable(fixture.Report, "not-found", false, false); ok {
		t.Errorf("unknown origin ID gave unexpected success")
	}
	for originID, want := range map[string]render.Table{
		fixture.ServerProcessNodeID: {
			Title:   fmt.Sprintf(`Process "apache" (%s)`, fixture.ServerPID),
			Numeric: false,
			Rank:    2,
			Rows:    []render.Row{},
		},
		fixture.ServerHostNodeID: {
			Title:   fmt.Sprintf("Host %q", fixture.ServerHostName),
			Numeric: false,
			Rank:    1,
			Rows: []render.Row{
				{Key: "Load (1m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
				{Key: "Load (5m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
				{Key: "Load (15m)", ValueMajor: "0.01", Metric: &fixture.LoadMetric, ValueType: "sparkline"},
				{Key: "Operating system", ValueMajor: "Linux"},
			},
		},
	} {
		have, ok := render.OriginTable(fixture.Report, originID, false, false)
		if !ok {
			t.Errorf("%q: not OK", originID)
			continue
		}
		if !reflect.DeepEqual(want, have) {
			t.Errorf("%q: %s", originID, test.Diff(want, have))
		}
	}

	// Test host/container tags
	for originID, want := range map[string]render.Table{
		fixture.ServerProcessNodeID: {
			Title:   fmt.Sprintf(`Process "apache" (%s)`, fixture.ServerPID),
			Numeric: false,
			Rank:    2,
			Rows: []render.Row{
				{Key: "Host", ValueMajor: fixture.ServerHostID},
				{Key: "Container ID", ValueMajor: fixture.ServerContainerID},
			},
		},
		fixture.ServerContainerNodeID: {
			Title:   `Container "server"`,
			Numeric: false,
			Rank:    3,
			Rows: []render.Row{
				{Key: "Host", ValueMajor: fixture.ServerHostID},
				{Key: "State", ValueMajor: "running"},
				{Key: "ID", ValueMajor: fixture.ServerContainerID},
				{Key: "Image ID", ValueMajor: fixture.ServerContainerImageID},
				{Key: fmt.Sprintf(`Label %q`, render.AmazonECSContainerNameLabel), ValueMajor: `server`},
				{Key: `Label "foo1"`, ValueMajor: `bar1`},
				{Key: `Label "foo2"`, ValueMajor: `bar2`},
				{Key: `Label "io.kubernetes.pod.name"`, ValueMajor: "ping/pong-b"},
			},
		},
	} {
		have, ok := render.OriginTable(fixture.Report, originID, true, true)
		if !ok {
			t.Errorf("%q: not OK", originID)
			continue
		}
		if !reflect.DeepEqual(want, have) {
			t.Errorf("%q: %s", originID, test.Diff(want, have))
		}
	}
}