コード例 #1
0
ファイル: main.go プロジェクト: mogren/accload
func main() {

	var config tomlConfig
	if _, err := toml.DecodeFile("example.toml", &config); err != nil {
		fmt.Println("No config file, using default settings.")
		config.Name = "Default"
	}
	fmt.Printf("Title: %s\n", config.Name)

	rate := uint64(100) // per second
	duration := 4 * time.Second
	targeter := vegeta.NewStaticTargeter(vegeta.Target{
		Method: "GET",
		URL:    "http://localhost:8080/",
	})
	attacker := vegeta.NewAttacker()

	var metrics vegeta.Metrics
	for res := range attacker.Attack(targeter, rate, duration) {
		metrics.Add(res)
	}
	metrics.Close()

	fmt.Printf("%d results\n", metrics.Requests)
	fmt.Printf("99th percentile: %s\n", metrics.Latencies.P99)
}
コード例 #2
0
ファイル: vegeta_get.go プロジェクト: finklabs/GoGrinder
func main() {
	rate := uint64(10000) // per second
	duration := 20 * time.Second
	targeter := vegeta.NewStaticTargeter(vegeta.Target{
		Method: "GET",
		URL:    "http://localhost:3001/get_stuff",
	})
	attacker := vegeta.NewAttacker()

	var metrics vegeta.Metrics
	for res := range attacker.Attack(targeter, rate, duration) {
		metrics.Add(res)
	}
	metrics.Close()

	fmt.Printf("99th percentile: %s\n", metrics.Latencies.P99)
}
						ghttp.RespondWith(http.StatusNotFound, ""),
					),
				)
			})

			It("reports the requests as not successful", func() {
				attacker, resultChannel := loadTest(server.URL(), availabilityTestRate)
				defer attacker.Stop()

				Eventually(func() int {
					return len(server.ReceivedRequests())
				}).Should(BeNumerically(">", 1))
				attacker.Stop()

				for result := range resultChannel {
					metrics.Add(result)
				}
				metrics.Close()
				Expect(metrics.Success * 100).To(BeNumerically("==", 0))
			})
		})
	})

	Context("when runs (until the deployment is finished or error rate > 50%)", func() {
		var attacker *vegeta.Attacker
		var resultChannel <-chan *vegeta.Result

		BeforeEach(func() {
			stopAttackCriteria = func() bool {
				if helpers.DeploymentHasFinishedInConcourse() {
					return true