Skip to content

Commit

Permalink
make the cache tests actually run
Browse files Browse the repository at this point in the history
Signed-off-by: AliceProxy <[email protected]>
  • Loading branch information
AliceProxy authored and LanceEa committed May 28, 2022
1 parent 432134c commit 3fb6b2f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions python/tests/unit/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def strip_cache_keys(self, node: Any) -> Any:
return node


@pytest.mark.compilertest
def test_circular_link():
builder = Builder(logger, "cache_test_1.yaml")
builder.build()
Expand Down Expand Up @@ -300,6 +301,7 @@ def test_circular_link():
builder.check_last("after invalidating circular links")


@pytest.mark.compilertest
def test_multiple_rebuilds():
builder = Builder(logger, "cache_test_1.yaml")

Expand All @@ -310,6 +312,7 @@ def test_multiple_rebuilds():
builder.check_last(f"rebuild {i-1} -> {i}")


@pytest.mark.compilertest
def test_simple_targets():
builder = Builder(logger, "cache_test_1.yaml")

Expand All @@ -325,6 +328,7 @@ def test_simple_targets():
builder.check_last("after delete foo-4")


@pytest.mark.compilertest
def test_smashed_targets():
builder = Builder(logger, "cache_test_2.yaml")

Expand All @@ -342,6 +346,7 @@ def test_smashed_targets():
builder.check_last("after invalidating foo-4 and foo-6")


@pytest.mark.compilertest
def test_delta_1():
builder1 = Builder(logger, "cache_test_1.yaml")
builder2 = Builder(logger, "cache_test_1.yaml", enable_cache=False)
Expand All @@ -365,6 +370,7 @@ def test_delta_1():
builder3.check("final", b3, b1)


@pytest.mark.compilertest
def test_delta_2():
builder1 = Builder(logger, "cache_test_2.yaml")
builder2 = Builder(logger, "cache_test_2.yaml", enable_cache=False)
Expand All @@ -388,6 +394,7 @@ def test_delta_2():
builder3.check("final", b3, b1)


@pytest.mark.compilertest
def test_delta_3():
builder1 = Builder(logger, "cache_test_1.yaml")
builder2 = Builder(logger, "cache_test_1.yaml", enable_cache=False)
Expand Down Expand Up @@ -416,6 +423,7 @@ def test_delta_3():
builder3.check("final", b3, b1)


@pytest.mark.compilertest
def test_delete_4():
builder1 = Builder(logger, "cache_test_1.yaml")
builder2 = Builder(logger, "cache_test_1.yaml", enable_cache=False)
Expand All @@ -439,6 +447,8 @@ def test_delete_4():

builder3.check("final", b3, b1)


@pytest.mark.compilertest
def test_long_cluster_1():
# Create a cache for Mappings whose cluster names are too long
# to be envoy cluster names and must be truncated.
Expand All @@ -463,8 +473,8 @@ def test_long_cluster_1():

print("test_long_cluster_1 done")

MadnessVerifier = Callable[[Tuple[IR, EnvoyConfig]], bool]

@pytest.mark.compilertest
def test_mappings_same_name_delta():
# Tests that multiple Mappings with the same name (but in different namespaces)
# are properly added/removed from the cache when they are updated.
Expand All @@ -477,7 +487,7 @@ def test_mappings_same_name_delta():
# to ensure their clusters were generated properly.
cluster1_ok, cluster2_ok = False
for cluster in econf['static_resources']['clusters']:
cname = cluster.get('per_connection_buffer_limit_bytes', None)
cname = cluster.get('name', None)
assert cname is not None, \
f"Error, cluster missing cluster name in econf"
# The 6666 in the cluster name comes from the Mapping.spec.service's port
Expand All @@ -498,7 +508,7 @@ def test_mappings_same_name_delta():

cluster1_ok, cluster2_ok = False
for cluster in econf['static_resources']['clusters']:
cname = cluster.get('per_connection_buffer_limit_bytes', None)
cname = cluster.get('name', None)
assert cname is not None, \
f"Error, cluster missing cluster name in econf"
# We can check the cluster name to identify if the clusters were updated properly
Expand All @@ -514,6 +524,9 @@ def test_mappings_same_name_delta():
assert cluster1_ok and cluster2_ok, 'clusters could not be found with the correct econf after updating their config'


MadnessVerifier = Callable[[Tuple[IR, EnvoyConfig]], bool]


class MadnessMapping:
name: str
pfx: str
Expand Down Expand Up @@ -660,7 +673,7 @@ def check_group(self, b: Tuple[IR, EnvoyConfig], current_mappings: Dict[MadnessM

return match


@pytest.mark.compilertest
def test_cache_madness():
builder1 = Builder(logger, "/dev/null")
builder2 = Builder(logger, "/dev/null", enable_cache=False)
Expand Down

0 comments on commit 3fb6b2f

Please sign in to comment.