-
Notifications
You must be signed in to change notification settings - Fork 579
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
pandaproxy: Invert error_code dependencies #4722
Merged
BenPope
merged 5 commits into
redpanda-data:dev
from
BenPope:move-kafka-error-code-to-kafka
May 16, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0cafa8
pandaproxy: Add tests for error_code, error_condition comparisons
BenPope c22d337
pandaproxy: Invert error_code dependencies
BenPope 69bdfff
pandaproxy: Invert kafka::error_code dependency
BenPope 3cbae3d
pandaproxy: Invert parse::error_code dependency
BenPope fd0eeb4
pandaproxy: Invert json::error_code dependency
BenPope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ v_cc_library( | |
error.cc | ||
DEPS | ||
Seastar::seastar | ||
v::pandaproxy_common | ||
) | ||
|
||
add_subdirectory(test) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
rp_test( | ||
UNIT_TEST | ||
BINARY_NAME pandaproxy_unit | ||
SOURCES | ||
errors.cc | ||
DEFINITIONS BOOST_TEST_DYN_LINK | ||
LIBRARIES Boost::unit_test_framework v::pandaproxy_common v::kafka_protocol | ||
LABELS pandaproxy | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2021 Redpanda Data, Inc. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.md | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0 | ||
*/ | ||
|
||
#define BOOST_TEST_MODULE pandaproxy | ||
|
||
#include "kafka/protocol/errors.h" | ||
|
||
#include "pandaproxy/error.h" | ||
#include "pandaproxy/json/error.h" | ||
#include "pandaproxy/parsing/error.h" | ||
|
||
#include <boost/test/data/monomorphic.hpp> | ||
#include <boost/test/data/test_case.hpp> | ||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <ostream> | ||
#include <system_error> | ||
#include <utility> | ||
|
||
namespace bdata = boost::unit_test::data; | ||
namespace pp = pandaproxy; | ||
using rec = pp::reply_error_code; | ||
using kec = kafka::error_code; | ||
using pec = pandaproxy::parse::error_code; | ||
using jec = pandaproxy::json::error_code; | ||
|
||
struct ec_cond { | ||
std::error_code ec; | ||
rec cond; | ||
friend std::ostream& operator<<(std::ostream& os, const ec_cond& p) { | ||
return os << p.ec.message() << ", " | ||
<< make_error_condition(p.cond).message(); | ||
} | ||
}; | ||
|
||
static const std::array<ec_cond, 5> conversion_data{ | ||
{{kec::offset_out_of_range, rec::kafka_bad_request}, | ||
{kec::unknown_server_error, rec::kafka_error}, | ||
{kec::unknown_topic_or_partition, rec::partition_not_found}, | ||
{pec::not_acceptable, rec::not_acceptable}, | ||
{jec::invalid_json, rec::unprocessable_entity}}}; | ||
|
||
BOOST_DATA_TEST_CASE( | ||
test_error_condition_conversion, bdata::make(conversion_data), sample) { | ||
auto ec = sample.ec; | ||
auto cond = pp::make_error_condition(ec); | ||
BOOST_REQUIRE(sample.cond == cond); | ||
} | ||
|
||
BOOST_DATA_TEST_CASE( | ||
test_error_condition_equivalence, bdata::make(conversion_data), sample) { | ||
BOOST_REQUIRE(sample.cond == sample.ec); | ||
BOOST_REQUIRE(sample.ec == sample.cond); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit:
[[fallthrough]];
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.
I tend to do that only for cases where there is a statement. I don't think the compiler will warn unless there is a statement, anyhow.
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.
hmm, i thought clang-tidy warned in this case, but indeed im not see it.