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

[CI] Mega nit, add race condition detection to the tests & fix race to log #27

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
DATAROOM_TEST_SOURCE: ${{ secrets.DATAROOM_TEST_SOURCE }}
DATAROOM_API_URL: ${{ secrets.DATAROOM_API_URL }}

run: cd tests && go test -v .
run: cd tests && go test -race -v .
11 changes: 4 additions & 7 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ type DatagoClient struct {

// GetClient is a constructor for the DatagoClient, given a JSON configuration string
func GetClient(config DatagoConfig) *DatagoClient {
// Initialize the vips library
vips.LoggingSettings(nil, vips.LogLevelWarning)
vips.Startup(nil)

// Create the generator and backend
var generator Generator
var backend Backend
Expand Down Expand Up @@ -202,13 +206,6 @@ func (c *DatagoClient) Start() {
c.context, c.cancel = context.WithCancel(context.Background())
}

debug.SetGCPercent(10) // Invoke GC 10x more often

vips.LoggingSettings(func(domain string, level vips.LogLevel, msg string) {
fmt.Println(domain, level, msg)
}, vips.LogLevelWarning)
vips.Startup(nil) // Initialize the vips library, image processing backend

// Report panics in the background goroutines
defer func() {
if r := recover(); r != nil {
Expand Down
6 changes: 4 additions & 2 deletions tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func TestClientNoStop(t *testing.T) {
client := datago.GetClient(clientConfig)
client.Start()
_ = client.GetSample()

}

func TestMoreThanBufferSize(t *testing.T) {
Expand All @@ -72,6 +71,7 @@ func TestMoreThanBufferSize(t *testing.T) {
if client.GetSample().ID == "" {
t.Errorf("GetSample returned an unexpected error")
}
client.Stop()
}

func TestFetchImage(t *testing.T) {
Expand Down Expand Up @@ -220,6 +220,7 @@ func TestImageBufferCompression(t *testing.T) {
if err != nil {
t.Errorf("Error decoding mask buffer")
}
client.Stop()
}

func TestStrings(t *testing.T) {
Expand Down Expand Up @@ -255,11 +256,12 @@ func TestRanks(t *testing.T) {
clientConfig.SourceConfig = dbConfig

client_0 := datago.GetClient(clientConfig)
client_0.Start()

dbConfig.Rank = 1
clientConfig.SourceConfig = dbConfig
client_1 := datago.GetClient(clientConfig)

client_0.Start()
client_1.Start()

samples_0 := make(map[string]int)
Expand Down
Loading