Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Aug 20, 2024
1 parent 4a2e5ac commit ce9d58d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions database/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"testing"
"time"

"github.com/konveyor/tackle2-hub/model"
"k8s.io/utils/env"
Expand All @@ -13,8 +14,11 @@ import (
var N, _ = env.GetInt("TEST_CONCURRENT", 10)

func TestConcurrent(t *testing.T) {
Settings.DB.Path = "/tmp/concurrent.db"
_ = os.Remove(Settings.DB.Path)
pid := os.Getpid()
Settings.DB.Path = fmt.Sprintf("/tmp/concurrent-%d.db", pid)
defer func() {
_ = os.Remove(Settings.DB.Path)
}()
db, err := Open(true)
if err != nil {
panic(err)
Expand All @@ -32,14 +36,12 @@ func TestConcurrent(t *testing.T) {
panic(uErr)
}
for i := 0; i < 10; i++ {
fmt.Printf("(%.4d) BEGIN: %.4d/%.4d\n", id, n, i)
tx := db.Begin()
fmt.Printf("(%.4d) FIRST: %.4d/%.4d\n", id, n, i)
time.Sleep(time.Millisecond * time.Duration(n))
uErr = tx.First(m).Error
if uErr != nil {
panic(uErr)
}
fmt.Printf("(%.4d) SAVE: %.4d/%.4d\n", id, n, i)
uErr = tx.Save(m).Error
if uErr != nil {
panic(uErr)
Expand Down

0 comments on commit ce9d58d

Please sign in to comment.