Skip to content

Feat/integration test mindmap terminal #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ mindwm_test:
python3 -m venv .venv && \
source .venv/bin/activate && \
pip3 install -r ./requirements.txt && \
pytest -s -x -m mindwm_test --no-header --junit-xml=$(ARTIFACT_DIR)/report.xml --disable-warnings -vv --gherkin-terminal-reporter --kube-config=$${HOME}/.kube/config --alluredir=$(ARTIFACT_DIR)/allure-results . | tee $(ARTIFACT_DIR)/report.md
pytest -s -x -m 'mindwm_lifecycle or mindmap_terminal' --no-header --junit-xml=$(ARTIFACT_DIR)/report.xml --disable-warnings -vv --gherkin-terminal-reporter --kube-config=$${HOME}/.kube/config --alluredir=$(ARTIFACT_DIR)/allure-results . | tee $(ARTIFACT_DIR)/report.md
exit_code=$${PIPESTATUS[0]}
echo $${exit_code} > $(ARTIFACT_DIR)/exit_code
xmlstarlet sel -t -m "//testcase[failure]" -v "concat(@classname,' ', @name)" -n $(ARTIFACT_DIR)/report.xml | tee $(ARTIFACT_DIR)/failed_test_title
Expand Down
2 changes: 1 addition & 1 deletion config_schema.k
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ schema MindwmContext:
}
kafka_cdc: KnativeFunction {
name.data = "kafka-cdc"
image = "ghcr.io/mindwm/knfunc-kafka-cdc:1.0.4"
image = "ghcr.io/mindwm/knfunc-kafka-cdc:1.0.6"
}
pong: KnativeFunction {
name.data = "pong"
Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/cloud-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ packages:
- tmux
- ripgrep
- xmlstarlet
# for mindmap-terminal tests
- wmctrl
- xdotool
- fvwm3
- xvfb
- wget
- openjdk-17-jdk
- xterm
groups:
- ci
- docker
Expand Down Expand Up @@ -44,3 +52,4 @@ runcmd:
- sysctl -w fs.inotify.max_queued_events=2099999999
- curl -Lo /usr/bin/kubectl https://dl.k8s.io/release/v1.32.0/bin/linux/amd64/kubectl
- chmod +x /usr/bin/kubectl
- update-java-alternatives --set java-1.17.0-openjdk-amd64
2 changes: 1 addition & 1 deletion tests/e2e/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ resource "linode_instance" "ci" {
inline = [
"mkdir -p ${var.artifact_dir}",
"echo 0 > ${var.artifact_dir}/exit_code",
"timeout 90 bash -c 'while :; do docker info && break; sleep 1; echo -n .; done'",
"timeout 270 bash -c 'while :; do docker info && break; sleep 1; echo -n .; done'",
# "echo dir: `basename ${var.git_repository}` checkout ${var.git_commit_sha} TARGET_REVISION=${var.git_ref_name}",
#"cd `basename ${var.git_repository}` && make mindwm_lifecycle sleep-300 mindwm_test ARTIFACT_DIR=${var.artifact_dir} TARGET_REVISION=${var.git_ref_name} || echo $? > ${var.artifact_dir}/exit_code",
#"cd ${var.artifact_dir} && tar cvf /tmp/artifacts.tar *"
Expand Down
128 changes: 128 additions & 0 deletions tests/mindwm_bdd/features/6_0_0_mindmap_terminal_freeplane.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@mindmap_terminal
@mindwm_test

Feature: Mindmap terminal integration test
Background:
Given A MindWM environment
Then all nodes in Kubernetes are ready

Scenario: Install freeplane
When God runs the command 'wget -c -O /tmp/freeplane.deb https://sourceforge.net/projects/freeplane/files/freeplane%20stable/archive/<freeplane_version>/freeplane_1.12.9~upstream-1_all.deb/download' inside the '<work_dir>' directory
When God runs the command 'sudo dpkg -i <work_dir>/freeplane.deb' inside the '<work_dir>' directory
Examples:
| freeplane_version | work_dir | display |
| 1.12.9 | /tmp/ | 42 |


Scenario: Prepare environment, context: <context>, username: <username>, host: <host>
When God creates a MindWM context with the name "<context>"
Then the context should be ready and operable

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

And the following resources of type "services.serving.knative.dev/v1" has a status "Ready" equal "True" in "context-<context>" namespace
| Knative service name |
| iocontext |

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

Examples:
| context | username | host |
| headwind | ci | localhost |

Scenario: Clone <repo>@<branch> to <clone_dir>
When God clones the repository '<repo>' with branch '<branch>' and commit '<commit>' to '<clone_dir>'
Then the directory '<clone_dir>' should exist

Examples:
| repo | branch | commit | clone_dir |
| https://github.com/mindwm/mindmap-terminal | master | HEAD | /tmp/mindmap-terminal |
| https://github.com/mindwm/mindwm-manager | master | HEAD | /tmp/mindwm-manager |

Scenario: Install, configure and run mindwm-manager
Then the directory '<work_dir>' should exist
When God runs the command 'python3.11 -m venv .venv' inside the '<work_dir>' directory
When God runs the command '.venv/bin/pip install -r requirements.txt' inside the '<work_dir>' directory
When God runs the command 'set -a && . <work_dir>/.env.sample && /<work_dir>/.venv/bin/python3.11 src/manager.py > <work_dir>/log 2>&1 &' inside the '<work_dir>' directory
Then God waits for '5' seconds
When God runs the command 'pgrep -fx "^//tmp/mindwm-manager/.venv/bin/python3.11 src/manager.py$"' inside the '<work_dir>' directory
Then file "<work_dir>/log" should not contain "Traceback \(most recent call last\):" regex
Then file "<work_dir>/log" contain "INFO:mindwm.events:Subscribed to NATS subject:.*" regex

Examples:
| work_dir |
| /tmp/mindwm-manager |

Scenario: Run xvfb server at :<display> port
When God runs the command 'nohup Xvfb :<display> -screen 0 1024x768x16 > /tmp/x 2>&1 &' inside the '<work_dir>' directory
When God runs the command 'nohup fvwm3 -d :<display> >/tmp/y 2>&1 &' inside the '<work_dir>' directory
When God runs the command 'pgrep -f ^Xvfb' inside the '<work_dir>' directory
When God runs the command 'pgrep -f ^fvwm3' inside the '<work_dir>' directory

Examples:
| display | work_dir |
| 42 | /tmp |

Scenario: Run freeplane
When God runs the command 'export DISPLAY=:<display>; make freeplane_start > <work_dir>/log 2>&1 &' inside the '<work_dir>' directory
Then God waits for '10' seconds
When God runs the command 'DISPLAY=:<display> wmctrl -l | grep Freeplane' inside the '<work_dir>' directory
Then God waits for '20' seconds
When God runs the command 'DISPLAY=:<display> wmctrl -l | grep -E "mindmap-terminal-[0-9]+-Map[0-9]+?-ID_[0-9]+"' inside the '<work_dir>' directory

Examples:
| work_dir | display |
| /tmp/mindmap-terminal | 42 |

Scenario: Run test
When God runs the command 'export DISPLAY=:<display>; xdotool search --name "freeplane" windowactivate' inside the '<work_dir>' directory
Then God waits for '3' seconds
When God runs the command 'export DISPLAY=:<display>; xdotool key Escape' inside the '<work_dir>' directory
Then God waits for '3' seconds
When God runs the command 'export DISPLAY=:<display>; xdotool type "<command>"' inside the '<work_dir>' directory
Then God waits for '3' seconds
When God runs the command 'export DISPLAY=:<display>; xdotool key Return' inside the '<work_dir>' directory
Examples:
| work_dir | display | command |
| /tmp/mindmap-terminal | 42 | uptime |
#
#
Scenario: Verification that the io-document has been delivered and processed
Then the following deployments are in a ready state in the "context-<context>" namespace
| Deployment name |
| iocontext-00001-deployment |
And container "user-container" in pod "iocontext-00001-deployment.*" in namespace "context-<context>" should contain "uptime" regex
And container "user-container" in pod "^.*-00001-deployment-.*" in namespace "context-<context>" should not contain "Traceback \(most recent call last\):" regex
And container "user-container" in pod "^dead-letter-.*" in namespace "context-<context>" should not contain "cloudevents.Event\n" regex

Examples:
| context | username | host | command |
| headwind | ci | localhost | uptime |

Scenario: Cleanup process <proc_mask>
When God runs the command 'pgrep -f "<proc_mask>" && (pkill -9 -f "<proc_mask>") || :' inside the '/tmp' directory
Examples:
| proc_mask |
| ^Xvfb |
| ^fvwm3 |
| ^xterm |
| ^//tmp/mindwm-manager/.venv/bin/python3.11 src/manager.py$ |


Scenario: Cleanup <username>@<host> in <context>
When God deletes the MindWM context resource "<context>"
And God deletes the MindWM host resource "<host>"
And God deletes the MindWM user resource "<username>"
And God runs the command 'sudo dpkg -r freeplane' inside the '/tmp' directory

Examples:
| context | username | host |
| headwind | ci | localhost |