Example #1
0
func TestConfig(t *testing.T) {
	var tests = []struct {
		filename, protocol, host, port, path string
	}{
		{utils.GetUserHome() + "/.mdfs/stnode/.stnode_conf.json", "tcp", "localhost", "8081", utils.GetUserHome() + "/.mdfs/stnode/"},
		{utils.GetUserHome() + "/.mdfs/mdservice/.mdservice_conf.json", "tcp", "localhost", "1994", utils.GetUserHome() + "/.mdfs/mdservice/"},
	}
	for _, c := range tests {
		got := config.ParseConfiguration(c.filename)
		if got.Path != c.path || got.Host != c.host || got.Port != c.port || got.Protocol != c.protocol {
			t.Error("Configuration variables does not contain expected values\n")
			fmt.Printf("%s,%s,%s,%s,%s,%s,%s,%s\n", got.Path, c.path, got.Host, c.host, got.Port, c.port, got.Protocol, c.protocol)
		}
	}
}
Example #2
0
func setup(path, port, host, mdport, mdhost, sample, fname string) error {

	// create the supplied file path
	err := os.MkdirAll(path, 0700)
	if err != nil {
		return err
	}

	// get the sample configuration file from the repo
	conf := config.ParseConfiguration(sample + fname)
	conf.Path = path // change the path variable
	conf.Port = port // change the port variable
	conf.Host = host
	conf.MdHost = mdhost
	conf.MdPort = mdport

	// encode the new object to a json file
	err = config.SetConfiguration(conf, path+"."+fname)
	return err
}
Example #3
0
// for testing setup
func main() {

	err := os.MkdirAll(utils.GetUserHome()+"/.mdfs/mdservice", 0700)
	if err != nil {
		panic(err)
	}
	err = os.MkdirAll(utils.GetUserHome()+"/.mdfs/mdservice/files/", 0700)
	if err != nil {
		panic(err)
	}

	conf := config.ParseConfiguration("./mdservice/config/mdservice_conf.json")
	conf.Path = utils.GetUserHome() + "/.mdfs/mdservice/"

	// save the new configuration to file
	err = config.SetConfiguration(conf, conf.Path+"/.mdservice_conf.json")
	if err != nil {
		panic(err)
	}
}
Example #4
0
File: server.go Project: CPSSD/MDFS
// StorageNode methods
func (st *StorageNode) parseConfig() {
	st.conf = config.ParseConfiguration(utils.GetUserHome() + "/.mdfs/stnode/.stnode_conf.json")
}
Example #5
0
File: server.go Project: CPSSD/MDFS
// MDService methods
// initialise its memeber variable with values from config file
func (md *MDService) parseConfig() {
	md.conf = config.ParseConfiguration(utils.GetUserHome() + "/.mdfs/mdservice/.mdservice_conf.json")
}