Example #1
0
func TestBenchmarkResult_DummyItems(t *testing.T) {

	back, err := backend.New(&cfg, log.New(os.Stdout, "TEST ", 0))
	if err != nil {
		t.Fatal(err)
	}

	t.Log(back.Model.TestEnvironment.Exist("1"))
	/*
		_, err = back.Model.Package.All()
		if err != nil {

			t.Fatal(err)
		}

		/*
			err = back.Model.Package.Add(&model.PackageRow{
				Name:          "github.com/bradfitz/slice",
				Url:           "https://github.com/bradfitz/slice",
				RepositoryUrl: "https://github.com",
				Engine:        "git",
				Created:       time.Now(),
				Updated:       time.Now()})

	*/
	pkg, err := back.Model.Package.GetItem("github.com/bradfitz/slice")
	if pkg.Name != "github.com/bradfitz/slice" {
		t.Fatal(err)
	}
	t.Log(pkg, err)

	task, err := back.Model.Task.Next("change-secret-1")
	if err != nil {
		t.Fatal(err)
	}
	s := task.Id.Hex()
	t.Log("Next: ", s)
	id, _ := hex.DecodeString(s)
	ttask, err := back.Model.Task.Get(string(id))
	t.Log(err, ttask)

	//res, err := back.Model.Task.GetAndDelete(string(task.Id))
	//t.Log(err, res)

	//result, _ := back.Model.BenchmarkResult.DummyItems("")
}
Example #2
0
func realMain() int {

	// reads and parses application config params
	config, err := config.ReadFromFile("./config.json")
	if err != nil {
		fmt.Println("Config file reading error. Details: ", err)
		return 1
	}

	// creates Logger (can be replaced with other popular logger)
	log := log.New(os.Stdout, "GOB ", log.Ldate|log.Ltime)
	log.Println("Application launched")

	// creates Backend object
	back, err := backend.New(&config.Backend, log)
	if err != nil {
		log.Println("Backend initialisation error. Details: ", err)
		return 2
	}

	// creates Frontend objects
	front, err := frontend.New(&config.Frontend, log, back)
	if err != nil {
		log.Println("Frontend initialisation error. Details: ", err)
		return 3
	}

	// starts background processes
	if err := back.Start(); err != nil {
		log.Println("Backend processes launching error. Details: ", err)
		return 4
	}

	// starts HTTP listener and handlers
	if err := front.Start(); err != nil {
		log.Println("Frontend listeners/processes error. Details: ", err)
		return 5
	}

	log.Println("Application succesfully terminated")
	return 0
}