Skip to content

Commit

Permalink
schema_registry: Wire up delete_config_subject
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiman committed Oct 18, 2023
1 parent 8878c7d commit 3010aaf
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/v/pandaproxy/schema_registry/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ server::routes_t get_schema_registry_routes(ss::gate& gate, one_shot& es) {
ss::httpd::schema_registry_json::put_config_subject,
wrap(gate, es, put_config_subject)});

routes.routes.emplace_back(server::route_t{
ss::httpd::schema_registry_json::delete_config_subject,
wrap(gate, es, delete_config_subject)});

routes.routes.emplace_back(server::route_t{
ss::httpd::schema_registry_json::get_mode, wrap(gate, es, get_mode)});

Expand Down
76 changes: 76 additions & 0 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ def _set_config_subject(self,
data=data,
**kwargs)

def _delete_config_subject(self,
subject,
headers=HTTP_POST_HEADERS,
**kwargs):
return self._request("DELETE",
f"config/{subject}",
headers=headers,
**kwargs)

def _get_mode(self, headers=HTTP_GET_HEADERS, **kwargs):
return self._request("GET", "mode", headers=headers, **kwargs)

Expand Down Expand Up @@ -883,6 +892,54 @@ def test_config(self):
result_raw = self._get_config_subject(subject=f"{topic}-key")
assert result_raw.json()["compatibilityLevel"] == "BACKWARD_TRANSITIVE"

prev_compat = result_raw.json()["compatibilityLevel"]
global_config = self._get_config().json()

result_raw = self._delete_config_subject(subject=f"{topic}-key")
assert result_raw.json(
)["compatibilityLevel"] == prev_compat, f"{json.dumps(result_raw.json(), indent=1)}"

self.logger.debug("Second DELETE should return 40401")
result_raw = self._delete_config_subject(subject=f"{topic}-key")
assert result_raw.status_code == requests.codes.not_found, result_raw.status_code
assert result_raw.json(
)["error_code"] == 40401, f"Wrong err code: {result_raw.json()}"
assert result_raw.json(
)["message"] == f"Subject '{topic}-key' not found.", f"{json.dumps(result_raw.json(), indent=1)}"

self.logger.debug(
"GET config/{subject} should indicate missing subject-level config"
)
result_raw = self._get_config_subject(subject=f"{topic}-key")
assert result_raw.status_code == requests.codes.not_found
assert result_raw.json()["error_code"] == 40408
assert result_raw.json(
)["message"] == f"Subject '{topic}-key' does not have subject-level compatibility configured"

result_raw = self._get_config_subject(subject=f"{topic}-key",
fallback=True)
assert result_raw.json(
)["compatibilityLevel"] == global_config["compatibilityLevel"]

self.logger.debug(
"Subject compatibility should reflect the new global config")
global_config = self._set_config(
data=json.dumps({"compatibility": "NONE"}))
assert global_config.json()["compatibility"] == "NONE"

result_raw = self._get_config_subject(subject=f"{topic}-key",
fallback=True)
assert result_raw.json()["compatibilityLevel"] == global_config.json(
)["compatibility"]

self.logger.debug("DELETE on non-existant subject should 404")
result_raw = self._delete_config_subject(subject=f"foo-key")
assert result_raw.status_code == requests.codes.not_found, result_raw.status_code
assert result_raw.json(
)["error_code"] == 40401, f"Wrong err code: {result_raw.json()}"
assert result_raw.json(
)["message"] == f"Subject 'foo-key' not found.", f"{json.dumps(result_raw.json(), indent=1)}"

@cluster(num_nodes=3)
def test_mode(self):
"""
Expand Down Expand Up @@ -1927,6 +1984,25 @@ def test_config(self):
super_password))
assert result_raw.json()["compatibilityLevel"] == "BACKWARD_TRANSITIVE"

global_config = self._get_config(auth=(super_username,
super_password)).json()

old_config = result_raw.json()

result_raw = self._delete_config_subject(subject=f"{topic}-key",
auth=(super_username,
super_password))
assert result_raw.json(
)["compatibilityLevel"] == old_config["compatibilityLevel"]
#, f"{json.dumps(result_raw.json(), indent=1)}, {json.dumps(global_config, indent=1)}"

result_raw = self._get_config_subject(subject=f"{topic}-key",
fallback=True,
auth=(super_username,
super_password))
assert result_raw.json(
)["compatibilityLevel"] == global_config["compatibilityLevel"]

@cluster(num_nodes=3)
def test_mode(self):
"""
Expand Down

0 comments on commit 3010aaf

Please sign in to comment.