<commit_before>package filestore

import (
	"io/ioutil"
	"os"
	"testing"
	"time"

	"github.com/smancke/guble/store"
	"github.com/stretchr/testify/assert"

	"math"
	"strconv"

	log "github.com/Sirupsen/logrus"
)

func Test_MessagePartition_forConcurrentWriteAndReads(t *testing.T) {
	// defer testutil.EnableDebugForMethod()()
	// testutil.PprofDebug()
	a := assert.New(t)
	dir, _ := ioutil.TempDir("", "guble_partition_store_test")
	defer os.RemoveAll(dir)

	store, _ := newMessagePartition(dir, "myMessages")

	n := 2000 * 100
	nReaders := 7

	writerDone := make(chan bool)
	go messagePartitionWriter(a, store, n, writerDone)

	readerDone := make(chan bool)
	for i := 1; i <= nReaders; i++ {
		go messagePartitionReader("reader"+strconv.Itoa(i), a, store, n, readerDone)
	}

	select {
	case <-writerDone:
	case <-time.After(time.Second * 15):
		a.Fail("writer timed out")
	}

	timeout := time.After(time.Second * 15)
	for i := 0; i < nReaders; i++ {
		select {<commit_msg>Increase timeout for robustness test cause travis is too slow<commit_after>package filestore

import (
	"io/ioutil"
	"os"
	"testing"
	"time"

	"github.com/smancke/guble/store"
	"github.com/stretchr/testify/assert"

	"math"
	"strconv"

	log "github.com/Sirupsen/logrus"
)

func Test_MessagePartition_forConcurrentWriteAndReads(t *testing.T) {
	// defer testutil.EnableDebugForMethod()()
	// testutil.PprofDebug()
	a := assert.New(t)
	dir, _ := ioutil.TempDir("", "guble_partition_store_test")
	defer os.RemoveAll(dir)

	store, _ := newMessagePartition(dir, "myMessages")

	n := 2000 * 100
	nReaders := 7

	writerDone := make(chan bool)
	go messagePartitionWriter(a, store, n, writerDone)

	readerDone := make(chan bool)
	for i := 1; i <= nReaders; i++ {
		go messagePartitionReader("reader"+strconv.Itoa(i), a, store, n, readerDone)
	}

	select {
	case <-writerDone:
	case <-time.After(time.Second * 30):
		a.Fail("writer timed out")
	}

	timeout := time.After(time.Second * 30)
	for i := 0; i < nReaders; i++ {
		select {
{'fraction_non_alphanumeric': 0.1534603811434303, 'fraction_numerical': 0.014042126379137413, 'mean_word_length': 4.450819672131147, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2763189', 'n_tokens_mistral': 824, 'n_tokens_neox': 759, 'n_words': 161}