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