func TestPrometheusClientCounterWithFullLabels(t *testing.T) {
	config.Global.Set("prometheus.namelabel", true)
	config.Global.Set("prometheus.sitecodelabel", true)
	store := data.NewSimpleInMemoryStore()
	test.ExecuteCompletePipe(t, store)

	// It is kinda complicated to collect values from CounterVecs,
	// so for now this test simply makes sure that the application doesn't
	// crash if extended node labels are activated.
}
Exemple #2
0
func TestCompletePipeWithBoltStore(t *testing.T) {
	assert := assert.New(t)
	log.SetLevel(log.ErrorLevel)
	dbPath := "./bolt.db"
	defer os.RemoveAll(dbPath)
	store, err := data.NewBoltStore(dbPath)
	assert.Nil(err)
	assert.NotNil(store)
	test.ExecuteCompletePipe(t, store)
	store.Close()
}
Exemple #3
0
func TestCompletePipe(t *testing.T) {
	assert := assert.New(t)
	log.SetLevel(log.ErrorLevel)
	store := data.NewSimpleInMemoryStore()
	test.ExecuteCompletePipe(t, store)

	graphGenerator := &meshviewer.GraphGenerator{Store: store}
	nodesGenerator := &meshviewer.NodesJsonGenerator{Store: store}

	graph := graphGenerator.GenerateGraph()
	assert.NotNil(graph)
	assert.Equal(169, len(graph.Batadv.Nodes))
	assert.Equal(66, len(graph.Batadv.Links))

	nodes := nodesGenerator.GetNodesJson()
	assert.NotNil(nodes)
}
Exemple #4
0
func TestGeneratingNodeGraph(t *testing.T) {
	assert := assert.New(t)
	log.SetLevel(log.ErrorLevel)
	assert.True(true)
	store := data.NewSimpleInMemoryStore()
	test.ExecuteCompletePipe(t, store)

	graphGenerator := &GraphGenerator{Store: store}
	graphGenerator.UpdateGraphJson()

	graphData := &GraphJson{}
	err := json.Unmarshal([]byte(graphGenerator.cachedJsonString), graphData)

	assert.Nil(err)
	assert.NotNil(graphData)
	testForDoublettes(assert, graphData.Batadv.Nodes)
}
Exemple #5
0
func TestNodesJsonHasFlaggedUplinks(t *testing.T) {
	assert := assert.New(t)
	store := data.NewSimpleInMemoryStore()
	test.ExecuteCompletePipe(t, store)

	statistics := data.StatisticsStruct{}
	err := json.Unmarshal([]byte(uplinkStats), &statistics)
	assert.Nil(err)

	store.PutStatistics(statistics)

	generator := &NodesJsonGenerator{Store: store}
	nodesJson := generator.GetNodesJson()

	uplinkFound := false
	for _, node := range nodesJson.Nodes {
		if node.Flags.Uplink && node.Nodeinfo.NodeId == "e8de27252554" {
			uplinkFound = true
			break
		}
	}
	assert.True(uplinkFound, "No node was flagged as uplink")

	statistics = data.StatisticsStruct{}
	err = json.Unmarshal([]byte(nonUplinkStats), &statistics)
	assert.Nil(err)

	uplinkFound = false
	store.PutStatistics(statistics)
	nodesJson = generator.GetNodesJson()
	for _, node := range nodesJson.Nodes {
		if !node.Flags.Uplink && node.Nodeinfo.NodeId == "e8de27252554" {
			uplinkFound = true
			break
		}
	}
	assert.True(uplinkFound, "A node was not correctly flagged")
}