예제 #1
0
func TestMain(m *testing.M) {
	var cleanup func()
	etcdAddr, cleanup = etcdrunner.RunEtcdServer(etcdLogger{log.New(os.Stderr, "", log.Lmicroseconds|log.Lshortfile)})
	exitCode := m.Run()
	cleanup()
	os.Exit(exitCode)
}
예제 #2
0
func TestMain(m *testing.M) {
	p, err = New("./test")
	defer os.Remove("./test")
	m.Run()
	p.Close()

}
예제 #3
0
func TestMain(m *testing.M) {
	flag.Parse()
	rand.Seed(time.Now().UnixNano())
	// For redis tests we just point at an external server.
	if *flagReddisHost != "" {
		testData = newDataAccess(*flagReddisHost, true)
		if *flagFlushRedis {
			log.Println("FLUSHING REDIS")
			c := testData.getConnection()
			_, err := c.Do("FLUSHDB")
			if err != nil {
				log.Fatal(err)
			}
		}
	} else {
		// To test ledis, start a local instance in a new tmp dir. We will attempt to delete it when we're done.
		addr := "127.0.0.1:9876"
		testPath := filepath.Join(os.TempDir(), "bosun_ledis_test", fmt.Sprint(time.Now().Unix()))
		log.Println(testPath)
		stop, err := StartLedis(testPath, addr)
		if err != nil {
			log.Fatal(err)
		}
		testData = newDataAccess(addr, false)
		cleanups = append(cleanups, func() {
			stop()
			os.RemoveAll(testPath)
		})
	}
	status := m.Run()
	for _, c := range cleanups {
		c()
	}
	os.Exit(status)
}
예제 #4
0
func TestMain(m *testing.M) {
	size = numXi(index)
	pk = []byte{1}

	runtime.GOMAXPROCS(runtime.NumCPU())

	id := flag.Int("index", 1, "graph index")
	flag.Parse()
	index = int64(*id)

	graphDir = fmt.Sprintf("%s%d", graphDir, *id)
	//os.RemoveAll(graphDir)

	now := time.Now()
	prover = NewProver(pk, index, name, graphDir)
	fmt.Printf("%d. Graph gen: %fs\n", index, time.Since(now).Seconds())

	now = time.Now()
	commit := prover.Init()
	fmt.Printf("%d. Graph commit: %fs\n", index, time.Since(now).Seconds())

	root := commit.Commit
	verifier = NewVerifier(pk, index, beta, root)

	os.Exit(m.Run())
}
예제 #5
0
파일: go_test.go 프로젝트: josharian/go.ssa
// The TestMain function creates a go command for testing purposes and
// deletes it after the tests have been run.
func TestMain(m *testing.M) {
	flag.Parse()

	if canRun {
		// We give the executable a .exe extension because Windows.
		out, err := exec.Command("go", "build", "-tags", "testgo", "-o", "testgo.exe").CombinedOutput()
		if err != nil {
			fmt.Fprintf(os.Stderr, "building testgo failed: %v\n%s", err, out)
			os.Exit(2)
		}
	}

	// Don't let these environment variables confuse the test.
	os.Unsetenv("GOBIN")
	os.Unsetenv("GOPATH")
	os.Unsetenv("GOROOT")

	r := m.Run()

	if canRun {
		os.Remove("testgo.exe")
	}

	os.Exit(r)
}
예제 #6
0
func TestMain(m *testing.M) {
	log.SetDebug(true)
	if err := os.Setenv("ABOT_DEBUG", "true"); err != nil {
		log.Fatal(err)
	}
	os.Exit(m.Run())
}
예제 #7
0
func TestMain(m *testing.M) {
	// Reset this so it panics instead of exiting on Fatal messages
	logging.SetBackend(&fakeLogBackend{})
	server = httptest.NewServer(http.HandlerFunc(handler))
	defer server.Close()
	os.Exit(m.Run())
}
예제 #8
0
func TestMain(m *testing.M) {
	flag.Parse()
	//	os.RemoveAll(testPath)
	code := m.Run()
	os.RemoveAll(testPath)
	os.Exit(code)
}
예제 #9
0
파일: main_test.go 프로젝트: yab/vitess
func TestMain(m *testing.M) {
	flag.Parse() // Do not remove this comment, import into google3 depends on it
	tabletserver.Init()

	exitCode := func() int {
		hdl, err := vttest.LaunchMySQL("vttest", schema, testing.Verbose())
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not launch mysql: %v\n", err)
			return 1
		}
		defer hdl.TearDown()
		connParams, err = hdl.MySQLConnParams()
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not fetch mysql params: %v\n", err)
			return 1
		}
		err = framework.StartDefaultServer(connParams)
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			return 1
		}
		defer framework.StopDefaultServer()

		err = initTableACL()
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			return 1
		}

		return m.Run()
	}()
	os.Exit(exitCode)
}
예제 #10
0
func TestMain(m *testing.M) {
	flag.Parse()
	if flag.Lookup("test.short").Value.String() != "false" {
		quickCfg.MaxCount = 10
	}
	os.Exit(m.Run())
}
예제 #11
0
func TestMain(m *testing.M) {
	server = httptest.NewServer(routes.Index{option.Options{}})
	client = &http.Client{}
	code := m.Run()
	server.Close()
	os.Exit(code)
}
예제 #12
0
파일: roshi_test.go 프로젝트: ello/streams
func TestMain(m *testing.M) {
	log.SetLevel(log.DebugLevel)

	retCode := m.Run()

	os.Exit(retCode)
}
예제 #13
0
파일: dao_test.go 프로젝트: vmware/harbor
func testForAll(m *testing.M) int {
	os.Setenv("AUTH_MODE", "db_auth")
	initDatabaseForTest()
	clearUp(username)

	return m.Run()
}
예제 #14
0
func TestMain(m *testing.M) {
	var logLevel log.LogLevel

	logLevel = 0
	// logLevel = 1
	// logLevel = 3

	log.SetLoggers(logLevel, os.Stdout, os.Stderr)

	if err := testsInit(); err != nil {
		logger.Errorln(err)
		os.Exit(1)
	}

	exitCode := m.Run()

	if os.Getenv("TEST_IN_CIRCLE") != "true" {
		if err := testsTearDown(); err != nil {
			logger.Errorln(err)
			log.Flush()
			os.Exit(1)
		}
	}

	os.Exit(exitCode)
}
예제 #15
0
파일: user_test.go 프로젝트: paked/steel
func TestMain(m *testing.M) {
	createTestDB()
	c := m.Run()
	deleteTestDB()

	os.Exit(c)
}
예제 #16
0
func TestMain(m *testing.M) {
	if reexec.Init() {
		return
	}

	if err := createController(); err != nil {
		os.Exit(1)
	}
	option := options.Generic{
		"EnableIPForwarding": true,
	}

	genericOption := make(map[string]interface{})
	genericOption[netlabel.GenericData] = option

	err := controller.ConfigureNetworkDriver(bridgeNetType, genericOption)
	if err != nil {
		//m.Fatal(err)
		os.Exit(1)
	}

	libnetwork.SetTestDataStore(controller, datastore.NewCustomDataStore(datastore.NewMockStore()))

	os.Exit(m.Run())
}
예제 #17
0
func TestMain(m *testing.M) {
	flag.Parse()
	log.TestOutput(testing.Verbose(), 4)
	code := m.Run()
	log.AfterTest(nil)
	os.Exit(code)
}
예제 #18
0
파일: main_test.go 프로젝트: CliffYuan/etcd
func TestMain(m *testing.M) {
	v := m.Run()
	if v == 0 && testutil.CheckLeakedGoroutine() {
		os.Exit(1)
	}
	os.Exit(v)
}
예제 #19
0
func TestMain(m *testing.M) {
	var logLevel log.LogLevel
	var err error

	logLevel = 0
	// logLevel = 1
	// logLevel = 2

	log.SetLoggers(logLevel, os.Stdout, os.Stderr)

	testsInit()
	logger.Infoln("Test init completed. Starting main test sequence now.")

	exitCode := m.Run()

	logger.Infoln("Commensing with Tests Tear Down.")
	if os.Getenv("TEST_IN_CIRCLE") != "true" {
		err = testsTearDown()
		if err != nil {
			logger.Errorln(err)
			os.Exit(1)
		}
	}

	os.Exit(exitCode)
}
예제 #20
0
파일: bs2_test.go 프로젝트: aclisp/go-bs2
func TestMain(m *testing.M) {
	flag.Parse()

	// setup the object for all tests
	c := bs2.Connection{
		AccessKey: a,
		SecretKey: s,
		Logger:    nil,
	}
	_, e := c.ObjectPut(myBucket, myObj, strings.NewReader(myObjValue), true, "", bs2.Headers{
		"Content-Length": strconv.Itoa(len(myObjValue)),
	})
	if e != nil {
		logger.Fatal("Tests setup failed")
	}

	exitCode := m.Run()

	// teardown
	e = c.ObjectDelete(myBucket, myObj)
	if e != nil {
		logger.Fatal("Tests teardown failed")
	}

	os.Exit(exitCode)
}
예제 #21
0
// TestMainWithLeakCheck is an implementation of TestMain which verifies that
// there are no leaked goroutines at the end of the run (except those created
// by the system which are on a whitelist). Usage:
//
// func TestMain(m *testing.M) {
//   leaktest.TestMainWithLeakCheck(m)
// }
func TestMainWithLeakCheck(m *testing.M) {
	v := m.Run()
	if v == 0 && goroutineLeaked() {
		os.Exit(1)
	}
	os.Exit(v)
}
예제 #22
0
func TestMain(m *testing.M) {
	err := initialize()
	if err != nil {
		log.Error(fmt.Sprintf("Unable to initialize database: %v", err))
		os.Exit(1)
	}

	url := c.Database.URL + c.Database.Test

	manager, err := NewPgManager(url)
	if err != nil {
		log.Error("Unable to initialize PgManager")
		os.Exit(1)
	}

	repo = NewPgRepository(manager)

	r := m.Run()

	err = manager.close()
	if err != nil {
		log.Error(fmt.Sprintf("Error closing database: %v", err))
		os.Exit(1)
	}

	os.Exit(r)
}
예제 #23
0
func TestMain(m *testing.M) {
	copyrightTagger = New("CopyrightCorpus.in")

	//	dumpTransMatrix()

	os.Exit(m.Run())
}
예제 #24
0
파일: main_test.go 프로젝트: ringtail/etcd
// TestMain sets up an etcd cluster if running the examples.
func TestMain(m *testing.M) {
	useCluster := true // default to running all tests
	for _, arg := range os.Args {
		if strings.HasPrefix(arg, "-test.run=") {
			exp := strings.Split(arg, "=")[1]
			match, err := regexp.MatchString(exp, "Example")
			useCluster = (err == nil && match) || strings.Contains(exp, "Example")
			break
		}
	}

	v := 0
	if useCluster {
		cfg := integration.ClusterConfig{Size: 3}
		clus := integration.NewClusterV3(nil, &cfg)
		endpoints = make([]string, 3)
		for i := range endpoints {
			endpoints[i] = clus.Client(i).Endpoints()[0]
		}
		v = m.Run()
		clus.Terminate(nil)
	} else {
		v = m.Run()
	}

	if v == 0 && testutil.CheckLeakedGoroutine() {
		os.Exit(1)
	}
	os.Exit(v)
}
예제 #25
0
func TestMain(m *testing.M) {
	setup()
	defer teardown() // only called if we panic
	result := m.Run()
	teardown()
	os.Exit(result)
}
예제 #26
0
func TestMain(m *testing.M) {
	if testing.Short() {
		// skip
		os.Exit(0)
	}
	os.Exit(m.Run())
}
예제 #27
0
func TestMain(m *testing.M) {
	var logLevel log.LogLevel

	logLevel = 0
	// logLevel = 1
	// logLevel = 3

	log.SetLoggers(logLevel, os.Stdout, os.Stderr)

	if os.Getenv("TEST_IN_CIRCLE") == "true" {
		erisDir = os.Getenv("HOME")
	}

	file = path.Join(erisDir, "temp")

	tests.IfExit(testsInit())
	exitCode := m.Run()

	if os.Getenv("TEST_IN_CIRCLE") != "true" {
		testKillIPFS(nil)
		tests.IfExit(tests.TestsTearDown())
	}

	os.Exit(exitCode)
}
예제 #28
0
func TestMain(m *testing.M) {
	TestMongo.Session = TestServer.Session()
	TestMongo.EnsureIndexes()
	TestMongo.Session.Close()
	defer exitTest()
	m.Run()
}
예제 #29
0
// setup the test suite
func TestMain(m *testing.M) {
	// read the settings
	err := readSettingsFromConfigFile()
	if err != nil {
		panic(err)
	}
	// create an opsgenie client
	opsGenieClient := new(OpsGenieClient)
	opsGenieClient.SetApiKey(testCfg.Alert.ApiKey)
	// create the alerting client
	var cliErr error
	cli, cliErr = opsGenieClient.Alert()

	if cliErr != nil {
		panic(cliErr)
	}

	// create the heartbeat client
	// Api Key should be switched in order to send heartbeat requests
	opsGenieClient.SetApiKey(testCfg.Heartbeat.ApiKey)
	hbCli, cliErr = opsGenieClient.Heartbeat()

	if cliErr != nil {
		panic(cliErr)
	}
	os.Exit(m.Run())
}
예제 #30
-1
func TestMain(m *testing.M) {
	generateMetrics()

	masterRouter := http.NewServeMux()
	masterRouter.HandleFunc("/metrics/snapshot", func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusOK)
		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode(masterMetrics)
	})
	masterTestServer = httptest.NewServer(masterRouter)

	slaveRouter := http.NewServeMux()
	slaveRouter.HandleFunc("/metrics/snapshot", func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusOK)
		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode(slaveMetrics)
	})
	slaveRouter.HandleFunc("/monitor/statistics", func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusOK)
		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode([]map[string]interface{}{slaveTaskMetrics})
	})
	slaveTestServer = httptest.NewServer(slaveRouter)

	rc := m.Run()

	masterTestServer.Close()
	slaveTestServer.Close()
	os.Exit(rc)
}