okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Failed engine test start gives a plain cause and next step; rollback never says the same version twice; max_tokens below 1 is a 400 (TUI stress X01, #18, #15)2f5f7c113

main
3.6 KiB70 linesraw
1"""0.2.3 RC stress test: X01 (a failed engine test start gives a plain cause and one next step, not the engine's words) and #18 (the rollback text
2never says "0.1.45.3 -> 0.1.45.3")."""
3
4import json
5import unittest
6
7from strata_control import updater
8from tests.terminal import test_updater
9from tests.terminal import update_fixture as fx
10
11
12class TestStartText(unittest.TestCase):
13    RAW = "it did not answer a one-token probe (server_exited) | CUDA error: out of memory at gr.cu:123 | stack"
14
15    def test_the_engines_words_stay_out_of_the_sentence(self):
16        err = updater.TestStartFailed("0.1.48", "it did not answer a one-token probe (server_exited)")
17        text = str(err)
18        self.assertIn("did not start correctly on this computer", text)
19        self.assertIn("so it was not installed", text)
20        self.assertIn("Your current engine is unchanged", text)
21        self.assertIn("The engine started but stopped before it answered a test question.", text)
22        self.assertIn("`strata update --force`", text)
23        self.assertNotIn("server_exited", text)
24        self.assertNotIn("probe", text)
25        self.assertEqual(err.reason, "it did not answer a one-token probe (server_exited)")      # kept for the state file and the JSON
26        self.assertEqual(err.exit_code, 6)
27
28    def test_a_busy_card_says_so_and_asks_for_a_plain_retry(self):
29        err = updater.TestStartFailed("0.1.48", "CUDA error: out of memory")
30        self.assertTrue(err.busy)
31        self.assertIn("graphics card or memory looks busy", str(err))
32        self.assertNotIn("CUDA", str(err))
33        self.assertNotIn("--force", str(err))
34
35    def test_an_engine_that_would_not_run_and_a_missing_model(self):
36        self.assertIn("The engine program did not run on this computer.", str(updater.TestStartFailed("0.1.48", "--version exited 3: dll missing")))
37        self.assertNotIn("dll missing", str(updater.TestStartFailed("0.1.48", "--version exited 3: dll missing")))
38        self.assertIn("no installed model", str(updater.TestStartFailed("0.1.48", "no installed model to test with")).lower())
39
40    def test_control_is_called_control(self):
41        text = str(updater.TestStartFailed("Control 0.1.48", "--version said 'oops' (exit 7)"))
42        self.assertTrue(text.startswith("The new Control 0.1.48 did not start correctly"), text)
43        self.assertIn("Your current Control is unchanged.", text)
44        self.assertNotIn("engine", text)
45
46
47class RollbackText(test_updater.UpdaterCase):
48    def test_from_names_the_version_that_is_left(self):
49        self.install_current()
50        self.publish(("0.1.46", fx.GOOD_ENGINE))
51        updater.run_update(self.ctx(), control=False)
52        out = updater.rollback_engine(self.ctx())
53        self.assertEqual((out["from"], out["to"]), ("0.1.46", "0.1.45"))
54        self.assertNotEqual(out["from"], out["to"])
55
56    def test_a_second_rollback_says_there_is_nothing_older_instead_of_the_same_version_twice(self):
57        self.install_current()
58        self.publish(("0.1.46", fx.GOOD_ENGINE))
59        updater.run_update(self.ctx(), control=False)
60        updater.rollback_engine(self.ctx())
61        state = self.components / ".updates" / "state.json"
62        data = json.loads(state.read_text(encoding="utf-8"))
63        data["engine"]["previous"] = data["engine"]["pinned"]          # the stale state a second run can meet
64        state.write_text(json.dumps(data), encoding="utf-8")
65        with self.assertRaisesRegex(updater.UpdateError, "already the previous one .0.1.45.*strata update --force"):
66            updater.rollback_engine(self.ctx())
67
68
69if __name__ == "__main__":
70    unittest.main()