...

Source file src/github.com/prometheus/procfs/sysfs/class_fibrechannel_test.go

Documentation: github.com/prometheus/procfs/sysfs

     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  //go:build linux
    15  // +build linux
    16  
    17  package sysfs
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/google/go-cmp/cmp"
    23  )
    24  
    25  func TestFibreChannelClass(t *testing.T) {
    26  	fs, err := NewFS(sysTestFixtures)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	got, err := fs.FibreChannelClass()
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	want := FibreChannelClass{
    37  		"host0": FibreChannelHost{
    38  			Name:             "host0",
    39  			Speed:            "16 Gbit",
    40  			PortState:        "Online",
    41  			PortType:         "Point-To-Point (direct nport connection)",
    42  			PortName:         "1000e0071bce95f2",
    43  			SymbolicName:     "Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux",
    44  			NodeName:         "2000e0071bce95f2",
    45  			PortID:           "000002",
    46  			FabricName:       "0",
    47  			DevLossTMO:       "30",
    48  			SupportedClasses: "Class 3",
    49  			SupportedSpeeds:  "4 Gbit, 8 Gbit, 16 Gbit",
    50  			Counters: FibreChannelCounters{
    51  				DumpedFrames:          ^uint64(0),
    52  				ErrorFrames:           0,
    53  				InvalidCRCCount:       0x2,
    54  				RXFrames:              0x3,
    55  				RXWords:               0x4,
    56  				TXFrames:              0x5,
    57  				TXWords:               0x6,
    58  				SecondsSinceLastReset: 0x7,
    59  				InvalidTXWordCount:    0x8,
    60  				LinkFailureCount:      0x9,
    61  				LossOfSyncCount:       0x10,
    62  				LossOfSignalCount:     0x11,
    63  				NosCount:              0x12,
    64  				FCPPacketAborts:       0x13,
    65  			},
    66  		},
    67  		"host1": FibreChannelHost{
    68  			Name:      "host1",
    69  			PortState: "Online",
    70  			Counters: FibreChannelCounters{
    71  				DumpedFrames:          0,
    72  				ErrorFrames:           ^uint64(0),
    73  				InvalidCRCCount:       0x20,
    74  				RXFrames:              0x30,
    75  				RXWords:               0x40,
    76  				TXFrames:              0x50,
    77  				TXWords:               0x60,
    78  				SecondsSinceLastReset: 0x70,
    79  				InvalidTXWordCount:    0x80,
    80  				LinkFailureCount:      0x90,
    81  				LossOfSyncCount:       0x100,
    82  				LossOfSignalCount:     0x110,
    83  				NosCount:              0x120,
    84  				FCPPacketAborts:       0x130,
    85  			},
    86  		},
    87  	}
    88  
    89  	if diff := cmp.Diff(want, got); diff != "" {
    90  		t.Fatalf("unexpected FibreChannel class (-want +got):\n%s", diff)
    91  	}
    92  }
    93  

View as plain text