@@ -1749,6 +1749,54 @@ func newTestQueryContext(tenantIDs []TenantID, q *Query) *QueryContext {
17491749 return NewQueryContext (context .Background (), qs , tenantIDs , false , q , false , nil )
17501750}
17511751
1752+ func TestStorageGetFieldNamesMultitenant (t * testing.T ) {
1753+ t .Parallel ()
1754+
1755+ path := t .TempDir ()
1756+ s := MustOpenStorage (path , & StorageConfig {
1757+ Retention : 24 * time .Hour ,
1758+ })
1759+ defer s .MustClose ()
1760+
1761+ now := time .Now ().UnixNano ()
1762+ lr := GetLogRows (nil , nil , nil , nil , "" )
1763+ for i := range 3 {
1764+ tenantID := TenantID {
1765+ AccountID : uint32 (i + 1 ),
1766+ ProjectID : uint32 (i + 11 ),
1767+ }
1768+ fields := []Field {
1769+ {Name : "_msg" , Value : fmt .Sprintf ("message-%d" , i )},
1770+ }
1771+ if i < 2 {
1772+ fields = append (fields ,
1773+ Field {Name : "vl_account_id" , Value : "stored-account-id" },
1774+ Field {Name : "vl_project_id" , Value : "stored-project-id" },
1775+ )
1776+ }
1777+ lr .mustAdd (tenantID , now + int64 (i ), fields )
1778+ }
1779+ s .MustAddRows (lr )
1780+ PutLogRows (lr )
1781+ s .DebugFlush ()
1782+
1783+ q := mustParseQuery ("*" )
1784+ qs := & QueryStats {}
1785+ qctx := NewQueryContext (context .Background (), qs , nil , true , q , false , nil )
1786+ results , err := s .GetFieldNames (qctx , "vl_" )
1787+ if err != nil {
1788+ t .Fatalf ("unexpected error: %s" , err )
1789+ }
1790+
1791+ resultsExpected := []ValueWithHits {
1792+ {"vl_account_id" , 3 },
1793+ {"vl_project_id" , 3 },
1794+ }
1795+ if ! reflect .DeepEqual (results , resultsExpected ) {
1796+ t .Fatalf ("unexpected result; got\n %v\n want\n %v" , results , resultsExpected )
1797+ }
1798+ }
1799+
17521800func TestGetTenantFilter (t * testing.T ) {
17531801 t .Parallel ()
17541802
0 commit comments