コード例 #1
0
ファイル: sequins_test.go プロジェクト: delkyd/sequins
func getSequins(t *testing.T, opts sequinsOptions) *sequins {
	os.RemoveAll("test_data/0/.manifest")
	os.RemoveAll("test_data/1/.manifest")
	backend := backend.NewLocalBackend("test_data")
	s := newSequins(backend, opts)

	require.NoError(t, s.init())
	return s
}
コード例 #2
0
ファイル: main.go プロジェクト: delkyd/sequins
func localSetup(localPath string, opts sequinsOptions) *sequins {
	absPath, err := filepath.Abs(localPath)
	if err != nil {
		log.Fatal(err)
	}

	backend := backend.NewLocalBackend(absPath)
	opts.LocalPath = absPath

	return newSequins(backend, opts)
}
コード例 #3
0
ファイル: sequins_test.go プロジェクト: delkyd/sequins
// TestSequinsThreadsafe makes sure that reads that occur during an update DTRT
func TestSequinsThreadsafe(t *testing.T) {
	scratch, err := ioutil.TempDir("", "sequins-")
	require.NoError(t, err)
	createTestIndex(t, scratch, 0)
	ts := newSequins(backend.NewLocalBackend(scratch), sequinsOptions{scratch, false})
	h := ts.handler()
	require.NoError(t, ts.init())

	var wg sync.WaitGroup
	threads := 50
	wg.Add(threads)
	for i := 0; i < threads; i++ {
		go func() {
			for j := 0; j < 1000; j++ {
				req, err := http.NewRequest("GET", "/Alice", nil)
				assert.NoError(t, err)

				w := httptest.NewRecorder()
				h.ServeHTTP(w, req)

				if w.Code != 200 && w.Code != 404 {
					// we might get either response, depending on which version of the db we see
					// we just want to make sure that we don't 500 (or anything else)
					t.Errorf("Got error response when making a request (status=%d)", w.Code)
				}
			}
			wg.Done()
		}()
	}

	for i := 1; i < 100; i++ {
		createTestIndex(t, scratch, i)
		ts.reloadLatest()
	}
	wg.Wait()
	require.NoError(t, os.RemoveAll(scratch))
}
コード例 #4
0
ファイル: sequins_test.go プロジェクト: delkyd/sequins
func TestSequinsNoValidDirectories(t *testing.T) {
	backend := backend.NewLocalBackend("test_data/0")
	s := newSequins(backend, sequinsOptions{"test_data/0", false})
	err := s.init()
	assert.Error(t, err)
}