Skip to content

Commit

Permalink
Merge branch 'main' into case-3-4
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner authored Dec 25, 2024
2 parents 6cdd588 + 9a6d7d6 commit 35b0313
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/docs/variability4tosca/specification/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ The following options are used to configure constraints.
| constraints | false | Boolean | false | Enable all constraints. |
| relation_source_constraint | false | Boolean | false | Enable the constraint regarding present relation sources. |
| relation_target_constraint | false | Boolean | false | Enable the constraint regarding present relation targets. |
| relation_enhanced_implication_mode | false | Boolean | true | Enable enhanced implied relations. |
| artifact_container_constraint | false | Boolean | false | Enable the constraint regarding present container of artifacts. |
| property_container_constraint | false | Boolean | false | Enable the constraint regarding present container of properties. |
| type_container_constraint | false | Boolean | false | Enable the constraint regarding present containers of types. |
Expand Down
15 changes: 14 additions & 1 deletion src/enricher/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,21 @@ export class ConstraintEnricher {
}
assert.isDefined(left, 'Left not defined')

/**
* Element presence is implied by container presence and manual conditions
*/
const antecedent: {and: [string, string]} = {and: [element.container.id, element.manualId]}
const consequent = element.id

/**
* Enhanced implied relations also include manual conditions of target
*/
if (element.isRelation() && this.graph.options.constraints.relationEnhancedImplication) {
antecedent.and.push(element.target.manualId)
}

this.graph.addConstraint({
implies: [{and: [element.container.id, element.manualId]}, element.id],
implies: [antecedent, consequent],
})
}

Expand Down
4 changes: 4 additions & 0 deletions src/graph/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ class ConstraintsOptions extends BaseOptions {

readonly relationSource: boolean
readonly relationTarget: boolean
readonly relationEnhancedImplication: boolean
readonly artifactContainer: boolean
readonly propertyContainer: boolean
readonly typeContainer: boolean
Expand Down Expand Up @@ -860,6 +861,9 @@ class ConstraintsOptions extends BaseOptions {
this.relationTarget = this.raw.relation_target_constraint ?? this.constraints
assert.isBoolean(this.relationTarget)

this.relationEnhancedImplication = this.raw.relation_enhanced_implication_mode ?? true
assert.isBoolean(this.relationEnhancedImplication)

this.artifactContainer = this.raw.artifact_container_constraint ?? this.constraints
assert.isBoolean(this.artifactContainer)

Expand Down
1 change: 1 addition & 0 deletions src/specification/variability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type ConstraintsOptions = {
constraints?: boolean
relation_source_constraint?: boolean
relation_target_constraint?: boolean
relation_enhanced_implication_mode?: boolean
artifact_container_constraint?: boolean
property_container_constraint?: boolean
type_container_constraint?: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
presets: left
error: Could not solve
description: disabled since we support now enhanced implied relations
3 changes: 3 additions & 0 deletions tests/conformance/implications/requires---disabled/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
presets: left
error: Could not solve
description: disabled since we support now enhanced implied relations
2 changes: 0 additions & 2 deletions tests/conformance/implications/requires/test.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions tests/conformance/implied-enhanced/new/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
node_templates:
container:
type: container
38 changes: 38 additions & 0 deletions tests/conformance/implied-enhanced/new/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tosca_definitions_version: tosca_variability_1_0_rc_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
variability:
options:
enrich_implementations: false
enrich_technologies: false
relation_enhanced_implication_mode: true

node_templates:
container:
type: container
persistent: true
managed: false
requirements:
- middleware: dmiddleware

dmiddleware:
type: container
managed: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
#conditions: false

other:
type: container
managed: false
requirements:
- host: emachine
38 changes: 38 additions & 0 deletions tests/conformance/implied-enhanced/old/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tosca_definitions_version: tosca_variability_1_0_rc_3

node_types:
container:
derived_from: tosca.nodes.Root

topology_template:
variability:
options:
enrich_implementations: false
enrich_technologies: false
relation_enhanced_implication_mode: false

node_templates:
container:
type: container
persistent: true
managed: false
requirements:
- middleware: dmiddleware

dmiddleware:
type: container
managed: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
#conditions: false

other:
type: container
managed: false
requirements:
- host: emachine
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
presets: left
error: Could not solve
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
error: Could not solve
description: Only one hosting relation must be present. Hence, there is a conflict between implied relations and hosting constraints.
description: Only one hosting relation must be present. Hence, there is a conflict between implied relations and hosting constraints. Disabled since we support now enhanced implied relations.
2 changes: 2 additions & 0 deletions tests/enricher/implied/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ topology_template:
- and:
- node.worker
- [email protected]
- manual.node.left
- [email protected]
- implies:
- and:
- node.worker
- [email protected]
- manual.node.right
- [email protected]
node_templates:
- worker:
Expand Down
37 changes: 23 additions & 14 deletions tests/minisat/plays/play.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ topology_template:
options:
enrich_implementations: false
enrich_technologies: false
required_artifact_constraint: false

inputs:
some_input:
type: string

node_templates:
container:
type: container
conditions: true
properties:
hallo: fvasadfasdfsdalco
artifacts:
- apt_package:
type: tosca.artifacts.Root
file: falco
properties:
repository: falco
persistent: true
managed: false
requirements:
- middleware:
node: dmiddleware

dmiddleware:
type: container
managed: false
conditions: false
requirements:
- host: emachine

emachine:
type: container
managed: false
#conditions: false

other:
type: container
managed: false
requirements:
- host: emachine

0 comments on commit 35b0313

Please sign in to comment.