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

fix: Better wait in CLI integration test #1415

Conversation

orpheuslummis
Copy link
Contributor

Relevant issue(s)

Resolves #

Description

Improve the wait on the goroutine start a DefraCommand
Thanks @AndrewSisley

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

CI & Shahzad

@orpheuslummis orpheuslummis added the area/testing Related to any test or testing suite label Apr 27, 2023
@orpheuslummis orpheuslummis self-assigned this Apr 27, 2023
@orpheuslummis orpheuslummis force-pushed the orpheus/fix/cli-integration-test-better-wait branch from 84abb3c to 515769c Compare April 27, 2023 16:53
@orpheuslummis orpheuslummis force-pushed the orpheus/fix/cli-integration-test-better-wait branch from 515769c to 0b411d7 Compare April 27, 2023 16:56
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (b95c931) 74.90% compared to head (76388f9) 74.90%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1415   +/-   ##
========================================
  Coverage    74.90%   74.90%           
========================================
  Files          203      203           
  Lines        21072    21072           
========================================
  Hits         15782    15782           
  Misses        4210     4210           
  Partials      1080     1080           
Flag Coverage Δ
all-tests 74.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b95c931...76388f9. Read the comment docs.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but suggest checking in with Shahzad first to see if this improves things for his local (I'm not sure in the chat, he might have just tried -p 1

@shahzadlone
Copy link
Member

I still see some fails on my machine even after checking into this branch:

=== Failed
=== FAIL: tests/integration/cli TestStartCommandWithNoP2P (2.08s)
    utils.go:127: executing defra command with args [--url localhost:56409 start --no-p2p --rootdir /tmp/TestStartCommandWithNoP2P3635917543/002]
    start_test.go:80: expected ["2023-04-27T15:09:08.127-0400, \x1b[34mINFO\x1b[0m, defra.config, Created config file at /tmp/TestStartCommandWithNoP2P3635917543/002/config.yaml" "2023-04-27T15:09:08.127-0400, \x1b[34mINFO\x1b[0m, defra.cli, Starting DefraDB service..." "2023-04-27T15:09:08.127-0400, \x1b[34mINFO\x1b[0m, defra.cli, Opening badger store, {\"Path\": \"/tmp/TestStartCommandWithNoP2P3635917543/002/data\"}" "2023-04-27T15:09:09.218-0400, \x1b[31mERROR\x1b[0m, defra.cli, Execution error, {\"Error\": \"failed to listen on TCP address localhost:56409: listen tcp: lookup localhost: i/o timeout\"}"] to not contain "Error"

=== FAIL: tests/integration/cli TestClientSchemaPatch_InvalidJSONPatch (3.26s)
Created config file at /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/config.yaml
Starting DefraDB service...
Opening badger store
    utils.go:127: executing defra command with args [--url localhost:56686 client schema add -f /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/003/schema.graphql --rootdir /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/004]
    client_schema_patch_test.go:49: expected [""] to contain "success"

=== FAIL: tests/integration/cli TestRequestSimple (unknown)
Created config file at /tmp/TestRequestSimple3219253407/001/config.yaml
Starting DefraDB service...
Opening badger store
Starting P2P node
Started RPC server
Providing HTTP API at http://localhost:64438/api/v0. Use the GraphQL request endpoint at http://localhost:64438/api/v0/graphql
    utils.go:127: executing defra command with args [--url localhost:64438 client query query IntrospectionQuery {__schema {queryType { name }}} --rootdir /tmp/TestRequestSimple3219253407/003]
2023-04-27T15:09:31.273-0400    ERROR   badger  v3@v3.2103.5/memtable.go:160    Got error: While opening memtable: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem error: while opening file: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem error: open /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem: no such file or directory
unable to open: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem
github.com/dgraph-io/ristretto/z.OpenMmapFile
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/file.go:80
github.com/dgraph-io/badger/v3.(*logFile).open
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:556
github.com/dgraph-io/badger/v3.(*DB).openMemTable
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:130
github.com/dgraph-io/badger/v3.(*DB).newMemTable
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:153
github.com/dgraph-io/badger/v3.Open
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/db.go:338
github.com/sourcenetwork/defradb/datastore/badger/v3.NewDatastore
        /home/shahzad/~~/defradb/datastore/badger/v3/datastore.go:157
github.com/sourcenetwork/defradb/cli.start
        /home/shahzad/~~/defradb/cli/start.go:220
github.com/sourcenetwork/defradb/cli.MakeStartCommand.func2
        /home/shahzad/~~/defradb/cli/start.go:76
github.com/spf13/cobra.(*Command).execute
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940
github.com/spf13/cobra.(*Command).ExecuteC
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068
github.com/spf13/cobra.(*Command).ExecuteContextC
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1001
github.com/sourcenetwork/defradb/cli.(*DefraCommand).Execute
        /home/shahzad/~~/defradb/cli/cli.go:109
github.com/sourcenetwork/defradb/tests/integration/cli.runDefraNode.func1
        /home/shahzad/~~/defradb/tests/integration/cli/utils.go:96
runtime.goexit
        /home/shahzad/.local/bin/go1.19.5/src/runtime/asm_amd64.s:1594 for id: 1

2023-04-27T15:09:31.274-0400    ERROR   badger  v3@v3.2103.5/db.go:261  Received err: newMemTable error: While opening memtable: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem error: while opening file: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem error: open /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem: no such file or directory
unable to open: /tmp/TestClientSchemaPatch_InvalidJSONPatch2643506082/001/data/00001.mem
github.com/dgraph-io/ristretto/z.OpenMmapFile
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/ristretto@v0.1.1/z/file.go:80
github.com/dgraph-io/badger/v3.(*logFile).open
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:556
github.com/dgraph-io/badger/v3.(*DB).openMemTable
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:130
github.com/dgraph-io/badger/v3.(*DB).newMemTable
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/memtable.go:153
github.com/dgraph-io/badger/v3.Open
        /home/shahzad/go/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.5/db.go:338
github.com/sourcenetwork/defradb/datastore/badger/v3.NewDatastore
        /home/shahzad/~~/defradb/datastore/badger/v3/datastore.go:157
github.com/sourcenetwork/defradb/cli.start
        /home/shahzad/~~/defradb/cli/start.go:220
github.com/sourcenetwork/defradb/cli.MakeStartCommand.func2
        /home/shahzad/~~/defradb/cli/start.go:76
github.com/spf13/cobra.(*Command).execute
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940
github.com/spf13/cobra.(*Command).ExecuteC
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068
github.com/spf13/cobra.(*Command).ExecuteContextC
        /home/shahzad/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1001
github.com/sourcenetwork/defradb/cli.(*DefraCommand).Execute
        /home/shahzad/~~/defradb/cli/cli.go:109
github.com/sourcenetwork/defradb/tests/integration/cli.runDefraNode.func1
        /home/shahzad/~~/defradb/tests/integration/cli/utils.go:96
runtime.goexit
        /home/shahzad/.local/bin/go1.19.5/src/runtime/asm_amd64.s:1594. Cleaning up...
panic: Fail in goroutine after TestClientSchemaPatch_InvalidJSONPatch has completed

goroutine 5922 [running]:
testing.(*common).Fail(0xc00aa2e4e0)
        /home/shahzad/.local/bin/go1.19.5/src/testing/testing.go:824 +0x1a8
testing.(*common).Errorf(0xc00aa2e4e0, {0x22d24cb, 0x3}, {0xc00e2f02a0, 0x1, 0x1})
        /home/shahzad/.local/bin/go1.19.5/src/testing/testing.go:941 +0xaf
github.com/stretchr/testify/assert.Fail({0x28ce800, 0xc00aa2e4e0}, {0xc0001e4000, 0xc27}, {0x0, 0x0, 0x0})
        /home/shahzad/go/pkg/mod/github.com/stretchr/testify@v1.8.2/assert/assertions.go:262 +0x438
github.com/stretchr/testify/assert.NoError({0x28ce800, 0xc00aa2e4e0}, {0x28cc980, 0xc0088920f0}, {0x0, 0x0, 0x0})
        /home/shahzad/go/pkg/mod/github.com/stretchr/testify@v1.8.2/assert/assertions.go:1380 +0x127
github.com/sourcenetwork/defradb/tests/integration/cli.runDefraNode.func1(0x0?)
        /home/shahzad/~~/defradb/tests/integration/cli/utils.go:97 +0x21b
created by github.com/sourcenetwork/defradb/tests/integration/cli.runDefraNode
        /home/shahzad/~~/defradb/tests/integration/cli/utils.go:90 +0x805

DONE 1352 tests, 3 failures in 58.626s
make: *** [Makefile:148: test] Error 1

@fredcarle fredcarle merged commit e3b49c6 into sourcenetwork:develop Jul 19, 2023
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Description

Improve the wait on the goroutine start a DefraCommand
Thanks @AndrewSisley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants