skatsuta / athenai

Have fun with Amazon Athena from command line! 🕊
Apache License 2.0
36 stars 0 forks source link

Fix a bug where TestShowResults sometime panics by index out of range #49

Closed skatsuta closed 7 years ago

skatsuta commented 7 years ago

TestShowResults sometimes panics by index out of range. Investigate and fix the cause.

--- FAIL: TestShowResults (0.00s)
panic: runtime error: index out of range [recovered]
    panic: runtime error: index out of range

goroutine 118 [running]:
testing.tRunner.func1(0xc42029fad0)
    /usr/local/go/src/testing/testing.go:622 +0x55f
panic(0xadd680, 0xea0b00)
    /usr/local/go/src/runtime/panic.go:489 +0x2f0
github.com/skatsuta/athenai/core.(*stubFilter).Run(0xc42025d800, 0xe76f60, 0xc420086d68, 0xb622be, 0x1)
    /go/src/github.com/skatsuta/athenai/core/athenai_test.go:547 +0x330
github.com/skatsuta/athenai/core.(*Athenai).filterQueryExecutions(0xc4201ca4d0, 0xc42025fa00, 0x0, 0x32, 0x0, 0x32, 0x0, 0x0, 0x0)
    github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:517 +0x95e
github.com/skatsuta/athenai/core.(*Athenai).selectQueryExecutions(0xc4201ca4d0, 0xe76f20, 0xc4201b5cc0, 0x0, 0x0, 0x0, 0x0, 0x0)
    github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:568 +0x289
github.com/skatsuta/athenai/core.(*Athenai).ShowResults(0xc4201ca4d0)
    github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:613 +0x227
github.com/skatsuta/athenai/core.TestShowResults(0xc42029fad0)
    /go/src/github.com/skatsuta/athenai/core/athenai_test.go:751 +0x2928
testing.tRunner(0xc42029fad0, 0xb81100)
    /usr/local/go/src/testing/testing.go:657 +0x108
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:697 +0x544
FAIL    github.com/skatsuta/athenai/core    0.170s
skatsuta commented 7 years ago
2017/08/06 18:36:02 Fetching 0 query excutions to be listed
2017/08/06 18:36:02 Paginating query executions to up to +Inf pages
⠋ Loading history... 2017/08/06 18:36:02 # of pages: current = 1, max = +Inf
2017/08/06 18:36:02 3 query executions have been fetched
2017/08/06 18:36:02 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:36:02 Reducing the number of entries from 3 to 3
SetInput: f.lines = [2017-07-01 02:00:00 +0000 UTC      SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UTC
SHOW DATABASES  SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB]
Run: f.lines = [2017-07-01 02:00:00 +0000 UTC   SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UTC   SHOW
DATABASES       SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB] (length: 3)
index: 0
index: 1
index: 2
2017/08/06 18:36:02 Selected 3 query execution entries
2017/08/06 18:36:02 Fetching 1 query excutions to be listed
2017/08/06 18:36:02 Paginating query executions to up to 1 pages
⠋ Loading history... 2017/08/06 18:36:02 # of pages: current = 1, max = 1
2017/08/06 18:36:02 3 query executions have been fetched
2017/08/06 18:36:02 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:36:02 Reducing the number of entries from 3 to 1
SetInput: f.lines = [2017-07-01 02:00:00 +0000 UTC      SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB]
Run: f.lines = [2017-07-01 02:00:00 +0000 UTC   SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB] (length: 1)
index: 0
2017/08/06 18:36:02 Selected 1 query execution entries
2017/08/06 18:36:02 Fetching 50 query excutions to be listed
2017/08/06 18:36:02 Paginating query executions to up to 1 pages
⠋ Loading history... 2017/08/06 18:36:02 # of pages: current = 1, max = 1
2017/08/06 18:36:02 3 query executions have been fetched
2017/08/06 18:36:02 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:36:02 Reducing the number of entries from 3 to 3
SetInput: f.lines = [2017-07-01 02:00:00 +0000 UTC      SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UTC
SHOW DATABASES  SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB]
Run: f.lines = [2017-07-01 02:00:00 +0000 UTC   SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UTC   SHOW
DATABASES       SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB] (length: 3)
index: 0
index: 1
index: 2
2017/08/06 18:36:02 Selected 3 query execution entries
2017/08/06 18:36:02 Fetching 0 query excutions to be listed
2017/08/06 18:36:02 Paginating query executions to up to +Inf pages
2017/08/06 18:36:02 # of pages: current = 1, max = +Inf
2017/08/06 18:36:02 0 query executions have been fetched
2017/08/06 18:36:02 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:36:02 Reducing the number of entries from 0 to 0
SetInput: f.lines = []
Run: f.lines = [] (length: 1)
index: 0
index: 1
⠋ Loading history... --- FAIL: TestShowResults (0.00s)
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range

goroutine 81 [running]:
testing.tRunner.func1(0xc4202bc9c0)
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:622 +0x55f
panic(0x16e4b20, 0x1aaf0b0)
        /usr/local/Cellar/go/1.8.3/libexec/src/runtime/panic.go:489 +0x2f0
github.com/skatsuta/athenai/core.(*stubFilter).Run(0xc4201c57a0, 0x1a850c0, 0xc420014ec8, 0x17697fe, 0x1)
        /Users/skatsuta/src/github.com/skatsuta/athenai/core/athenai_test.go:552 +0x551
github.com/skatsuta/athenai/core.(*Athenai).filterQueryExecutions(0xc4201ea580, 0xc4202be000, 0x0, 0x32, 0x0, 0x32, 0x0, 0x0, 0x0)
        github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:517 +0x95e
github.com/skatsuta/athenai/core.(*Athenai).selectQueryExecutions(0xc4201ea580, 0x1a85080, 0xc4201c2dc0, 0x0, 0x0, 0x0, 0x0, 0x0)
        github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:568 +0x289
github.com/skatsuta/athenai/core.(*Athenai).ShowResults(0xc4201ea580)
        github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:613 +0x227
github.com/skatsuta/athenai/core.TestShowResults(0xc4202bc9c0)
        /Users/skatsuta/src/github.com/skatsuta/athenai/core/athenai_test.go:756 +0x2928
testing.tRunner(0xc4202bc9c0, 0x17881d8)
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x108
created by testing.(*T).Run
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x544
FAIL    github.com/skatsuta/athenai/core        0.210s
go test -timeout=30s -cover -race ./core  11.24s user 1.61s system 253% cpu 5.069 total
skatsuta commented 7 years ago
2017/08/06 18:50:05 Fetching 0 query excutions to be listed                                                                                                                          2017/08/06 18:50:05 Paginating query executions to up to +Inf pages
⠋ Loading history... 2017/08/06 18:50:05 # of pages: current = 1, max = +Inf
2017/08/06 18:50:05 3 query executions have been fetched
2017/08/06 18:50:05 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:50:05 Reducing the number of entries from 3 to 3
SetInput: input = 2017-07-01 02:00:00 +0000 UTC SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB
2017-07-01 01:00:00 +0000 UTC   SHOW DATABASES  SUCCEEDED       12.35 seconds   56.79 KB
2017-07-01 00:00:00 +0000 UTC   SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB
SetInput: f.lines = [2017-07-01 02:00:00 +0000 UTC      SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UT$
SHOW DATABASES  SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB]
Run: f.lines = [2017-07-01 02:00:00 +0000 UTC   SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB 2017-07-01 01:00:00 +0000 UTC   SHOW
DATABASES       SUCCEEDED       12.35 seconds   56.79 KB 2017-07-01 00:00:00 +0000 UTC  SHOW TABLES     SUCCEEDED       1.11 seconds    2.22 KB] (length: 3)
index: 0
index: 1                                                                                                                                                                             index: 2
2017/08/06 18:50:05 Selected 3 query execution entries                                                                                                                               2017/08/06 18:50:05 Fetching 1 query excutions to be listed
2017/08/06 18:50:05 Paginating query executions to up to 1 pages
⠋ Loading history... 2017/08/06 18:50:05 # of pages: current = 1, max = 1
2017/08/06 18:50:05 3 query executions have been fetched
2017/08/06 18:50:05 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:50:05 Reducing the number of entries from 3 to 1
SetInput: input = 2017-07-01 02:00:00 +0000 UTC SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB
SetInput: f.lines = [2017-07-01 02:00:00 +0000 UTC      SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB]
Run: f.lines = [2017-07-01 02:00:00 +0000 UTC   SELECT date, time, bytes FROM cloudfront_logs LIMIT 3   SUCCEEDED       5.55 seconds    6.67 KB] (length: 1)
index: 0
2017/08/06 18:50:05 Selected 1 query execution entries
2017/08/06 18:50:05 Fetching 50 query excutions to be listed
2017/08/06 18:50:05 Paginating query executions to up to 1 pages
2017/08/06 18:50:05 # of pages: current = 1, max = 1
⠋ Loading history... 2017/08/06 18:50:05 0 query executions have been fetched
2017/08/06 18:50:05 Sorting query executions by SubmissionDateTime in descending order
2017/08/06 18:50:05 Reducing the number of entries from 0 to 0
SetInput: input =
SetInput: f.lines = []
Run: f.lines = [] (length: 1)
index: 0
index: 1
--- FAIL: TestSelectQueryExecutions (0.00s)
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range

goroutine 13 [running]:
testing.tRunner.func1(0xc4201b0f70)
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:622 +0x55f
panic(0x16e4be0, 0x1aaf0b0)
        /usr/local/Cellar/go/1.8.3/libexec/src/runtime/panic.go:489 +0x2f0
github.com/skatsuta/athenai/core.(*stubFilter).Run(0xc4201c57a0, 0x1a850c0, 0xc42006ad78, 0x17698be, 0x1)
        /Users/skatsuta/src/github.com/skatsuta/athenai/core/athenai_test.go:553 +0x551
github.com/skatsuta/athenai/core.(*Athenai).filterQueryExecutions(0xc4201e6420, 0xc420199380, 0x0, 0x32, 0x0, 0x32, 0x0, 0x0, 0x0)
        github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:517 +0x95e
github.com/skatsuta/athenai/core.(*Athenai).selectQueryExecutions(0xc4201e6420, 0x1a850c0, 0xc42006ad78, 0x0, 0x0, 0x0, 0x0, 0x0)
        github.com/skatsuta/athenai/core/_test/_obj_test/athenai.go:568 +0x289
github.com/skatsuta/athenai/core.TestSelectQueryExecutions(0xc4201b0f70)
        /Users/skatsuta/src/github.com/skatsuta/athenai/core/athenai_test.go:622 +0xb64
testing.tRunner(0xc4201b0f70, 0x1788280)
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x108
created by testing.(*T).Run
        /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x544
FAIL    github.com/skatsuta/athenai/core        0.209s
go test -timeout=30s -cover -race ./core  11.60s user 1.74s system 216% cpu 6.152 total
skatsuta commented 7 years ago

Fixed in a95f4a8f625c32709cd27c3b998d301a2722dc74.