Browse Source

Lint prometheus stats.

pull/99/head
Joachim Bauch 6 months ago
parent
commit
5d431e5612
No known key found for this signature in database GPG Key ID: 77C1D22D53E15F02
  1. 30
      mcu_common_test.go
  2. 2
      mcu_janus_test.go
  3. 4
      mcu_proxy_test.go
  4. 14
      stats_prometheus_test.go

30
mcu_common_test.go

@ -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...)
}

2
mcu_janus_test.go

@ -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...)
}

4
mcu_proxy_test.go

@ -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)

14
stats_prometheus_test.go

@ -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…
Cancel
Save