.agents/relationship-fixture-agent.md
This document describes the process to create new relationship test fixtures for the Meshery relationship evaluation integration tests.
Relationship test fixtures are JSON files that define a Meshery Design containing:
These fixtures are used by ui/tests/e2e/relationship_evaluation.spec.js to verify that the relationship evaluation API correctly identifies relationships between components.
Browse the relationship definitions in:
/server/meshmodel/kubernetes/v1.35.0-beta.0/v1.0.0/relationships/
Each file defines a relationship with:
edge or hierarchicalbinding, non-binding, or parentnetwork, reference, permission, inventory, alias, wallet, etc.from and to components with mutatorRef and mutatedRef paths| Field | Description |
|---|---|
mutatorRef | Path in the source component providing the value |
mutatedRef | Path in the target component receiving/matching the value |
Example (Secret → Deployment reference):
{
"kind": "edge",
"type": "non-binding",
"subType": "reference",
"selectors": [{
"allow": {
"from": [{ "kind": "Secret", "patch": { "mutatorRef": [["displayName"]] }}],
"to": [{ "kind": "Deployment", "patch": { "mutatedRef": [["configuration","spec","template","spec","containers","0","envFrom","0","secretRef","name"]] }}]
}
}]
}
{component1}-{component2}-{kind}-{type}-{subType}-fixture.json
Examples:
secret-deployment-edge-non-binding-reference-fixture.jsonnamespace-hierarchical-parent-inventory-fixture.jsonrole-rolebinding-serviceaccount-edge-binding-permission-fixture.jsonui/tests/e2e/fixtures/relationships/
{
"id": "<unique-uuid>",
"name": "<descriptive-fixture-name>",
"schemaVersion": "designs.meshery.io/v1beta1",
"version": "0.0.1",
"metadata": {},
"components": [
// Component definitions go here
],
"relationships": [
// Expected relationship definitions go here
]
}
{
"id": "<unique-component-uuid>",
"schemaVersion": "components.meshery.io/v1beta1",
"version": "v1.0.0",
"displayName": "<component-display-name>",
"description": "<component-description>",
"format": "JSON",
"modelReference": {
"version": "v1.0.0",
"name": "kubernetes",
"displayName": "Kubernetes",
"id": "00000000-0000-0000-0000-000000000000",
"registrant": { "kind": "github" },
"model": { "version": "v1.35.0-rc.0" }
},
"styles": {
"background-opacity": 1,
"primaryColor": "#326CE5",
"secondaryColor": "#7aa1f0",
"shape": "round-rectangle"
},
"capabilities": null,
"status": "enabled",
"metadata": {
"isAnnotation": false,
"isNamespaced": true
},
"configuration": {
// Kubernetes resource spec goes here
},
"component": {
"version": "<api-version>",
"kind": "<Kind>",
"schema": ""
}
}
Critical: The component configurations MUST satisfy the mutatorRef and mutatedRef paths defined in the relationship selector.
Relationship Definition requires:
mutatorRef: ["displayName"] on SecretmutatedRef: ["configuration","spec","template","spec","containers","0","envFrom","0","secretRef","name"] on DeploymentSecret Component:
{
"id": "44444444-4444-4444-4444-444444444444",
"displayName": "my-app-secret", // <- matches mutatorRef
"component": { "version": "v1", "kind": "Secret" },
"configuration": {
"metadata": { "name": "my-app-secret", "namespace": "default" },
"type": "Opaque",
"data": { "username": "YWRtaW4=" }
}
}
Deployment Component:
{
"id": "55555555-5555-5555-5555-555555555555",
"displayName": "my-app-deployment",
"component": { "version": "apps/v1", "kind": "Deployment" },
"configuration": {
"spec": {
"template": {
"spec": {
"containers": [{
"name": "my-app-container",
"envFrom": [{
"secretRef": {
"name": "my-app-secret" // <- matches mutatedRef, value equals displayName
}
}]
}]
}
}
}
}
}
{
"id": "<unique-relationship-uuid>",
"evaluationQuery": null,
"kind": "<edge|hierarchical>",
"metadata": {
"description": "<relationship-description>",
"styles": { "primaryColor": "", "svgColor": "", "svgWhite": "" },
"isAnnotation": false
},
"model": {
"version": "v1.0.0",
"name": "kubernetes",
"displayName": "Kubernetes",
"id": "00000000-0000-0000-0000-000000000000",
"registrant": { "kind": "github" },
"model": { "version": "v1.35.0-rc.0" }
},
"schemaVersion": "relationships.meshery.io/v1alpha3",
"selectors": [{
"allow": {
"from": [{
"id": "<from-component-id>",
"kind": "<FromKind>",
"model": { "name": "kubernetes", "registrant": { "kind": "github" }},
"patch": { "patchStrategy": "replace", "mutatorRef": [[...]] }
}],
"to": [{
"id": "<to-component-id>",
"kind": "<ToKind>",
"model": { "name": "kubernetes", "registrant": { "kind": "github" }},
"patch": { "patchStrategy": "replace", "mutatedRef": [[...]] }
}]
}
}],
"subType": "<subtype>",
"status": "pending",
"type": "<type>",
"version": ""
}
[!IMPORTANT] The
selectors.allow.from[].idandselectors.allow.to[].idMUST match the component IDs defined in your fixture.
Update ui/tests/e2e/fixtures/relationships/index.js:
import myNewFixture from './my-new-fixture.json';
export const RelationshipTestFixtures = [
// ... existing fixtures
myNewFixture
];
Update ui/tests/e2e/relationship_evaluation.spec.js to include the fixture:
const DESIGNS_TO_TEST = [
// ... existing designs
{
id: "<fixture-id>",
name: "<fixture-name>"
}
]
| Kind | Type | SubType | Example Use Case |
|---|---|---|---|
edge | non-binding | reference | ConfigMap/Secret → Pod/Deployment |
edge | non-binding | network | Service → Deployment (label selector) |
edge | binding | permission | Role → RoleBinding → ServiceAccount |
edge | binding | mount | PV → PVC mount |
hierarchical | parent | inventory | Namespace → namespaced resources |
hierarchical | parent | alias | Container alias within Deployment |
hierarchical | parent | wallet | EndpointSlice → Service |
displayName values match where mutatorRef references ["displayName"]mutatedRef paths exactlystatus is set to "pending" or "approved"jq . to validate)index.jsDESIGNS_TO_TEST in the spec file// turbo
cd ui && npx playwright test relationship_evaluation.spec.js --grep "@relationship"
This will test all relationship fixtures and report which relationships were correctly identified by the evaluation API.