func init() { flag.IntVar(&port, "port", 10001, "Port/IP to use for the REST interface. Overrides $PORT0 env variable") flag.StringVar(&logPath, "logPath", "/var/log/vamp-router/vamp-router.log", "Location of the log file") flag.StringVar(&configPath, "configPath", "", "Location of configuration files, defaults to configuration/") flag.StringVar(&binaryPath, "binary", helpers.HaproxyLocation(), "Path to the HAproxy binary") flag.StringVar(&kafkaHost, "kafkaHost", "", "The hostname or ip address of the Kafka host") flag.IntVar(&kafkaPort, "kafkaPort", 9092, "The port of the Kafka host") flag.StringVar(&zooConString, "zooConString", "", "A zookeeper ensemble connection string") flag.StringVar(&zooConKey, "zooConKey", "magneticio/vamplb", "Zookeeper root key") flag.StringVar(&customWorkDir, "customWorkDir", "", "Custom working directory for sockets and pid files, default to data/") flag.BoolVar(&headless, "headless", false, "Run without any logging output to the console") }
func TestApi_CreateAPI(t *testing.T) { log := gologger.MustGetLogger("vamp-router") sseChannel := make(chan metrics.Metric) sseBroker := &metrics.SSEBroker{ make(map[chan metrics.Metric]bool), make(chan (chan metrics.Metric)), make(chan (chan metrics.Metric)), sseChannel, log, } haConfig := haproxy.Config{TemplateFile: TEMPLATE_FILE, ConfigFile: CONFIG_FILE, JsonFile: JSON_FILE, PidFile: PID_FILE} haRuntime := haproxy.Runtime{Binary: helpers.HaproxyLocation()} if _, err := CreateApi(log, &haConfig, &haRuntime, sseBroker, "v.test"); err != nil { t.Errorf("Failed to create API") } }
package haproxy import ( "github.com/magneticio/vamp-router/helpers" "io/ioutil" "os" "os/exec" "testing" ) var ( haRuntime = Runtime{Binary: helpers.HaproxyLocation(), SockFile: "/tmp/haproxy.stat.sock"} ) func TestRuntime_SetNewPid(t *testing.T) { //make sure there is no pidfile present os.Remove(PID_FILE) if err := haRuntime.SetPid(PID_FILE); err != nil { t.Fatalf(err.Error()) } } func TestRuntime_UseExistingPid(t *testing.T) { //create a pid file emptyPid := []byte("12356") ioutil.WriteFile(PID_FILE, emptyPid, 0644) defer os.Remove(PID_FILE)