...

Source file src/github.com/prometheus/procfs/fscache_test.go

Documentation: github.com/prometheus/procfs

     1  // Copyright 2019 The Prometheus Authors
     2  // Licensed under the Apache License, Version 2.0 (the "License");
     3  // you may not use this file except in compliance with the License.
     4  // You may obtain a copy of the License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package procfs
    15  
    16  import (
    17  	"reflect"
    18  	"testing"
    19  )
    20  
    21  func TestFscacheinfo(t *testing.T) {
    22  	expected := Fscacheinfo{
    23  		IndexCookiesAllocated:                              3,
    24  		DataStorageCookiesAllocated:                        67877,
    25  		SpecialCookiesAllocated:                            0,
    26  		ObjectsAllocated:                                   67473,
    27  		ObjectAllocationsFailure:                           0,
    28  		ObjectsAvailable:                                   67473,
    29  		ObjectsDead:                                        388,
    30  		ObjectsWithoutCoherencyCheck:                       12,
    31  		ObjectsWithCoherencyCheck:                          33,
    32  		ObjectsNeedCoherencyCheckUpdate:                    44,
    33  		ObjectsDeclaredObsolete:                            55,
    34  		PagesMarkedAsBeingCached:                           547164,
    35  		UncachePagesRequestSeen:                            364577,
    36  		AcquireCookiesRequestSeen:                          67880,
    37  		AcquireRequestsWithNullParent:                      98,
    38  		AcquireRequestsRejectedNoCacheAvailable:            25,
    39  		AcquireRequestsSucceeded:                           67780,
    40  		AcquireRequestsRejectedDueToError:                  39,
    41  		AcquireRequestsFailedDueToEnomem:                   26,
    42  		LookupsNumber:                                      67473,
    43  		LookupsNegative:                                    67470,
    44  		LookupsPositive:                                    58,
    45  		ObjectsCreatedByLookup:                             67473,
    46  		LookupsTimedOutAndRequed:                           85,
    47  		InvalidationsNumber:                                14,
    48  		InvalidationsRunning:                               13,
    49  		UpdateCookieRequestSeen:                            7,
    50  		UpdateRequestsWithNullParent:                       3,
    51  		UpdateRequestsRunning:                              8,
    52  		RelinquishCookiesRequestSeen:                       394,
    53  		RelinquishCookiesWithNullParent:                    1,
    54  		RelinquishRequestsWaitingCompleteCreation:          2,
    55  		RelinquishRetries:                                  3,
    56  		AttributeChangedRequestsSeen:                       6,
    57  		AttributeChangedRequestsQueued:                     5,
    58  		AttributeChangedRejectDueToEnobufs:                 4,
    59  		AttributeChangedFailedDueToEnomem:                  3,
    60  		AttributeChangedOps:                                2,
    61  		AllocationRequestsSeen:                             20,
    62  		AllocationOkRequests:                               19,
    63  		AllocationWaitingOnLookup:                          18,
    64  		AllocationsRejectedDueToEnobufs:                    17,
    65  		AllocationsAbortedDueToErestartsys:                 16,
    66  		AllocationOperationsSubmitted:                      15,
    67  		AllocationsWaitedForCPU:                            14,
    68  		AllocationsAbortedDueToObjectDeath:                 13,
    69  		RetrievalsReadRequests:                             151959,
    70  		RetrievalsOk:                                       82823,
    71  		RetrievalsWaitingLookupCompletion:                  23467,
    72  		RetrievalsReturnedEnodata:                          69136,
    73  		RetrievalsRejectedDueToEnobufs:                     15,
    74  		RetrievalsAbortedDueToErestartsys:                  69,
    75  		RetrievalsFailedDueToEnomem:                        43,
    76  		RetrievalsRequests:                                 151959,
    77  		RetrievalsWaitingCPU:                               42747,
    78  		RetrievalsAbortedDueToObjectDeath:                  44,
    79  		StoreWriteRequests:                                 225565,
    80  		StoreSuccessfulRequests:                            225565,
    81  		StoreRequestsOnPendingStorage:                      12,
    82  		StoreRequestsRejectedDueToEnobufs:                  13,
    83  		StoreRequestsFailedDueToEnomem:                     14,
    84  		StoreRequestsSubmitted:                             69156,
    85  		StoreRequestsRunning:                               294721,
    86  		StorePagesWithRequestsProcessing:                   225565,
    87  		StoreRequestsDeleted:                               225565,
    88  		StoreRequestsOverStoreLimit:                        43,
    89  		ReleaseRequestsAgainstPagesWithNoPendingStorage:    364512,
    90  		ReleaseRequestsAgainstPagesStoredByTimeLockGranted: 2,
    91  		ReleaseRequestsIgnoredDueToInProgressStore:         43,
    92  		PageStoresCancelledByReleaseRequests:               12,
    93  		VmscanWaiting:                                      66,
    94  		OpsPending:                                         42753,
    95  		OpsRunning:                                         221129,
    96  		OpsEnqueued:                                        628798,
    97  		OpsCancelled:                                       11,
    98  		OpsRejected:                                        88,
    99  		OpsInitialised:                                     377538,
   100  		OpsDeferred:                                        27,
   101  		OpsReleased:                                        377538,
   102  		OpsGarbageCollected:                                37,
   103  		CacheopAllocationsinProgress:                       1,
   104  		CacheopLookupObjectInProgress:                      2,
   105  		CacheopLookupCompleteInPorgress:                    3,
   106  		CacheopGrabObjectInProgress:                        4,
   107  		CacheopInvalidations:                               5,
   108  		CacheopUpdateObjectInProgress:                      6,
   109  		CacheopDropObjectInProgress:                        7,
   110  		CacheopPutObjectInProgress:                         8,
   111  		CacheopAttributeChangeInProgress:                   9,
   112  		CacheopSyncCacheInProgress:                         10,
   113  		CacheopReadOrAllocPageInProgress:                   11,
   114  		CacheopReadOrAllocPagesInProgress:                  12,
   115  		CacheopAllocatePageInProgress:                      13,
   116  		CacheopAllocatePagesInProgress:                     14,
   117  		CacheopWritePagesInProgress:                        15,
   118  		CacheopUncachePagesInProgress:                      16,
   119  		CacheopDissociatePagesInProgress:                   17,
   120  		CacheevLookupsAndCreationsRejectedLackSpace:        18,
   121  		CacheevStaleObjectsDeleted:                         19,
   122  		CacheevRetiredWhenReliquished:                      20,
   123  		CacheevObjectsCulled:                               21,
   124  	}
   125  
   126  	have, err := getProcFixtures(t).Fscacheinfo()
   127  	if err != nil {
   128  		t.Fatal(err)
   129  	}
   130  
   131  	if !reflect.DeepEqual(have, expected) {
   132  		t.Logf("have: %+v", have)
   133  		t.Logf("expected: %+v", expected)
   134  		t.Errorf("structs are not equal")
   135  	}
   136  }
   137  

View as plain text