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

Conversation

@dhrupadb
Copy link
Contributor

No description provided.

return updater.ValidateConfiguration();
}

void UpdateMetadataCallback(MetadataUpdater::ResourceMetadata& result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

MetadataUpdater::ResourceMetadata&&.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

updater.UpdateMetadataCallback(std::move(result));
}

void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

const MetadataUpdater::ResourceMetadata&.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) {
updater.UpdateResourceCallback(std::move(result));
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to std::moveUpdateResourceCallback takes a const reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

MetadataStore::Metadata::IGNORED()
);
UpdateResourceCallback(metadata);
EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource(""));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it fits on one line, but for consistency, let's put the store.LookupResource() call on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@dhrupadb dhrupadb left a comment

Choose a reason for hiding this comment

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

PTAL

return updater.ValidateConfiguration();
}

void UpdateMetadataCallback(MetadataUpdater::ResourceMetadata& result) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

updater.UpdateMetadataCallback(std::move(result));
}

void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

void UpdateResourceCallback(MetadataUpdater::ResourceMetadata& result) {
updater.UpdateResourceCallback(std::move(result));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

MetadataStore::Metadata::IGNORED()
);
UpdateResourceCallback(metadata);
EXPECT_EQ(MonitoredResource("test_resource", {}), store.LookupResource(""));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/store.h Outdated
private:
friend class MetadataReporter;
friend class MetadataStoreTest;
friend class UpdaterTest;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just make GetMetadataMap public instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

namespace {

TEST_F(UpdaterTest, ValidateConfiguration) {
EXPECT_TRUE(ValidateConfiguration());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also check that PollingMetadataUpdater::ValidateConfiguration fails when the period is negative?
You would have to pull out the variables from the fixture and make the accessor function take an updater object instead, i.e.:

  static bool ValidateConfiguration(const MetadataUpdater& updater) {
    return updater.ValidateConfiguration();
  }

  static void UpdateMetadataCallback(
      MetadataUpdater* updater, MetadataUpdater::ResourceMetadata&& result) {
    updater->UpdateMetadataCallback(std::move(result));
  }

  static void UpdateResourceCallback(
      MetadataUpdater* updater,
      const MetadataUpdater::ResourceMetadata& result) {
    updater->UpdateResourceCallback(result);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@dhrupadb dhrupadb left a comment

Choose a reason for hiding this comment

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

PTAL

src/store.h Outdated
private:
friend class MetadataReporter;
friend class MetadataStoreTest;
friend class UpdaterTest;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

namespace {

TEST_F(UpdaterTest, ValidateConfiguration) {
EXPECT_TRUE(ValidateConfiguration());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/store.h Outdated

MetadataStore(const Configuration& config);

// Returns a copy of the map containing the mapping from monitored
Copy link
Contributor

Choose a reason for hiding this comment

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

Just Returns a copy of the mapping from ... is good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


namespace {

TEST_F(UpdaterTest, ValidateConfiguration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's give this a better name, e.g., OneMinutePollingIntervalIsValid?
Can you also add a ZeroPollingIntervalIsValid test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

EXPECT_TRUE(ValidateConfiguration(&updater));
}

TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NegativePollingIntervalIsInvalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

EXPECT_FALSE(ValidateConfiguration(&updater));
}

TEST_F(UpdaterTest, UpdateMetadataCallbackTest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Test suffix in all of these test names is superfluous. Let's get rid of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@dhrupadb dhrupadb left a comment

Choose a reason for hiding this comment

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

PTAL

src/store.h Outdated

MetadataStore(const Configuration& config);

// Returns a copy of the map containing the mapping from monitored
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


namespace {

TEST_F(UpdaterTest, ValidateConfiguration) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

EXPECT_TRUE(ValidateConfiguration(&updater));
}

TEST_F(UpdaterTest, UpdaterWithInvalidPollingIntervalTest) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

EXPECT_FALSE(ValidateConfiguration(&updater));
}

TEST_F(UpdaterTest, UpdateMetadataCallbackTest) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

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

A minor comment nit.

src/store.h Outdated

MetadataStore(const Configuration& config);

// Returns a copy of the mapping from monitored resources to metadata
Copy link
Contributor

Choose a reason for hiding this comment

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

from a monitored resource to — otherwise one is plural and one is singular.
Also the metadata.
So:

  // Returns a copy of the mapping from a monitored resource to the
  // metadata associated with that resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@dhrupadb dhrupadb left a comment

Choose a reason for hiding this comment

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

PTAL

src/store.h Outdated

MetadataStore(const Configuration& config);

// Returns a copy of the mapping from monitored resources to metadata
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

Copy link
Contributor

@bmoyles0117 bmoyles0117 left a comment

Choose a reason for hiding this comment

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

LGTM

@igorpeshansky igorpeshansky removed the request for review from ACEmilG March 31, 2018 21:21
@igorpeshansky igorpeshansky merged commit f8f54a9 into master Mar 31, 2018
@igorpeshansky igorpeshansky deleted the dhrupadb-metadata-updater-unittests branch March 31, 2018 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants