github.com/whamcloud/lemur@v0.0.0-20190827193804-4655df8a52af/cmd/lhsmd/agent/mountpoints_test.go (about)

     1  // Copyright (c) 2018 DDN. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package agent
     6  
     7  import (
     8  	"reflect"
     9  	"testing"
    10  
    11  	"golang.org/x/sys/unix"
    12  
    13  	"github.com/intel-hpdd/lemur/cmd/lhsmd/config"
    14  	"github.com/intel-hpdd/go-lustre/fs/spec"
    15  )
    16  
    17  func TestMountConfigs(t *testing.T) {
    18  	cfg, err := LoadConfig("./test-fixtures/plugin-config")
    19  	if err != nil {
    20  		t.Fatalf("err: %s", err)
    21  	}
    22  
    23  	d, err := spec.ClientDeviceFromString("0@lo:/test")
    24  	if err != nil {
    25  		t.Fatalf("err: %s", err)
    26  	}
    27  	expectedDevice := d.String()
    28  	expectedOptions := clientMountOptions{"user_xattr", "device=" + expectedDevice}
    29  	var expectedFlags uintptr
    30  	expectedFlags |= unix.MS_STRICTATIME
    31  	expected := []*mountConfig{
    32  		{
    33  			Device:    expectedDevice,
    34  			Directory: config.DefaultAgentMountRoot + "/agent",
    35  			Type:      "lustre",
    36  			Options:   expectedOptions,
    37  			Flags:     expectedFlags,
    38  		},
    39  		{
    40  			Device:    expectedDevice,
    41  			Directory: config.DefaultAgentMountRoot + "/lhsm-plugin-posix",
    42  			Type:      "lustre",
    43  			Options:   expectedOptions,
    44  			Flags:     expectedFlags,
    45  		},
    46  		{
    47  			Device:    expectedDevice,
    48  			Directory: config.DefaultAgentMountRoot + "/lhsm-plugin-s3",
    49  			Type:      "lustre",
    50  			Options:   expectedOptions,
    51  			Flags:     expectedFlags,
    52  		},
    53  		{
    54  			Device:    expectedDevice,
    55  			Directory: config.DefaultAgentMountRoot + "/lhsm-plugin-noop",
    56  			Type:      "lustre",
    57  			Options:   expectedOptions,
    58  			Flags:     expectedFlags,
    59  		},
    60  	}
    61  
    62  	got := createMountConfigs(cfg)
    63  
    64  	if !reflect.DeepEqual(got, expected) {
    65  		t.Fatalf("\nexpected:\n%s\ngot:\n%s\n", expected, got)
    66  	}
    67  }