-
Notifications
You must be signed in to change notification settings - Fork 13
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
e2e_test: integrate MistLoadTest to verify streaming #54
Conversation
172c504
to
73bb142
Compare
73bb142
to
67d8ad2
Compare
test/e2e/e2e_test.go
Outdated
|
||
matches, err := filepath.Glob("*" + strings.ToUpper(prot) + "*json") | ||
if err != nil { | ||
panic(fmt.Errorf("Glob failed: %w", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will defer to @leszko here on best practices for tests like this, but should this maybe be returning an error instead of panicking? Seems like a good practice in general... on the other hand I can see how this error would be like "test harness failure" instead of "failing test" and maybe a panic makes sense there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm inclined to remove the panic and just make it a general "fail". We'd be reviewing logs anyways to see where the failures are - doesn't seem like a panic would be anymore useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better to not use panic
in tests. You can do t.Fail()
instead.
test/e2e/e2e_test.go
Outdated
|
||
content, err := ioutil.ReadFile(matches[0]) | ||
if err != nil { | ||
glog.Fatalf("Error while opening output file: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any event, no sense in doing anything else after a Fatalf
, which will crash the process immediately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I realize that now after looking at the Fatalf
man page which calls os.Exit right after. Will fix.
test/e2e/e2e_test.go
Outdated
return true | ||
} | ||
require.Eventually(t, correctStream, 5*time.Minute, time.Second) | ||
|
||
// Define a set of protocols to test at output of node catalyst-two | ||
protocols := map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I'm thinking that each protocol should probably be its own test, rather than just having one big loop in here? Minimally, having a separate function for running a protocol test will let you return err
in the error cases for those instead of having to do awkward continue
s or break
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think I got a little lost in trying to do things in the "idiomatic" go style. I'll take a look at refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it should be a separate test. Also, the very idiomatic in Go is to use a tests [] array. Please check "Introducing table driven tests" in https://dave.cheney.net/2019/05/07/prefer-table-driven-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really really nice! Happy it wasn't too terrible to get this working properly - just suggested a few structuring changes
67d8ad2
to
c3ca3ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments. But two general thoughts:
- We should create more tests rather than expanding the assertion of the same test. Having more tests give us better information what failed. One single test is hard to analyze in case of failures.
- I'd try to not cleanup files manually, but rather depend on the built-in 1
t.TempDir()
test/e2e/e2e_test.go
Outdated
return true | ||
} | ||
require.Eventually(t, correctStream, 5*time.Minute, time.Second) | ||
|
||
// Define a set of protocols to test at output of node catalyst-two | ||
protocols := map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it should be a separate test. Also, the very idiomatic in Go is to use a tests [] array. Please check "Introducing table driven tests" in https://dave.cheney.net/2019/05/07/prefer-table-driven-tests
test/e2e/e2e_test.go
Outdated
} | ||
|
||
// rm any old output files from previous MistLoadTest runs | ||
cleanupFiles("*json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to store all these files in the t.TempDir()
, then the files are automatically removed after the test is completed.
Manually removing the files has some disadvantages, e.g., if the test fails, then we can end up with uncleaned files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll have to update MistLoadUtil
to accept a different path. But agree managing files is not the best way - didn't know about t.TempDir()
so i'll try to get that to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR here to allow output directory:
DDVTECH/mistserver@1341ffb
This should let me refactor into something much simpler.
test/e2e/e2e_test.go
Outdated
|
||
glog.Infof("Testing %s using url: %s", prot, url) | ||
|
||
cmdMistLoadTest := exec.Command("../../bin/./MistLoadTest", url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already commented above, I think this should be a completely separate test, not to add too many things in one test. In general, it's better to have more smaller tests, than one very big test.
test/e2e/e2e_test.go
Outdated
} | ||
glog.Infof("MistLoadTest stdout: %s", out) | ||
|
||
defer cmdMistLoadTest.Process.Kill() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that this process is not killed and we end up with a running MistLoadTest
process? E.g. what happens if the line 250
fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MistLoadTest
will timeout and exit within 30s (default). I'll turn it into a parameter in the next push and verify it does work as expected.
test/e2e/e2e_test.go
Outdated
} | ||
|
||
// Parse output results for each protocol tested above | ||
var p bool = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var p bool = true | |
p := true |
test/e2e/e2e_test.go
Outdated
|
||
matches, err := filepath.Glob("*" + strings.ToUpper(prot) + "*json") | ||
if err != nil { | ||
panic(fmt.Errorf("Glob failed: %w", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better to not use panic
in tests. You can do t.Fail()
instead.
test/e2e/e2e_test.go
Outdated
} | ||
fmt.Println(matches) | ||
|
||
content, err := ioutil.ReadFile(matches[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are multiple files that are matched? Like there is already another *.json
file in the directory?
test/e2e/e2e_test.go
Outdated
if err != nil { | ||
panic(fmt.Errorf("Glob failed: %w", err)) | ||
} | ||
fmt.Println(matches) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to glog
0ad11df
to
dc7fd92
Compare
0ad11df
to
5cc69cd
Compare
Updates:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some minor comments. Other than that, it looks good. Thanks for all the changes @emranemran 👍
8acd8d7
to
f3e6cda
Compare
Use MistLoadTest to spawn multiple clients for a specific protocol (e.g. HLS) as viewers at catalyst-two node. The test passes if every client is able to connect and stream successfully. The json files generated by MistLoadTest are parsed to verify if streams passed or failed.
0a38628
to
3169383
Compare
…I host The Mist tester binaries need to run outside of the containers or inside another container. This is a temporary workaround to run outside the containers directly on the CI host. This is obviously a bit fragile and a follow up change will be used to make this more robust by using a third container that contains all relevant test binaries
3169383
to
1f91195
Compare
Use MistLoadTest to spawn multiple clients for a specific protocol (e.g. HLS) as viewers at catalyst-two node. The test passes if every client is able to connect and stream successfully. The json files generated by MistLoadTest are parse to verify if streams passed or failed.