Skip to content
This repository was archived by the owner on Aug 30, 2019. It is now read-only.

test: add integration package#544

Merged
gbbr merged 15 commits into
masterfrom
gbbr/integration
Dec 7, 2018
Merged

test: add integration package#544
gbbr merged 15 commits into
masterfrom
gbbr/integration

Conversation

@gbbr

@gbbr gbbr commented Nov 30, 2018

Copy link
Copy Markdown
Contributor

Adds a package which allows running a fake backend and an agent with a given configuration. The runner exposes methods to send payloads to the agent and a channel to receive anything the agent outputs to the backend.

An example of how tests would be written, along with a first integration test can be seen in test/suite/hostname_test.go

Comment thread test/buffer.go
Comment thread test/agent.go Outdated
s.StopAgent()
cmd := exec.Command("trace-agent", "-config", path)
s.log.Reset()
cmd.Stdout = s.log

@p-lambert p-lambert Nov 30, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! We can even inspect logs ❤️

Comment thread test/server.go Outdated
return s.srv.Shutdown(ctx)
}

func (s *Runner) startBackend() error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I would probably have a Backend abstraction encapsulating this and leave Runner just orchestrating (start/stop) both the agent and the Backend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These aspects we call "nits" are actually the ones I am most interested in when getting reviews. Structuring the code in the simplest, most decoupled and easy to understand (and test) way is what is most important to me. Your suggestion has also crossed my mind. I will explore this. It would even make sense to have the logic that starts/stops the agent as a separate unit.

@p-lambert p-lambert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great! Left a couple of nits as separate comments (sorry about that 🤦‍♂️ )

@gbbr
gbbr force-pushed the gbbr/integration branch 7 times, most recently from 71f1be2 to a3fec37 Compare December 1, 2018 16:13
@gbbr

gbbr commented Dec 1, 2018

Copy link
Copy Markdown
Contributor Author

@p-lambert I've separated out both the backend and the agent runner into separate more isolated components. I'd be curious to hear what you think if you can spare the time to take another look.

@gbbr
gbbr force-pushed the gbbr/integration branch 12 times, most recently from d2aae3f to e759ce2 Compare December 3, 2018 12:42
@gbbr
gbbr force-pushed the gbbr/integration branch 4 times, most recently from 913d715 to f306982 Compare December 3, 2018 12:58
Comment thread internal/test/testsuite/hostname_test.go

@LotharSee LotharSee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Left nitpicks, else good to me.

Comment thread internal/test/agent.go Outdated
Comment thread internal/test/testsuite/hostname_test.go
@p-lambert

Copy link
Copy Markdown
Member

@p-lambert I've separated out both the backend and the agent runner into separate more isolated components. I'd be curious to hear what you think if you can spare the time to take another look.

That's exactly what I had in mind. I think now the abstractions have each a well defined set of responsibilities and the code is easier to follow (and hopefully to maintain!). Great job!

@gbbr
gbbr force-pushed the gbbr/integration branch 2 times, most recently from 43978d0 to c94762d Compare December 4, 2018 09:47
@gbbr
gbbr force-pushed the gbbr/integration branch from c94762d to 862299d Compare December 4, 2018 09:50
@gbbr
gbbr merged commit 60eeae8 into master Dec 7, 2018
@gbbr
gbbr deleted the gbbr/integration branch December 7, 2018 11:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants