bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/bosun/conf/system_test.go (about)

     1  package conf
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"bosun.org/opentsdb"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestSystemToml(t *testing.T) {
    13  	sc, err := LoadSystemConfigFile("test.toml")
    14  	if err != nil {
    15  		t.Errorf("failed to load/parse config file: %v", err)
    16  		return
    17  	}
    18  	assert.Equal(t, sc.Hostname, "bosun.example.com", "Hostname not equal")
    19  	assert.Equal(t, sc.Scheme, "https", "Scheme does not match")
    20  	assert.Equal(t, sc.DefaultRunEvery, 5)
    21  	assert.Equal(t, sc.CheckFrequency, Duration{time.Minute})
    22  	assert.Equal(t, sc.Ping, true)
    23  	assert.Equal(t, sc.MinGroupSize, 5)
    24  	assert.Equal(t, sc.UnknownThreshold, 5)
    25  	assert.Equal(t, sc.SearchSince, Duration{Duration: time.Hour * 72})
    26  	assert.Equal(t, sc.PingDuration, Duration{Duration: time.Hour * 24}, "PingDuration does not match (should be set by default)")
    27  	assert.Equal(t, sc.HTTPListen, ":8080", "HTTPListen does not match")
    28  	assert.Equal(t, sc.TimeAndDate, []int{202, 75, 179, 136}, "TimeAndDate does not match")
    29  	assert.Equal(t, sc.ShortURLKey, "aKey")
    30  	assert.Equal(t, sc.EnableSave, false)
    31  	assert.Equal(t, sc.CommandHookPath, "/Users/kbrandt/src/hook/hook")
    32  	assert.Equal(t, sc.RuleFilePath, "dev.sample.conf")
    33  	assert.Equal(t, sc.OpenTSDBConf, OpenTSDBConf{
    34  		Host:          "ny-tsdb01:4242",
    35  		ResponseLimit: 25000000,
    36  		Version:       opentsdb.Version2_2,
    37  	})
    38  	assert.Equal(t, sc.GraphiteConf, GraphiteConf{
    39  		Host:    "localhost:80",
    40  		Headers: map[string]string{"X-Meow": "Mix"},
    41  	})
    42  	assert.Equal(t, sc.ElasticConf, map[string]ElasticConf{
    43  		"default": {
    44  			Hosts: []string{"http://ny-lselastic01.example.com:9200", "http://ny-lselastic02.example.com:9200"},
    45  		},
    46  	})
    47  	assert.Equal(t, sc.AnnotateConf, AnnotateConf{
    48  		Hosts: []string{"http://ny-lselastic01.example.com:9200", "http://ny-lselastic02.example.com:9200"},
    49  	})
    50  	assert.Equal(t, sc.DBConf, DBConf{
    51  		RedisHost:          "localhost:6389", // From Config
    52  		RedisClientSetName: true,
    53  		LedisDir:           "ledis_data",     // Default
    54  		LedisBindAddr:      "127.0.0.1:9565", // Default
    55  
    56  	}, "DBConf does not match")
    57  	assert.Equal(t, sc.SMTPConf, SMTPConf{
    58  		EmailFrom: "bosun@example.com",
    59  		Host:      "mail.example.com",
    60  	}, "SMTPConf does not match")
    61  	assert.Equal(t, sc.InfluxConf, InfluxConf{
    62  		URL:       "https://myInfluxServer:1234",
    63  		Timeout:   Duration{time.Minute * 5},
    64  		UnsafeSSL: true,
    65  	})
    66  	assert.Equal(t, sc.CloudWatchConf, CloudWatchConf{
    67  		Enabled:        true,
    68  		PagesLimit:     10,
    69  		ExpansionLimit: 500,
    70  		Concurrency:    2,
    71  	}, "CloudwatchConf does not match")
    72  
    73  }