...

Source file src/k8s.io/kubernetes/pkg/volume/metrics_block_linux_test.go

Documentation: k8s.io/kubernetes/pkg/volume

     1  //go:build !windows
     2  // +build !windows
     3  
     4  /*
     5  Copyright 2021 The Kubernetes Authors.
     6  
     7  Licensed under the Apache License, Version 2.0 (the "License");
     8  you may not use this file except in compliance with the License.
     9  You may obtain a copy of the License at
    10  
    11      http://www.apache.org/licenses/LICENSE-2.0
    12  
    13  Unless required by applicable law or agreed to in writing, software
    14  distributed under the License is distributed on an "AS IS" BASIS,
    15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  See the License for the specific language governing permissions and
    17  limitations under the License.
    18  */
    19  
    20  package volume_test
    21  
    22  import (
    23  	"testing"
    24  
    25  	. "k8s.io/kubernetes/pkg/volume"
    26  	volumetest "k8s.io/kubernetes/pkg/volume/testing"
    27  )
    28  
    29  func TestGetMetricsBlockInvalid(t *testing.T) {
    30  	// TODO: Enable this on Windows once support VolumeMode=Block is added.
    31  	metrics := NewMetricsBlock("")
    32  	actual, err := metrics.GetMetrics()
    33  	expected := &Metrics{}
    34  	if !volumetest.MetricsEqualIgnoreTimestamp(actual, expected) {
    35  		t.Errorf("Expected empty Metrics from uninitialized MetricsBlock, actual %v", *actual)
    36  	}
    37  	if err == nil {
    38  		t.Errorf("Expected error when calling GetMetrics on uninitialized MetricsBlock, actual nil")
    39  	}
    40  
    41  	metrics = NewMetricsBlock("/nonexistent/device/node")
    42  	actual, err = metrics.GetMetrics()
    43  	if !volumetest.MetricsEqualIgnoreTimestamp(actual, expected) {
    44  		t.Errorf("Expected empty Metrics from incorrectly initialized MetricsBlock, actual %v", *actual)
    45  	}
    46  	if err == nil {
    47  		t.Errorf("Expected error when calling GetMetrics on incorrectly initialized MetricsBlock, actual nil")
    48  	}
    49  }
    50  

View as plain text