feat(chaos): implement Tier 2 Integration Chaos for Memory, Networking, and LLM Gateway
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
(is (search ".config/opencortex" (namestring dir)))))
|
||||
(if orig-env
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env)
|
||||
(unsetenv "OC_CONFIG_DIR")))))
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") nil)))))
|
||||
|
||||
(test test-get-oc-config-dir-env-override
|
||||
"Verify get-oc-config-dir uses OC_CONFIG_DIR when set."
|
||||
@@ -36,7 +36,7 @@
|
||||
(is (string= "/tmp/test-opencortex-config/" (namestring dir)))))
|
||||
(if orig-env
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env)
|
||||
(unsetenv "OC_CONFIG_DIR")))))
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") nil)))))
|
||||
|
||||
(test test-save-providers-roundtrip
|
||||
"Verify save-providers writes and providers can be reloaded."
|
||||
@@ -54,7 +54,7 @@
|
||||
(uiop:delete-directory-tree (uiop:ensure-directory-pathname test-dir) :validate t)
|
||||
(if orig-env
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") orig-env)
|
||||
(unsetenv "OC_CONFIG_DIR")))))
|
||||
(setf (uiop:getenv "OC_CONFIG_DIR") nil)))))
|
||||
|
||||
(test test-configure-provider-validation
|
||||
"Verify configure-provider validates required fields."
|
||||
|
||||
17
tests/llm-gateway-tests.lisp
Normal file
17
tests/llm-gateway-tests.lisp
Normal file
@@ -0,0 +1,17 @@
|
||||
(defpackage :opencortex-llm-gateway-tests
|
||||
(:use :cl :fiveam :opencortex)
|
||||
(:export #:llm-gateway-suite))
|
||||
|
||||
(in-package :opencortex-llm-gateway-tests)
|
||||
|
||||
(def-suite llm-gateway-suite :description "Tests for the LLM Gateway skill")
|
||||
(in-suite llm-gateway-suite)
|
||||
|
||||
(test test-llm-gateway-timeout
|
||||
"Tier 2 Chaos: Verify that LLM Gateway handles connection failures gracefully."
|
||||
;; Point to a non-existent port to force a connection error
|
||||
(let ((uiop:*environment* (copy-list uiop:*environment*)))
|
||||
(setf (uiop:getenv "OLLAMA_HOST") "localhost:1")
|
||||
(let ((result (opencortex::execute-llm-request :prompt "hello" :provider :ollama)))
|
||||
(is (eq (getf result :status) :error))
|
||||
(is (uiop:string-prefix-p "Ollama Failure" (getf result :message))))))
|
||||
@@ -49,3 +49,29 @@
|
||||
(is (equal (org-object-hash (lookup-object "cow-node")) hash-v2))
|
||||
(rollback-memory 0)
|
||||
(is (equal (org-object-hash (lookup-object "cow-node")) hash-v1)))))
|
||||
|
||||
(test test-merkle-corruption-rollback
|
||||
"Tier 2 Chaos: Verify that Merkle hash corruption triggers a Micro-Rollback."
|
||||
(clrhash *memory*)
|
||||
(setf *object-store-snapshots* nil)
|
||||
(let* ((ast '(:type :HEADLINE :properties (:ID "node-1" :TITLE "Original") :contents nil))
|
||||
(id (ingest-ast ast)))
|
||||
(snapshot-memory)
|
||||
;; Manually corrupt the hash in the live memory
|
||||
(let ((obj (lookup-object id)))
|
||||
(setf (org-object-hash obj) "CORRUPTED-HASH"))
|
||||
|
||||
;; Simulate a system integrity check that should fail and rollback
|
||||
;; We'll use a manual check here since automatic validation is in the Loop
|
||||
(let ((obj (lookup-object id)))
|
||||
(let ((current-hash (org-object-hash obj))
|
||||
(computed-hash (compute-merkle-hash (org-object-id obj)
|
||||
(org-object-type obj)
|
||||
(org-object-attributes obj)
|
||||
(org-object-content obj)
|
||||
nil)))
|
||||
(unless (string= current-hash computed-hash)
|
||||
(rollback-memory 0))))
|
||||
|
||||
;; Verify that the memory was rolled back to the clean snapshot
|
||||
(is (string/= "CORRUPTED-HASH" (org-object-hash (lookup-object id))))))
|
||||
|
||||
@@ -8,7 +8,13 @@
|
||||
|
||||
(in-suite tui-suite)
|
||||
|
||||
(test test-command-parser
|
||||
"Verify that slash-commands are correctly identified."
|
||||
;; Stub for now
|
||||
(is (null nil)))
|
||||
(test test-tui-connection-drop
|
||||
"Tier 2 Chaos: Verify that handle-return degrades gracefully when the daemon connection is lost."
|
||||
(let ((opencortex.tui::*chat-history* nil)
|
||||
(opencortex.tui::*input-buffer* (make-array 5 :element-type 'char :initial-contents "hello" :fill-pointer 5 :adjustable t))
|
||||
;; Create a closed stream to simulate connection drop
|
||||
(mock-stream (make-string-output-stream)))
|
||||
(close mock-stream)
|
||||
(opencortex.tui::handle-return mock-stream)
|
||||
;; Check if the error was enqueued to history instead of crashing
|
||||
(is (member "ERROR: Connection to daemon lost." opencortex.tui::*chat-history* :test #'string=))))
|
||||
|
||||
Reference in New Issue
Block a user