This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quite bad performance: Transactions: 754 hits Availability: 100.00 % Elapsed time: 59.74 secs Data transferred: 0.00 MB Response time: 1.96 secs Transaction rate: 12.62 trans/sec Throughput: 0.00 MB/sec Concurrency: 24.71 Successful transactions: 754 Failed transactions: 0 Longest transaction: 2.31 Shortest transaction: 1.86
- Loading branch information
Showing
9 changed files
with
203 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package main_test | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"net/http" | ||
|
||
. "github.com/scoiatael/archai" | ||
"github.com/scoiatael/archai/actions" | ||
"github.com/scoiatael/archai/util" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
const testingKeyspace = "archai_test" | ||
|
||
var ( | ||
config Config | ||
) | ||
|
||
var _ = BeforeSuite(func() { | ||
config = Config{} | ||
config.Hosts = []string{"127.0.0.1"} | ||
config.Keyspace = testingKeyspace | ||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
|
||
}) | ||
|
||
var _ = Describe("Actions", func() { | ||
Describe("HttpServer", func() { | ||
var ( | ||
action actions.HttpServer | ||
port int | ||
address string | ||
stream string | ||
buf io.Reader | ||
) | ||
port = 9080 | ||
BeforeEach(func() { | ||
action.Addr = "127.0.0.1" | ||
port = port + 1 + util.RandomInt(1000) | ||
action.Port = port | ||
}) | ||
JustBeforeEach(func() { | ||
go action.Run(config) | ||
address = fmt.Sprintf("http://127.0.0.1:%d", action.Port) | ||
}) | ||
|
||
AfterEach(func() { | ||
action.Stop() | ||
}) | ||
|
||
Describe("/stream/:id", func() { | ||
JustBeforeEach(func() { | ||
stream = util.RandomString(10) | ||
address = fmt.Sprintf("%s/stream/%s", address, stream) | ||
buf = bytes.NewBufferString(`{ "foo": "bar" }`) | ||
}) | ||
|
||
It("allows writing events", func() { | ||
resp, err := http.Post(address, "application/json", buf) | ||
|
||
Expect(err).NotTo(HaveOccurred()) | ||
body, err := ioutil.ReadAll(resp.Body) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(string(body)).To(Equal(`"OK"`)) | ||
}) | ||
|
||
Context("After some event was written", func() { | ||
JustBeforeEach(func() { | ||
event := actions.WriteEvent{} | ||
event.Stream = stream | ||
event.Payload = []byte(`{ "foo": "bar"}`) | ||
event.Meta = make(map[string]string) | ||
|
||
event.Run(config) | ||
|
||
}) | ||
It("allows reading events", func() { | ||
resp, err := http.Get(address) | ||
|
||
Expect(err).NotTo(HaveOccurred()) | ||
body, err := ioutil.ReadAll(resp.Body) | ||
Expect(err).NotTo(HaveOccurred()) | ||
js := make(map[string]interface{}) | ||
err = json.Unmarshal(body, &js) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(js["results"]).NotTo(BeEmpty()) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package persistence_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestPersistence(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Persistence Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
siege -t60S -b -H 'Content-Type: application/json' "http://localhost:8080/stream/siege-test POST < $(dirname $0)/siege_data.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"payload": { | ||
"post_id": "491452930867938_1095485790464646", | ||
"date": "2015-09-03T02:30:01+0000", | ||
"field1": "19565815", | ||
"field2": "186716", | ||
"field3": "38213", | ||
"field4": "302554", | ||
"field5": "15.033", | ||
"field7": "Egg-In-The-Hole Grilled Cheese", | ||
"post_url": "https://www.facebook.com/BuzzFeedFood/videos/1095485790464646/", | ||
"thumbnail_url": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xpf1/v/t15.0-10/p130x130/11838221_1095489770464248_1585269284_n.jpg?oh=f132b8b6b3d3d613e274f94c570fe98c&oe=56893684&__gda__=1456401596_c9408cc1e7995d6d454bcdc14e7a1729", | ||
"video_url": "https://video.xx.fbcdn.net/hvideo-xfp1/v/t43.1792-2/11961942_1095489660464259_581814512_n.mp4?efg=eyJybHIiOjE1MDAsInJsYSI6MTAyNCwidmVuY29kZV90YWciOiJoZCJ9&rl=1500&vabr=505&oh=fb028b89baa62dd9b55e6c2a2842c250&oe=5617530A" | ||
}, | ||
"stream": "BuzzThis" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package util | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
func RandomInt(max int) int { | ||
rand.Seed(time.Now().UnixNano()) | ||
return rand.Intn(max) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package util | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
|
||
func RandomString(length int) string { | ||
rand.Seed(time.Now().UnixNano()) | ||
b := make([]byte, length) | ||
for i := range b { | ||
b[i] = letters[rand.Intn(len(letters))] | ||
} | ||
return string(b) | ||
} |