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

[tests] Add dbnode capable of being started in-process. #3759

Merged
merged 3 commits into from
Sep 21, 2021

Conversation

nbroyles
Copy link
Collaborator

What this PR does / why we need it:

This commit adds an implementation of resources.Node that
is capable of being started in-process as opposed to
being started via a Docker container.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


return nil
}

func updateDBNodePorts(cfg config.Configuration) (config.Configuration, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note, this is not the complete list of addresses we could watch for based on the config, but one could see how we would extend this to add support

return cfg, nil
}

func updateDBNodeFilepaths(cfg config.Configuration) (config.Configuration, []string, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ditto for filepaths

}, res.Datapoints[0])
}

func TestWriteTaggedFetchTaggedRoundtrip(t *testing.T) {
Copy link
Collaborator Author

@nbroyles nbroyles Sep 19, 2021

Choose a reason for hiding this comment

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

One interesting thing you can see from this test is that, while node setup is pretty painless, reading and writing could be more frictionless. Adding a layer of helpers after we reach dtest parity could be really nice here.

host, err := dbnode.HostDetails(9000)
require.NoError(t, err)

_, err = coord.CreateDatabase(admin.DatabaseCreateRequest{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would also be nice to simplify database creation as well after we get the foundational stuff in place.

@nbroyles nbroyles force-pushed the nb/in-process-coord branch 2 times, most recently from e75f283 to 5251677 Compare September 19, 2021 22:03
@nbroyles nbroyles force-pushed the nb/in-process-dbnode branch from 1e56add to 7d7e51f Compare September 19, 2021 22:04
@codecov
Copy link

codecov bot commented Sep 19, 2021

Codecov Report

Merging #3759 (3118bef) into master (914b23f) will decrease coverage by 0.0%.
The diff coverage is n/a.

❗ Current head 3118bef differs from pull request most recent head 2b2ce9d. Consider uploading reports for the commit 2b2ce9d to get more accurate results

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3759     +/-   ##
========================================
- Coverage    56.9%   56.8%   -0.1%     
========================================
  Files         552     552             
  Lines       62950   62950             
========================================
- Hits        35835   35804     -31     
- Misses      23927   23947     +20     
- Partials     3188    3199     +11     
Flag Coverage Δ
aggregator 63.3% <ø> (-0.1%) ⬇️
cluster ∅ <ø> (∅)
collector 58.4% <ø> (ø)
dbnode 60.5% <ø> (-0.1%) ⬇️
m3em 46.4% <ø> (ø)
metrics 19.7% <ø> (ø)
msg 74.3% <ø> (ø)

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


Continue to review full report at Codecov.

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

@nbroyles nbroyles force-pushed the nb/in-process-dbnode branch from 7d7e51f to b3877b0 Compare September 20, 2021 16:08
@nbroyles nbroyles force-pushed the nb/in-process-coord branch 2 times, most recently from e8a41e4 to 8c7ebab Compare September 20, 2021 18:31
@nbroyles nbroyles force-pushed the nb/in-process-dbnode branch 2 times, most recently from b12a4d6 to 0a6960b Compare September 20, 2021 18:47
Base automatically changed from nb/in-process-coord to master September 20, 2021 19:07
This commit adds an implementation of resources.Node that
is capable of being started in-process as opposed to
being started via a Docker container.
@nbroyles nbroyles force-pushed the nb/in-process-dbnode branch from 0a6960b to 5abce0e Compare September 20, 2021 19:40
@jaredjenkins jaredjenkins self-requested a review September 20, 2021 19:48
@@ -166,6 +166,34 @@ func NewCoordinator(cfg config.Configuration, opts CoordinatorOptions) (resource
return coord, nil
}

// NewEmbeddedCoordinator creates a coordinator from one embedded within an existing
// db node. This method expects that the DB node has already been started before
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is this expectation guaranteed? Does it error? Should it error if it doesn't?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lazily at the moment. In other words, coordinator API calls will fail since the http server isn't up to handle them. We can validate that here, but that'll take some rework. Will address in a follow up

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah failing fast is preferrable.

src/integration/resources/inprocess/dbnode.go Show resolved Hide resolved

for i := 0; i < d.cfg.Components(); i++ {
select {
case <-d.shutdownCh:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What exactly are we looping over here? And what are pulling from the shutdownCh?

Copy link
Collaborator Author

@nbroyles nbroyles Sep 20, 2021

Choose a reason for hiding this comment

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

A dbnode can be configured to run as just a dbnode or a dbnode and an embedded coordinator. Therefore, we need to receive shutdown signals from however many components have been started.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I am just confused by what we're looping over here? We don't seem to grab anything from the components?

Copy link
Collaborator Author

@nbroyles nbroyles Sep 20, 2021

Choose a reason for hiding this comment

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

We're waiting on N many shutdown notifications before we proceed where N is equal to the number of components we started up, which is what d.cfg.Components() returns. Each shutdown notification corresponds to a single component telling us they have finished.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. So I think it would just make sense to make this a method for the server interface...

server.ShutdownComponents(waitTime time.Duration) error

with each component implementing an actual Shutdown() method

errors := make(chan error)
for _, c : range components {
  c := c
  go func() {
   // capture the error here
   errors <- c.Shutdown()
  } ()
}

// Wait for shutdowns, with appropriate the timeout and error catching.

The two channel setup is just feels awkward and hard to read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think moving this to the server package is a good call. Though, fwiw, there are still going to be two channels -- one to interrupt the components and one to get notified when the components are done shutting down. Will try to make this as friendly as possible

@jaredjenkins jaredjenkins self-requested a review September 21, 2021 15:00
Copy link
Collaborator

@jaredjenkins jaredjenkins left a comment

Choose a reason for hiding this comment

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

approved, but yeah I don't love the server + component interactions.

@nbroyles nbroyles merged commit 9fea52c into master Sep 21, 2021
@nbroyles nbroyles deleted the nb/in-process-dbnode branch September 21, 2021 15:19
soundvibe added a commit that referenced this pull request Sep 23, 2021
* master:
  [dbnode,query] Allow blocking operations on main thread to be interrupted (#3764)
  [coordinator] Add support for prometheus remote write compatible backend (#3742)
  [tests] Add dbnode capable of being started in-process. (#3759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants