Skip to content

Commit

Permalink
Merge pull request #128 from mindwm/feat/mindwm_clipboard
Browse files Browse the repository at this point in the history
feat: add clipboard function to context crd
  • Loading branch information
metacoma authored Oct 8, 2024
2 parents e6fb57c + e8a965d commit a3346f5
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 3 deletions.
7 changes: 6 additions & 1 deletion config_schema.k
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ schema MindwmContext:
}
kafka_cdc: KnativeFunction {
name.data = "kafka-cdc"
image = "ghcr.io/mindwm/knfunc-kafka-cdc:1.0.1"
image = "ghcr.io/mindwm/knfunc-kafka-cdc:1.0.3"
}
pong: KnativeFunction {
name.data = "pong"
image = "ghcr.io/mindwm/knfunc-pong:latest"
}

clipboard: KnativeFunction {
name.data = "clipboard"
image = "ghcr.io/mindwm/knfunc-clipboard:master"
}

schema KafkaTopic:
name: ResourceNameStr

Expand Down
2 changes: 1 addition & 1 deletion flux.k
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace = "flux-system"
argo_flux_oci_repo_name = "flux"
chart_version = "2.3.0"
chart_version = "2.4.0"
73 changes: 72 additions & 1 deletion mindwm_crossplane/xrd_kcl_function.k
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ kind: InMemoryChannel
image = ctx.kafka_cdc.image
env = [
{
name = "NEO4J_URL"
name = "NEO4J_URI"
value = "bolt://" + getData(ctx.name) + "-" + getData(ctx.neo4j.name) + "-neo4j:" + str(ctx.neo4j.port)
}
{
Expand Down Expand Up @@ -554,6 +554,77 @@ kind: InMemoryChannel
}
}

crossplane_kubernetes.Object {
metadata.name = crossplaneResourceName(ctx, ctx.clipboard.name)
spec.forProvider.manifest = knative_service.Service {
metadata = {
name = getData(ctx.clipboard.name)
namespace = getData(ctx.namespace)
}
spec.template.spec.containers = [{
image = ctx.clipboard.image
env = [
{
name = "NEO4J_URI"
value = "bolt://" + getData(ctx.name) + "-" + getData(ctx.neo4j.name) + "-neo4j:" + str(ctx.neo4j.port)
}
{
name = "NEO4J_USERNAME"
value = ctx.neo4j.username
}
{
name = "NEO4J_PASSWORD"
value = ctx.neo4j.password
}
{
name = "CONTEXT_NAME"
value = getData(ctx.name)
}
{
name = "OTEL_EXPORTER_OTLP_ENDPOINT"
value = "http://${config.monitoring.otel_collector.release_name}-opentelemetry-collector.${config.monitoring.namespace}:4317"
}
{
name = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
value = "http://${config.monitoring.tempo.release_name}.${config.monitoring.namespace}:4317/v1/traces"
}
]
}]
}
}
#clipboard trigger
crossplane_kubernetes.Object {
metadata.name = crossplaneResourceName(ctx, ctx.clipboard.name) + "-trigger"
spec.forProvider.manifest = {
apiVersion = "eventing.knative.dev/v1"
kind = "Trigger"
metadata = {
name = getData(ctx.clipboard.name) + "-trigger"
namespace = getData(ctx.namespace)
}
spec = {
broker = getData(ctx.broker.name)
delivery.deadLetterSink.ref = {
apiVersion = "serving.knative.dev/v1"
kind = "Service"
name = getData(ctx.broker.deadLetter.name)
}
filters = [{
"all" = [
{
exact.type = "org.mindwm.v1.clipboard"
}
]
}]
subscriber.ref = {
apiVersion = "serving.knative.dev/v1"
kind = "Service"
name = getData(ctx.clipboard.name)
}
}
}
}

crossplane_kubernetes.Object {
metadata.name = crossplaneResourceName(ctx, ctx.gateway.name)
spec.forProvider.manifest = istio_gateway.Gateway {
Expand Down
126 changes: 126 additions & 0 deletions tests/mindwm_bdd/features/9_mindwm_clipboard.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
@mindwm_clipboard
@mindwm_test
Feature: MindWM clipboard EDA test
Background:
Given A MindWM environment
Then all nodes in Kubernetes are ready

Scenario: Prepare environment for ping tests
When God creates a MindWM context with the name "<context>"
Then the context should be ready and operable
And the following knative services are in a ready state in the "context-<context>" namespace
| Knative service name |
| clipboard |
And statefulset "<context>-neo4j" in namespace "context-<context>" is in ready state

When God creates a MindWM user resource with the name "<username>" and connects it to the context "<context>"
Then the user resource should be ready and operable

When God creates a MindWM host resource with the name "<host>" and connects it to the user "<username>"
Then the host resource should be ready and operable
And NatsJetStreamChannel "<host>-host-broker-kne-trigger" is ready in "user-<username>" namespace

When God starts reading message from NATS topic ">"

Examples:
| context | username | host |
| philadelphia | flukeman | the-host |

Scenario: Send clipboard to knative ping service
When God creates a new cloudevent
And sets cloudevent header "ce-subject" to "clipboard"
And sets cloudevent header "ce-type" to "org.mindwm.v1.clipboard"
And sets cloudevent header "ce-source" to "org.mindwm.<username>.<host>.clipboard"
And sets cloudevent header "traceparent" to "<traceparent>"
And sends cloudevent to knative service "clipboard" in "context-<context>" namespace
"""
{
"uuid": "6ca8a133-aba6-4f7f-ab95-242802fcac2c",
"time": 1728325473,
"data": "clipboard primary data"
}
"""
Then the response http code should be "200"

Then the following deployments are in a ready state in the "context-<context>" namespace
| Deployment name |
| clipboard-00001-deployment |

Examples:
| context | username | host | traceparent |
| philadelphia | flukeman | the-host | 00-6ef92f3577b34da6a3ce929d0e0e4734-00f067aa0ba902b7-00 |

Scenario: Send ping directly to function <endpoint>
When God creates a new cloudevent
And God starts reading message from NATS topic ">"
And sets cloudevent header "ce-subject" to "clipboard"
And sets cloudevent header "ce-type" to "org.mindwm.v1.clipboard"
And sets cloudevent header "ce-source" to "org.mindwm.<username>.<host>.clipboard"
And sets cloudevent header "traceparent" to "<traceparent>"
And sends cloudevent to "<endpoint>"
"""
{
"uuid": "4bca8a133-aba6-4f7f-ab95-242802fcac2c",
"time": 1728325474,
"data": "clipboard secondary data"
}
"""
Then the response http code should be "202"

Then the following deployments are in a ready state in the "context-<context>" namespace
| Deployment name |
| clipboard-00001-deployment |
Then the trace with "<traceparent>" should appear in TraceQL
And the trace should contains
| service name |
| broker-ingress.knative-eventing |
| unknown_service |
| jetstream-ch-dispatcher |
And a cloudevent with type == "org.mindwm.v1.graph.created" should have been received from the NATS topic "user-<username>.<host>-host-broker-kne-trigger._knative"

Examples:
| context | username | host | endpoint | traceparent |
| philadelphia | flukeman | the-host | broker-ingress.knative-eventing/context-philadelphia/context-broker | 00-5df92f3577b34da6a3ce929d0e0e4734-00f067aa0ba902b7-00 |
| philadelphia | flukeman | the-host | broker-ingress.knative-eventing/user-flukeman/user-broker | 00-6df93f3577b34da6a3ce929d0e0e4742-00f067aa0ba902b7-00 |


Scenario: Send ping via nats
When God creates a new cloudevent
And sets cloudevent header "ce-id" to "<uuid>"
And sets cloudevent header "ce-subject" to "clipboard"
And sets cloudevent header "ce-type" to "org.mindwm.v1.clipboard"
And sets cloudevent header "ce-source" to "org.mindwm.<username>.<host>.clipboard"
And sets cloudevent header "traceparent" to "<traceparent>"
And sends cloudevent to nats topic "org.mindwm.<username>.<host>.clipboard"
"""
{
"uuid": "3bca8a133-aba6-4f7f-ab95-242802fcac3c",
"time": 1728325474,
"data": "clipboard #3 data"
}
"""

Then the following deployments are in a ready state in the "context-<context>" namespace
| Deployment name |
| clipboard-00001-deployment |

And a cloudevent with type == "org.mindwm.v1.graph.created" should have been received from the NATS topic "user-<username>.<host>-host-broker-kne-trigger._knative"


Examples:
| context | username | host | uuid | traceparent |
| philadelphia | flukeman | the-host | 09fb195c-c419-6d62-15e0-51b6ee990922 | 00-8af92f3577b34da6a3ce929d0e0e4742-00f067aa0ba902b7-00 |


Scenario: Cleanup <username>@<host> in <context>
When God deletes the MindWM host resource "<host>"
Then the host "<host>" should be deleted

When God deletes the MindWM user resource "<username>"

When God deletes the MindWM context resource "<context>"

Examples:
| context | username | host |
| philadelphia | flukeman | the-host |

0 comments on commit a3346f5

Please sign in to comment.