mirror of
https://github.com/strukturag/nextcloud-spreed-signaling.git
synced 2025-04-11 14:21:18 +00:00
Lint prometheus stats.
This commit is contained in:
parent
70f9f7ea91
commit
5d431e5612
4 changed files with 50 additions and 0 deletions
30
mcu_common_test.go
Normal file
30
mcu_common_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Standalone signaling server for the Nextcloud Spreed app.
|
||||
* Copyright (C) 2021 struktur AG
|
||||
*
|
||||
* @author Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package signaling
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommonMcuStats(t *testing.T) {
|
||||
collectAndLint(t, commonMcuStats...)
|
||||
}
|
|
@ -106,4 +106,6 @@ func TestPublisherStatsCounter(t *testing.T) {
|
|||
checkStatsValue(t, statsMcuPublisherStreamTypesCurrent.WithLabelValues("video"), 0)
|
||||
checkStatsValue(t, statsMcuSubscriberStreamTypesCurrent.WithLabelValues("audio"), 0)
|
||||
checkStatsValue(t, statsMcuSubscriberStreamTypesCurrent.WithLabelValues("video"), 0)
|
||||
|
||||
collectAndLint(t, commonMcuStats...)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestMcuProxyStats(t *testing.T) {
|
||||
collectAndLint(t, proxyMcuStats...)
|
||||
}
|
||||
|
||||
func newProxyConnectionWithCountry(country string) *mcuProxyConnection {
|
||||
conn := &mcuProxyConnection{}
|
||||
conn.country.Store(country)
|
||||
|
|
|
@ -37,3 +37,17 @@ func checkStatsValue(t *testing.T, collector prometheus.Collector, value float64
|
|||
t.Errorf("Expected value %f for %s, got %f", value, desc, v)
|
||||
}
|
||||
}
|
||||
|
||||
func collectAndLint(t *testing.T, collectors ...prometheus.Collector) {
|
||||
for _, collector := range collectors {
|
||||
problems, err := testutil.CollectAndLint(collector)
|
||||
if err != nil {
|
||||
t.Errorf("Error linting %+v: %s", collector, err)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, problem := range problems {
|
||||
t.Errorf("Problem with %s: %s", problem.Metric, problem.Text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue