mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
Whenever a volume is provisioned and de-provisioned we will send a google event with mainly following details : 1. pvName (will shown as app title in google analytics) 2. size of the volume 3. event type : volume-provision, volume-deprovision 4. storage type zfs-localpv 5. replicacount as 1 6. ClientId as default namespace uuid Apart from this, we send the event once in 24 hr, which will have some info like number of nodes, node type, kubernetes version etc. This metric is cotrolled by OPENEBS_IO_ENABLE_ANALYTICS env. We can set it to false if we don't want to send the metrics. Signed-off-by: Pawan <pawan@mayadata.io>
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
// Copyright 2020 The OpenEBS Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package usage
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestGetPingPeriod(t *testing.T) {
|
|
beforeFunc := func(value string) {
|
|
if err := os.Setenv(string(OpenEBSPingPeriod), value); err != nil {
|
|
t.Logf("Unable to set environment variable")
|
|
}
|
|
}
|
|
afterFunc := func() {
|
|
if err := os.Unsetenv(string(OpenEBSPingPeriod)); err != nil {
|
|
t.Logf("Unable to unset environment variable")
|
|
}
|
|
}
|
|
testSuite := map[string]struct {
|
|
OpenEBSPingPeriodValue string
|
|
ExpectedPeriodValue time.Duration
|
|
}{
|
|
"24 seconds": {"24s", 86400000000000},
|
|
"24 minutes": {"24m", 86400000000000},
|
|
"24 hours": {"24h", 86400000000000},
|
|
"Negative 24 hours": {"-24h", 86400000000000},
|
|
"Random string input": {"Apache", 86400000000000},
|
|
"Two hours": {"2h", 7200000000000},
|
|
"Three hundred hours": {"300h", 1080000000000000},
|
|
"Fifty two seconds": {"52000000000ns", 86400000000000},
|
|
"Empty env value": {"", 86400000000000},
|
|
}
|
|
for testKey, testData := range testSuite {
|
|
beforeFunc(testData.OpenEBSPingPeriodValue)
|
|
evaluatedValue := getPingPeriod()
|
|
if evaluatedValue != testData.ExpectedPeriodValue {
|
|
t.Fatalf("Tests failed for %s, expected=%d, got=%d", testKey, testData.ExpectedPeriodValue, evaluatedValue)
|
|
}
|
|
afterFunc()
|
|
}
|
|
}
|