Skip to content

Commit

Permalink
Fix #75 Add missing constraint to rule out invalid stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
fchauvel committed Sep 25, 2019
1 parent 9941973 commit 161f424
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions camp/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,17 @@ def coverage_gain(self):
""",


# There shall not be two components providing the same feature in a
# given stack (See Issue 75)
"""
CInstance.forall(ci1,
ci1.definition.provide_features.forall(f1,
Not(
ci1.stack.exists(ci2,
ci2.definition.provide_features.exists(f2, f2 == f1)))))
""",


# All partner shall connect to an endpoint that provides the requested
# service
"""
Expand Down
27 changes: 27 additions & 0 deletions tests/generate/test_configuration_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,33 @@ def test_stack_with_side_by_side_components(self):
self.assert_configuration_count_is(2)


# See Issue 75
def test_stack_with_side_by_side_components_and_choice(self):
self.prepare_sample(
"components:\n"
" app:\n"
" provides_services: [ Awesome ]\n"
" requires_features: [ Python, HttpProxy ]\n"
" apache:\n"
" provides_features: [ HttpProxy ]\n"
" requires_features: [ Linux ]\n"
" nginx:\n"
" provides_features: [ HttpProxy ]\n"
" requires_features: [ Linux ]\n"
" django:\n"
" provides_features: [ Python ]\n"
" requires_features: [ Linux ]\n"
" ubuntu:\n"
" provides_features: [ Linux ]\n"
"\n"
"goals:\n"
" running:\n"
" - Awesome\n")

self.invoke_camp_generate()

self.assert_configuration_count_is(4)


def test_orchestrations(self):
self.prepare_sample(
Expand Down

0 comments on commit 161f424

Please sign in to comment.