Exemplo n.º 1
0
func initLogs(name string, t *testing.T) func() {
	// Show all output if test fails
	logflow.NewSink(logflow.NewTestWriter(t), ".*")

	err := os.MkdirAll("logs/neighbor_test", 0776)
	if err != nil {
		panic("Directory logs/neighbor_test could not be created.")
	}

	logflow.FileSink("logs/neighbor_test/all", true, ".*")
	logflow.FileSink("logs/neighbor_test/"+name, true, ".*")
	logflow.FileSink("logs/neighbor_test/debug", true, ".*/debug")

	// Or show all output anyway I guess...
	// logflow.StdoutSink(".*")
	//     logflow.StdoutSink(".*/debug")

	defer logflow.Println("test", fmt.Sprintf(`
--------------------------------------------------------------------------------
    Start Testing %v
`, name))
	return func() {
		logflow.Println("test", fmt.Sprintf(`
--------------------------------------------------------------------------------
        End Testing %v
    `, name))
		logflow.RemoveAllSinks()
	}
}
Exemplo n.º 2
0
func (self CoordinatorSlice) ChainTCP() {
	logflow.Println("main", "Exporting channels")
	for i, c := range self {
		if i < len(self)-1 {
			c.ExportRemote(i + 1)
		}
		if i > 0 {
			c.ExportRemote(i - 1)
		}
		c.RunExporterInitial()
	}
	logflow.Println("main", "Connecting coordinators")
	for i, c := range self {
		if i < len(self)-1 {
			logflow.Printf("main", "Connect %d to %d over TCP", i, i+1)
			c.ConnectToRPCServer(i+1, fmt.Sprintf("127.0.0.1:%d", 8000+i+1))
		}
		if i > 0 {
			logflow.Printf("main", "Connect %d to %d over TCP", i, i-1)
			c.ConnectToRPCServer(i-1, fmt.Sprintf("127.0.0.1:%d", 8000+i-1))
		}
	}
}