Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable travis-ci #10

Merged
merged 14 commits into from May 8, 2018
19 changes: 19 additions & 0 deletions .travis.yml
@@ -0,0 +1,19 @@
sudo: required
language: go
go:
- "1.10.x"
before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce libtool pkg-config build-essential autoconf automake uuid-dev wget
- sudo docker run -p 5555:5555 -p 5556:5556 -d --name zest --rm jptmoore/zest:v0.0.6 /app/zest/server.exe --secret-key-file example-server-key
- wget https://github.com/zeromq/libzmq/releases/download/v4.2.3/zeromq-4.2.3.tar.gz
- tar xvzf zeromq-4.2.3.tar.gz
- cd zeromq-4.2.3; ./configure; sudo make install; sudo ldconfig; cd ..; sudo rm -rf zeromq-4.2.3
script:
- go test -coverprofile=coverage.txt -covermode=atomic
after_success:
- bash <(curl -s https://codecov.io/bash)
services:
- docker
15 changes: 12 additions & 3 deletions core-store-kv_test.go
Expand Up @@ -125,7 +125,7 @@ func TestObserveKeyKV(t *testing.T) {
}()

//Observe take a bit of time to register we miss some values if we dont wait before writing
time.Sleep(time.Second)
time.Sleep(time.Second * 2)

go func() {
for i := startAt; i <= numRecords; i++ {
Expand All @@ -135,11 +135,15 @@ func TestObserveKeyKV(t *testing.T) {
}
t.Log(string("written:: " + strconv.Itoa(i)))
}
// we miss some values if we dont wait before saying we are done!
time.Sleep(time.Second * 3)
doneChanWrite <- 1
}()

<-doneChanWrite

if len(receivedData) < numRecords {
t.Errorf("receivedData Error: receivedData should contain '%d' items but contains %d", numRecords, len(receivedData))
}
for i := startAt; i <= numRecords; i++ {
expected := []byte("{\"value\":" + strconv.Itoa(i) + "}")
cont := s.Contains(string(receivedData[i].Json), string(expected))
Expand Down Expand Up @@ -176,7 +180,7 @@ func TestObserveKV(t *testing.T) {
}()

//Observe take a bit of time to register we miss some values if we dont wait before writing
time.Sleep(time.Second / 2)
time.Sleep(time.Second * 2)

go func() {
for i := startAt; i < numRecords; i++ {
Expand All @@ -187,6 +191,8 @@ func TestObserveKV(t *testing.T) {
t.Log(string("written:: " + strconv.Itoa(i)))
time.Sleep(time.Millisecond * 10)
}
// we miss some values if we dont wait before saying we are done!
time.Sleep(time.Second * 3)
doneChanWrite <- 1
}()

Expand All @@ -197,6 +203,9 @@ func TestObserveKV(t *testing.T) {
return
}

if len(receivedData) < numRecords {
t.Errorf("receivedData Error: receivedData should contain '%d' items but contains %d", numRecords, len(receivedData))
}
for i := startAt; i < numRecords; i++ {
expected := []byte("{\"value\":" + strconv.Itoa(i) + "}")
cont := s.Contains(string(receivedData[i].Json), string(expected))
Expand Down
6 changes: 5 additions & 1 deletion core-store-ts-json-blob_test.go
Expand Up @@ -371,11 +371,15 @@ func TestObserveBlob(t *testing.T) {
}
t.Log(string("written:: " + strconv.Itoa(i)))
}
// we miss some values if we dont wait before saying we are done!
time.Sleep(time.Second * 3)
doneChanWrite <- 1
}()

<-doneChanWrite

if len(receivedData) < numRecords {
t.Errorf("receivedData Error: receivedData should contain '%d' items but contains %d", numRecords, len(receivedData))
}
for i := startAt; i <= numRecords; i++ {
expected := []byte("{\"test\":" + strconv.Itoa(i) + ", \"data\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"}")
cont := s.Contains(string(receivedData[i].Json), string(expected))
Expand Down
33 changes: 26 additions & 7 deletions core-store-ts-json_test.go
Expand Up @@ -402,9 +402,16 @@ func TestEarliest(t *testing.T) {
if err != nil {
t.Errorf("Write to %s failed expected err to be nil got %s", dsID+"TestEarliest", err.Error())
}
//time.Sleep(time.Millisecond * 10)

// On a fast CPU its possible to write faster than the resolution of zestDBs timestamp!
// when this happens it can return records out of order causing this test to fail ;-(
// so lets just sleep for a while to make sure!!
// https://github.com/jptmoore/zestdb/issues/25
time.Sleep(time.Millisecond * 10)
}

time.Sleep(time.Second)

result, err := tsc.Earliest(dsID + "TestEarliest")
if err != nil {
t.Errorf("Call to Earliest failed with error %s", err.Error())
Expand All @@ -425,6 +432,10 @@ func TestFirstN(t *testing.T) {
if err != nil {
t.Errorf("Write to %s failed expected err to be nil got %s", dsID+"TestFirstN", err.Error())
}
// On a fast CPU its possible to write faster than the resolution of zestDBs timestamp!
// when this happens it can return records out of order causing this test to fail ;-(
// so lets just sleep for a while to make sure!!
// https://github.com/jptmoore/zestdb/issues/25
time.Sleep(time.Millisecond * 10)
}

Expand Down Expand Up @@ -489,6 +500,10 @@ func TestWriteAtAndRange(t *testing.T) {
if err != nil {
t.Errorf("WriteAt to %s failed expected err to be nil got %s", dsID, err.Error())
}
// On a fast CPU its possible to write faster than the resolution of zestDBs timestamp!
// when this happens it can return records out of order causing this test to fail ;-(
// so lets just sleep for a while to make sure!!
// https://github.com/jptmoore/zestdb/issues/25
}

result, err := tsc.Range(dsID, now, now+int64(numRecords*timeStepMs), JSONTimeSeriesQueryOptions{})
Expand Down Expand Up @@ -545,7 +560,6 @@ func TestConcurrentWriteAndRead(t *testing.T) {

doneChanWrite := make(chan int)
doneChanRead := make(chan int)
//now := time.Now().UnixNano() / int64(time.Millisecond)
startAt := 1000
numRecords := 1100

Expand All @@ -555,7 +569,6 @@ func TestConcurrentWriteAndRead(t *testing.T) {
if err != nil {
t.Errorf("WriteAt to %s failed expected err to be nil got %s", dsID, err.Error())
}
//fmt.Println(string("written:: " + strconv.Itoa(i)))
}
doneChanWrite <- 1
}()
Expand All @@ -566,7 +579,6 @@ func TestConcurrentWriteAndRead(t *testing.T) {
if err != nil {
t.Errorf("Latest failed expected err to be nil got %s", err.Error())
}
//fmt.Println("Got:: ", string(data))
}
doneChanRead <- 1
}()
Expand Down Expand Up @@ -612,8 +624,9 @@ func TestObserve(t *testing.T) {

}()

//Observe take a bit of time to register we miss some values if we dont wait before writing
time.Sleep(time.Second)
// Observe take a bit of time to register
// we miss some values if we dont wait before writing
time.Sleep(time.Second * 2)

go func() {
for i := startAt; i <= numRecords; i++ {
Expand All @@ -623,15 +636,21 @@ func TestObserve(t *testing.T) {
}
t.Log(string("written:: " + strconv.Itoa(i)))
}

// we miss some values if we dont wait before saying we are done!
time.Sleep(time.Second * 3)
doneChanWrite <- 1
}()

<-doneChanWrite

if len(receivedData) < numRecords {
t.Errorf("receivedData Error: receivedData should contain '%d' items but contains %d", numRecords, len(receivedData))
}
for i := startAt; i <= numRecords; i++ {
expected := []byte("{\"value\":" + strconv.Itoa(i) + "}")
cont := s.Contains(string(receivedData[i].Json), string(expected))
t.Log(receivedData[i])
//t.Log(receivedData[i])
if cont != true {
t.Errorf("receivedData Error '%s' does not contain %s", string(receivedData[i].Json), string(expected))
break
Expand Down