Beispiel #1
0
func main() {
	config := config.NewConfig()
	err := config.Parse()
	if err != nil {
		panic(err)
	}

	if config.Server == true {
		fmt.Println("Starting in server mode")
		server.Serve()
		server.Bind()
	} else {
		pat.RunCommandLine(config.Concurrency, config.Iterations, config.Silent, config.Output, config.Interval, config.Stop, config.Workload)
	}
}
Beispiel #2
0
	"github.com/julz/pat/experiment"
	"github.com/julz/pat/laboratory"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cmdline", func() {
	var (
		flags  config.Config
		args   []string
		lab    *dummyLab
		worker benchmarker.Worker
	)

	JustBeforeEach(func() {
		flags = config.NewConfig()
		InitCommandLineFlags(flags)
		flags.Parse(args)
		lab = &dummyLab{}
		worker = benchmarker.NewWorker()
		RunCommandLineWithLabAndWorker(lab, worker)
	})

	Describe("When -iterations is supplied", func() {
		BeforeEach(func() {
			args = []string{"-iterations", "3"}
		})

		It("configures the experiment with the parameter", func() {
			Ω(lab).Should(HaveBeenRunWith("iterations", 3))
		})
Beispiel #3
0
var _ = Describe("Server", func() {
	var (
		lab *DummyLab
	)

	BeforeEach(func() {
		experiments := []*DummyExperiment{&DummyExperiment{"a"}, &DummyExperiment{"b"}, &DummyExperiment{"c"}}
		lab = &DummyLab{}
		lab.experiments = experiments
		http.DefaultServeMux = http.NewServeMux()
		ServeWithLab(lab)
	})

	It("Uses config to get CSV output directory", func() {
		http.DefaultServeMux = http.NewServeMux()
		c := config.NewConfig()
		InitCommandLineFlags(c)
		c.Parse([]string{"-csvDir", "/var/tmp/foo/bar/"})
		csvs := store.NewCsvStore("/var/tmp/foo/bar/")
		ch := make(chan *Sample)
		go func() { ch <- &Sample{}; ch <- &Sample{}; close(ch) }()
		csvs.Writer("1234")(ch)

		Serve()
		json := get("/experiments/1234")
		Ω(json["Items"]).Should(HaveLen(2))
	})

	It("lists experiments", func() {
		json := get("/experiments/")
		Ω(json["Items"]).Should(HaveLen(3))