mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
feat(BRIDGE-150): Observability service modification; user distinction utility & heartbeat; various observbility metrics & relevant integration tests
This commit is contained in:
38
tests/features/observability/all_metrics.feature
Normal file
38
tests/features/observability/all_metrics.feature
Normal file
@ -0,0 +1,38 @@
|
||||
Feature: Bridge send remote notification observability metrics
|
||||
Background:
|
||||
Given there exists an account with username "[user:user1]" and password "password"
|
||||
Then it succeeds
|
||||
When bridge starts
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible heartbeat metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible observability heartbeat metrics
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible user discrimination metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible user distinction metrics
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible sync message event failure observability metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible sync message event failure observability metrics
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible event loop message events observability metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible event loop message events observability metrics
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible sync message building failure observability metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible sync message building failure observability metrics
|
||||
Then it succeeds
|
||||
|
||||
Scenario: Test all possible sync message building success observability metrics
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And the user with username "[user:user1]" sends all possible sync message building success observability metrics
|
||||
Then it succeeds
|
||||
|
||||
|
||||
111
tests/observability_test.go
Normal file
111
tests/observability_test.go
Normal file
@ -0,0 +1,111 @@
|
||||
// Copyright (c) 2024 Proton AG
|
||||
//
|
||||
// This file is part of Proton Mail Bridge.
|
||||
//
|
||||
// Proton Mail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Proton Mail Bridge 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ProtonMail/go-proton-api"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/services/imapservice/observabilitymetrics/evtloopmsgevents"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/services/imapservice/observabilitymetrics/syncmsgevents"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/services/observability"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/services/syncservice/observabilitymetrics"
|
||||
)
|
||||
|
||||
// userHeartbeatPermutationsObservability - corresponds to bridge_generic_user_heartbeat_total_v1.schema.json.
|
||||
func (s *scenario) userHeartbeatPermutationsObservability(username string) error {
|
||||
metrics := observability.GenerateAllHeartbeatMetricPermutations()
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
batch := proton.ObservabilityBatch{Metrics: metrics}
|
||||
return c.SendObservabilityBatch(ctx, batch)
|
||||
})
|
||||
}
|
||||
|
||||
// userDistinctionMetricsPermutationsObservability - corresponds to:
|
||||
// bridge_sync_errors_users_total_v1.schema.json
|
||||
// bridge_event_loop_events_errors_users_total_v1.schema.json.
|
||||
func (s *scenario) userDistinctionMetricsPermutationsObservability(username string) error {
|
||||
batch := proton.ObservabilityBatch{
|
||||
Metrics: observability.GenerateAllUsedDistinctionMetricPermutations()}
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// syncFailureMessageEventsObservability - corresponds to bridge_sync_message_event_failures_total_v1.schema.json.
|
||||
func (s *scenario) syncFailureMessageEventsObservability(username string) error {
|
||||
batch := proton.ObservabilityBatch{
|
||||
Metrics: []proton.ObservabilityMetric{
|
||||
syncmsgevents.GenerateSyncFailureCreateMessageEventMetric(),
|
||||
syncmsgevents.GenerateSyncFailureDeleteMessageEventMetric(),
|
||||
},
|
||||
}
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// eventLoopFailureMessageEventsObservability - corresponds to bridge_event_loop_message_event_failures_total_v1.schema.json.
|
||||
func (s *scenario) eventLoopFailureMessageEventsObservability(username string) error {
|
||||
batch := proton.ObservabilityBatch{
|
||||
Metrics: []proton.ObservabilityMetric{
|
||||
evtloopmsgevents.GenerateMessageEventFailedToBuildDraft(),
|
||||
evtloopmsgevents.GenerateMessageEventFailedToBuildMessage(),
|
||||
evtloopmsgevents.GenerateMessageEventFailureCreateMessageMetric(),
|
||||
evtloopmsgevents.GenerateMessageEventFailureDeleteMessageMetric(),
|
||||
evtloopmsgevents.GenerateMessageEventFailureUpdateMetric(),
|
||||
evtloopmsgevents.GenerateMessageEventUpdateChannelDoesNotExist(),
|
||||
},
|
||||
}
|
||||
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// syncFailureMessageBuiltObservability - corresponds to bridge_sync_message_event_failures_total_v1.schema.json.
|
||||
func (s *scenario) syncFailureMessageBuiltObservability(username string) error {
|
||||
batch := proton.ObservabilityBatch{
|
||||
Metrics: []proton.ObservabilityMetric{
|
||||
observabilitymetrics.GenerateNoUnlockedKeyringMetric(),
|
||||
observabilitymetrics.GenerateFailedToBuildMetric(),
|
||||
},
|
||||
}
|
||||
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// syncSuccessMessageBuiltObservability - corresponds to bridge_sync_message_build_success_total_v1.schema.json.
|
||||
func (s *scenario) syncSuccessMessageBuiltObservability(username string) error {
|
||||
batch := proton.ObservabilityBatch{
|
||||
Metrics: []proton.ObservabilityMetric{
|
||||
observabilitymetrics.GenerateMessageBuiltSuccessMetric(),
|
||||
},
|
||||
}
|
||||
|
||||
return s.t.withClientPass(context.Background(), username, s.t.getUserByName(username).userPass, func(ctx context.Context, c *proton.Client) error {
|
||||
err := c.SendObservabilityBatch(ctx, batch)
|
||||
return err
|
||||
})
|
||||
}
|
||||
@ -218,6 +218,12 @@ func (s *scenario) steps(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^the contact "([^"]*)" of user "([^"]*)" has public key from file "([^"]*)"$`, s.contactOfUserHasPubKeyFromFile)
|
||||
|
||||
// ==== OBSERVABILITY METRICS ====
|
||||
ctx.Step(`^the user with username "([^"]*)" sends the following remote notification observability metric "([^"]*)"`,
|
||||
ctx.Step(`^the user with username "([^"]*)" sends the following remote notification observability metric "([^"]*)"$`,
|
||||
s.userRemoteNotificationMetricTest)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible observability heartbeat metrics$`, s.userHeartbeatPermutationsObservability)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible user distinction metrics$`, s.userDistinctionMetricsPermutationsObservability)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible sync message event failure observability metrics$`, s.syncFailureMessageEventsObservability)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible event loop message events observability metrics$`, s.eventLoopFailureMessageEventsObservability)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible sync message building failure observability metrics$`, s.syncFailureMessageBuiltObservability)
|
||||
ctx.Step(`^the user with username "([^"]*)" sends all possible sync message building success observability metrics$`, s.syncSuccessMessageBuiltObservability)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user