From 773f7aa35bc2f197e1915e68cf201517f3894199 Mon Sep 17 00:00:00 2001 From: divyaac Date: Mon, 2 Dec 2024 09:44:57 -0800 Subject: [PATCH] Remove test from oss file --- .../activity_testonly_test.go | 74 ------------------- 1 file changed, 74 deletions(-) diff --git a/vault/external_tests/activity_testonly/activity_testonly_test.go b/vault/external_tests/activity_testonly/activity_testonly_test.go index 38094944953d..cd9dfb21574b 100644 --- a/vault/external_tests/activity_testonly/activity_testonly_test.go +++ b/vault/external_tests/activity_testonly/activity_testonly_test.go @@ -892,77 +892,3 @@ func TestHandleQuery_MultipleMounts(t *testing.T) { }) } } - -// Test_ActivityLog_PreviousMonths_GlobalLocalClients verifies that -// local and global clients seen in previous months are correctly written -// to storage by the clientcountutil library, and are subsequently correctly extracted -// when a call to the counters API is made. -func Test_ActivityLog_PreviousMonths_GlobalLocalClients(t *testing.T) { - t.Parallel() - - cluster := minimal.NewTestSoloCluster(t, nil) - client := cluster.Cores[0].Client - _, err := client.Logical().Write("sys/internal/counters/config", map[string]interface{}{ - "enabled": "enable", - }) - require.NoError(t, err) - for i := 0; i < 2; i++ { - _, err = client.Logical().Write(fmt.Sprintf("sys/namespaces/ns%d", i), nil) - require.NoError(t, err) - } - - now := time.Now().UTC() - - localPaths, globalPaths, err := clientcountutil.NewActivityLogData(client). - NewPreviousMonthData(2). - NewClientsSeen(10, clientcountutil.WithClientNamespace("ns0"), clientcountutil.WithClientMount("identity")). - NewClientsSeen(20, clientcountutil.WithClientNamespace("ns1"), clientcountutil.WithClientMount("sys")). - NewClientsSeen(30, clientcountutil.WithClientNamespace("ns0"), clientcountutil.WithClientMount("sys")). - NewClientsSeen(40, clientcountutil.WithClientNamespace("ns1"), clientcountutil.WithClientMount("identity")). - NewPreviousMonthData(1). - NewClientsSeen(10, clientcountutil.WithClientNamespace("ns0"), clientcountutil.WithClientMount("cubbyhole")). - NewClientsSeen(20, clientcountutil.WithClientNamespace("ns1"), clientcountutil.WithClientMount("sys")). - NewClientsSeen(30, clientcountutil.WithClientNamespace("ns0"), clientcountutil.WithClientMount("sys")). - Write(context.Background(), generation.WriteOptions_WRITE_PRECOMPUTED_QUERIES, generation.WriteOptions_WRITE_ENTITIES) - require.NoError(t, err) - // cubbyhole is local and is created for one month, one segment for local should exist - require.Len(t, localPaths, 1) - // global segments should exist for two months seen - require.Len(t, globalPaths, 2) - - resp, err := client.Logical().ReadWithData("sys/internal/counters/activity", map[string][]string{ - "end_time": {timeutil.EndOfMonth(timeutil.MonthsPreviousTo(1, now)).Format(time.RFC3339)}, - "start_time": {timeutil.StartOfMonth(timeutil.MonthsPreviousTo(2, now)).Format(time.RFC3339)}, - }) - - require.NoError(t, err) - var byNamespace []*vault.ResponseNamespace - err = mapstructure.Decode(resp.Data["by_namespace"], &byNamespace) - require.Len(t, byNamespace, 2) - mountClientCount := func(mounts []*vault.ResponseMount, expect map[string]int) { - mountSet := make(map[string]int, len(mounts)) - for _, mount := range mounts { - mountSet[mount.MountPath] = mount.Counts.Clients - } - require.Equal(t, expect, mountSet) - } - for _, byNS := range byNamespace { - switch byNS.NamespacePath { - case "ns0/": - require.Len(t, byNS.Mounts, 3) - mountClientCount(byNS.Mounts, map[string]int{ - "identity/": 10, - "sys/": 60, - "cubbyhole/": 10, - }) - case "ns1/": - require.Len(t, byNS.Mounts, 2) - mountClientCount(byNS.Mounts, map[string]int{ - "identity/": 40, - "sys/": 40, - }) - default: - require.Fail(t, "unknown namespace", byNS.NamespacePath) - } - } -}