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

test: Break down huge monolith mock header to improve test compilation performance #11797

Merged
merged 17 commits into from
Jul 6, 2020

Conversation

foreseeable
Copy link
Contributor

Commit Message: breakdown test/mocks/server/mocks.h into different mock classes
Additional Description: test/mocks/server/mocks.h is a wide-used mock header included by various test files. However it's very huge and most test files only used a small portion of it. Splitting it up into different mock classes will be helpful to reduce compilation time.
Risk Level: low
Testing: existing tests
Docs Changes: N/A
Release Notes: no
Related Issues: #10917

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
@foreseeable
Copy link
Contributor Author

@ahedberg

#include "gmock/gmock.h"
#include "gtest/gtest.h"

using testing::_;
Copy link
Contributor

Choose a reason for hiding this comment

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

As I mentioned on the last PR, these should be fully-qualified and inside the innermost working namespace, or removed if not being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for let me know, now they should be fully qualified and stay inside the innermost namespace.

MOCK_METHOD(std::string, name, (), (const, override));
};
} // namespace Configuration

Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the blank lines between closing namespace brackets would be more consistent with the opening namespace brackets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now they're removed

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
@@ -0,0 +1,32 @@
#pragma once

#include <chrono>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we scripting the removal of extra #includes or doing it manually? We don't need most of these system headers in the new headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remove them manually, just forget to remove them. Thanks for pointing out

} // namespace Configuration
} // namespace Server
} // namespace Envoy
namespace Envoy {}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete the .cc file.

#include "worker.h"
#include "worker_factory.h"

namespace Envoy {}
Copy link
Contributor

Choose a reason for hiding this comment

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

This empty namespace block can be removed.

Signed-off-by: Muge Chen <mugechen@google.com>
Copy link
Contributor

@ahedberg ahedberg left a comment

Choose a reason for hiding this comment

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

Please fix formatting. ./ci/run_envoy_docker.sh './ci/do_ci.sh fix_format' should do it.

Signed-off-by: Muge Chen <mugechen@google.com>
@foreseeable
Copy link
Contributor Author

foreseeable commented Jun 30, 2020

cc @ahedberg

Please fix formatting. ./ci/run_envoy_docker.sh './ci/do_ci.sh fix_format' should do it.

Now it should be fixed. Actually the empty namespace block in mocks.h from previous commits was used to make the formatter happy. now I found I can use no lint instead

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Muge Chen <mugechen@google.com>
@lizan lizan merged commit 7d5e12c into envoyproxy:master Jul 6, 2020
htuch pushed a commit that referenced this pull request Jul 23, 2020
… up test compilation (#12048)

breakdown test/mocks/upstream/mocks.h into different mock classes

test/mocks/upstream/mocks.h is a wide-used mock header included by various test files. However it's very huge and most test files only used a small portion of it. Splitting it up into different mock classes will be helpful to reduce compilation time. (similar to #11797 )

Risk Level: low
Testing: existing tests
Docs Changes: N/A
Release Notes: no
Related Issues: #10917

Signed-off-by: Muge Chen <mugechen@google.com>
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
… up test compilation (envoyproxy#12048)

breakdown test/mocks/upstream/mocks.h into different mock classes

test/mocks/upstream/mocks.h is a wide-used mock header included by various test files. However it's very huge and most test files only used a small portion of it. Splitting it up into different mock classes will be helpful to reduce compilation time. (similar to envoyproxy#11797 )

Risk Level: low
Testing: existing tests
Docs Changes: N/A
Release Notes: no
Related Issues: envoyproxy#10917

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
…n performance (envoyproxy#11797)

Commit Message: breakdown `test/mocks/server/mocks.h` into different mock classes
Additional Description:  `test/mocks/server/mocks.h` is a wide-used mock header included by various test files. However it's very huge and most test files only used a small portion of it. Splitting it up into different mock classes will be helpful to reduce compilation time.

Risk Level: low
Testing: existing tests
Docs Changes: N/A
Release Notes: no
Related Issues: envoyproxy#10917

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this pull request Aug 7, 2020
… up test compilation (envoyproxy#12048)

breakdown test/mocks/upstream/mocks.h into different mock classes

test/mocks/upstream/mocks.h is a wide-used mock header included by various test files. However it's very huge and most test files only used a small portion of it. Splitting it up into different mock classes will be helpful to reduce compilation time. (similar to envoyproxy#11797 )

Risk Level: low
Testing: existing tests
Docs Changes: N/A
Release Notes: no
Related Issues: envoyproxy#10917

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: chaoqinli <chaoqinli@google.com>
htuch pushed a commit that referenced this pull request Aug 28, 2020
We need to reduce resource consumption of test compilation by simplifying mock library inclusions. #10917
One way to do that is to break the monolithic mock headers into different mock classes and then refactor the code base (like #12053 #12051 #11797)
It's hard to refactor them manually. So I wrote headersplit, a tool based on libclang and python to help me divide the monolithic mock header and replace includes after dividing automatically. This tool can also generate building time comparison between before/after refactoring.

Risk level: low
Testing: Build succeeds.

Signed-off-by: Muge Chen <mugechen@google.com>
clarakosi pushed a commit to clarakosi/envoy that referenced this pull request Sep 3, 2020
)

We need to reduce resource consumption of test compilation by simplifying mock library inclusions. envoyproxy#10917
One way to do that is to break the monolithic mock headers into different mock classes and then refactor the code base (like envoyproxy#12053 envoyproxy#12051 envoyproxy#11797)
It's hard to refactor them manually. So I wrote headersplit, a tool based on libclang and python to help me divide the monolithic mock header and replace includes after dividing automatically. This tool can also generate building time comparison between before/after refactoring.

Risk level: low
Testing: Build succeeds.

Signed-off-by: Muge Chen <mugechen@google.com>
Signed-off-by: Clara Andrew-Wani <candrewwani@gmail.com>
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.

3 participants