Skip to content

Commit

Permalink
Merge pull request #321 from aiven/hacka-remove-compatibility-tests
Browse files Browse the repository at this point in the history
tests: remove compatibility tests
  • Loading branch information
jongiddy authored Feb 3, 2022
2 parents de400ba + d26e988 commit edda19b
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions tests/integration/test_schema_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@
from karapace.utils import Client
from tests.utils import create_subject_name_factory

import json
import logging
import pytest
import requests

baseurl = "http://localhost:8081"

compatibility_test_url = (
"https://raw.githubusercontent.com/confluentinc/schema-registry/"
+ "0530b0107749512b997f49cc79fe423f21b43b87/"
+ "protobuf-provider/src/test/resources/diff-schema-examples.json"
)


def add_slashes(text: str) -> str:
escape_dict = {
Expand Down Expand Up @@ -112,60 +104,3 @@ async def test_protobuf_schema_compatibility(registry_async_client: Client, trai
)
assert res.status == 200
assert "id" in res.json()


class Schemas:
url = requests.get(compatibility_test_url)
sch = json.loads(url.text)
schemas = {}
descriptions = []
max_count = 120
count = 0
for a in sch:
# if a["description"] == "Detect compatible add field to oneof":
descriptions.append(a["description"])
schemas[a["description"]] = dict(a)
count += 1
if a["description"] == "Detect incompatible message index change":
break
if count == max_count:
break


@pytest.mark.parametrize("trail", ["", "/"])
@pytest.mark.parametrize("desc", Schemas.descriptions)
async def test_schema_registry_examples(registry_async_client: Client, trail: str, desc) -> None:
subject = create_subject_name_factory(f"test_protobuf_schema_compatibility-{trail}")()

res = await registry_async_client.put(f"config/{subject}{trail}", json={"compatibility": "BACKWARD"})
assert res.status == 200

description = desc

schema = Schemas.schemas[description]
original_schema = schema["original_schema"]
evolved_schema = schema["update_schema"]
compatible = schema["compatible"]

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema}
)
assert res.status == 200
assert "id" in res.json()

res = await registry_async_client.post(
f"compatibility/subjects/{subject}/versions/latest{trail}",
json={"schemaType": "PROTOBUF", "schema": evolved_schema},
)
assert res.status == 200
assert res.json() == {"is_compatible": compatible}

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": evolved_schema}
)

if compatible:
assert res.status == 200
assert "id" in res.json()
else:
assert res.status == 409

0 comments on commit edda19b

Please sign in to comment.