...

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

Documentation: github.com/prometheus/procfs

     1  // Copyright 2023 Prometheus Team
     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  	"testing"
    18  )
    19  
    20  func TestTLSStat(t *testing.T) {
    21  	tlsStats, err := getProcFixtures(t).NewTLSStat()
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  
    26  	for _, test := range []struct {
    27  		name string
    28  		want int
    29  		got  int
    30  	}{
    31  		{name: "TLSCurrTxSw", want: 5, got: tlsStats.TLSCurrTxSw},
    32  		{name: "TLSCurrRxSw", want: 5, got: tlsStats.TLSCurrRxSw},
    33  		{name: "TLSCurrTxDevice", want: 0, got: tlsStats.TLSCurrTxDevice},
    34  		{name: "TLSCurrRxDevice", want: 0, got: tlsStats.TLSCurrRxDevice},
    35  		{name: "TLSTxSw", want: 8711, got: tlsStats.TLSTxSw},
    36  		{name: "TLSTxSw", want: 8711, got: tlsStats.TLSRxSw},
    37  		{name: "TLSTxDevice", want: 0, got: tlsStats.TLSTxDevice},
    38  		{name: "TLSRxDevice", want: 0, got: tlsStats.TLSRxDevice},
    39  		{name: "TLSDecryptError", want: 13, got: tlsStats.TLSDecryptError},
    40  		{name: "TLSRxDeviceResync", want: 0, got: tlsStats.TLSRxDeviceResync},
    41  		{name: "TLSDecryptRetry", want: 0, got: tlsStats.TLSDecryptRetry},
    42  		{name: "TLSRxNoPadViolation", want: 0, got: tlsStats.TLSRxNoPadViolation},
    43  	} {
    44  		if test.want != test.got {
    45  			t.Errorf("Want %s %d, have %d", test.name, test.want, test.got)
    46  		}
    47  	}
    48  }
    49  

View as plain text