lang::test::execute_upgrade (private)
lang::test::execute_upgrade -locale locale
Defined in packages/acs-lang/tcl/test/acs-lang-test-procs.tcl
Executes the logic of the upgrade test case for a certain locale.
- Switches:
- -locale (required)
- Author:
- Peter Marklund
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- upgrade
Source code: set package_key [lang::test::test_package_key] # The key numbers correspond to the 14 cases described in the API-doc for lang::catalog::upgrade array set base_messages { key01 "Key 1" key04 "Key 4" key05 "Key 5" key06 "Key 6" key07 "Key 7" key10 "Key 10" key11 "Key 11" key12 "Key 12" key13 "Key 13 differ" key14 "Key 14 base" } array set db_messages { key02 "Key 2" key06 "Key 6 differ" key07 "Key 7" key08 "Key 8" key09 "Key 9" key10 "Key 10" key11 "Key 11 differ" key12 "Key 12" key13 "Key 13" key14 "Key 14 db" } array set file_messages { key03 "Key 3" key04 "Key 4 differ" key05 "Key 5" key08 "Key 8 differ" key09 "Key 9" key10 "Key 10" key11 "Key 11" key12 "Key 12 differ" key13 "Key 13" key14 "Key 14 file" } # Add the locale to each message so we can tell messages in # different locales apart foreach array_name {base_messages db_messages file_messages} { foreach message_key [array names $array_name] { append ${array_name}($message_key) " $locale" } } array set upgrade_expect { key01 { message base deleted_p t conflict_p f sync_time not_null upgrade_status no_upgrade } key02 { message db deleted_p f conflict_p f sync_time null upgrade_status no_upgrade } key03 { message file deleted_p f conflict_p f sync_time not_null upgrade_status added } key04 { message file deleted_p f conflict_p t sync_time not_null upgrade_status added } key05 { message base deleted_p t conflict_p f sync_time null upgrade_status no_upgrade } key06 { message db deleted_p t conflict_p t sync_time not_null upgrade_status deleted } key07 { message db deleted_p t conflict_p f sync_time not_null upgrade_status deleted } key08 { message file deleted_p f conflict_p t sync_time not_null upgrade_status updated } key09 { message db deleted_p f conflict_p f sync_time not_null upgrade_status no_upgrade } key10 { message db deleted_p f conflict_p f sync_time not_null upgrade_status added } key11 { message db deleted_p f conflict_p f sync_time null upgrade_status no_upgrade } key12 { message file deleted_p f conflict_p f sync_time not_null upgrade_status updated } key13 { message db deleted_p f conflict_p f sync_time not_null upgrade_status no_upgrade } key14 { message file deleted_p f conflict_p t sync_time not_null upgrade_status updated } } # # Execution plan: # # 1. Import some messages (base_messages below) # 2. Make changes to DB (db_messages below) # 3. Make changes to catalog files and import again (file_messages below) # 4. Check that merged result is what we expect (upgrade_expect below) # 5. Import again # 6. Check that we still have the same result (verify idempotent) # 7. Resolve some conflicts, but not all # 8. Import again # 9. Check that we have what's expected then # aa_log "-------------------------------------------------------------------" aa_log "*** Executing upgrade test with locale $locale" aa_log "-------------------------------------------------------------------" #---------------------------------------------------------------------- # 1. Import some messages (base_messages) #---------------------------------------------------------------------- aa_log "locale=$locale ----------1. import some messages----------" # Write original catalog file set catalog_file_path [lang::catalog::get_catalog_file_path -package_key $package_key -locale $locale] lang::catalog::export_to_file $catalog_file_path [array get base_messages] aa_true "Initial export: messages exported to file $catalog_file_path" [file exists $catalog_file_path] aa_log [template::util::read_file $catalog_file_path] # Import the catalog file aa_silence_log_entries -severities {error} { set message_count [lang::catalog::import -package_key $package_key -locales [list $locale]] } aa_log "Imported messages: $message_count" # Check that we have the expected messages in the database set actual_db_messages [lang::catalog::messages_in_db -package_key $package_key -locale $locale] foreach message_key [lsort [array names base_messages]] { aa_equals "Initial import: message for key $message_key in db same as in file" [dict get $actual_db_messages $message_key] $base_messages($message_key) } #---------------------------------------------------------------------- # 2. Make changes to DB (db_messages) #---------------------------------------------------------------------- aa_log "locale=$locale ----------2. Make changes to DB----------" # Carry out changes to the message catalog in the db foreach message_key [lsort [array names upgrade_expect]] { set register_p 0 if { ![info exists db_messages($message_key)] } { # Message is not supposed to exist in DB if { [info exists base_messages($message_key)] } { # Message currently does exist in DB: Delete aa_log "Deleting message $message_key" lang::message::delete -package_key $package_key -message_key $message_key -locale $locale # Test undelete after deleting for the first time aa_log "Undeleting message $message_key" lang::message::undelete -package_key $package_key -message_key $message_key -locale $locale # Delete the message again aa_log "Deleting message $message_key definitively" lang::message::delete -package_key $package_key -message_key $message_key -locale $locale } } else { # Message is supposed to exist in DB # Is it new or changed? if { ![info exists base_messages($message_key)] || $base_messages($message_key) ne $db_messages($message_key) } { # Added || updated aa_log "Adding/updating message $message_key" lang::message::register $locale $package_key $message_key $db_messages($message_key) } } } #---------------------------------------------------------------------- # 3. Make changes to catalog files and import again (file_messages) #---------------------------------------------------------------------- aa_log "locale=$locale ----------3. Make changes to catalog files and do first upgrade----------" # Update the catalog file file delete -force -- $catalog_file_path lang::catalog::export_to_file $catalog_file_path [array get file_messages] aa_true "First upgrade: catalog file $catalog_file_path updated" [file exists $catalog_file_path] # Execute a first upgrade lang::catalog::import -package_key $package_key -locales [list $locale] #---------------------------------------------------------------------- # 4. Check that merged result is what we expect (upgrade_expect) #---------------------------------------------------------------------- aa_log "locale=$locale ----------4. Check merge result of first upgrade----------" lang::test::check_import_result -package_key $package_key -locale $locale -upgrade_array upgrade_expect -base_array base_messages -db_array db_messages -file_array file_messages #---------------------------------------------------------------------- # 5. First upgrade (second import) #---------------------------------------------------------------------- aa_log "locale=$locale ----------5. Second upgrade ----------" lang::catalog::import -package_key $package_key -locales [list $locale] #---------------------------------------------------------------------- # 6. Check that we still have the same result (verify idempotent) #---------------------------------------------------------------------- aa_log "locale=$locale ----------6. Check merge results of second upgrade (verify idempotent)----------" lang::test::check_import_result -package_key $package_key -locale $locale -upgrade_array upgrade_expect -base_array base_messages -db_array db_messages -file_array file_messages #---------------------------------------------------------------------- # 7. Resolve some conflicts, but not all #---------------------------------------------------------------------- aa_log "locale=$locale ----------7. Resolve some conflicts, but not all----------" array set conflict_resolutions { key06 "key06 resolution message" key08 "accept" } foreach message_key [array names conflict_resolutions] { if {$conflict_resolutions($message_key) eq "accept"} { # Resolution is an accept - just toggle conflict_p flag lang::message::edit $package_key $message_key $locale [list conflict_p f] # Set the message to be what's in the database (the accepted message) set conflict_resolutions($message_key) [lang::message::get_element -package_key $package_key -message_key $message_key -locale $locale -element message] } else { # Resolution is an edit lang::message::register $locale $package_key $message_key $conflict_resolutions($message_key) } } # TODO: test resolution being to retain the message (just toggle conflict_p) # TODO: test resolution being to delete a resurrected message # TODO: test other resolution possibilities #---------------------------------------------------------------------- # 8. Third upgrade #---------------------------------------------------------------------- aa_log "locale=$locale ----------8. Do third upgrade----------" lang::catalog::import -package_key $package_key -locales [list $locale] #---------------------------------------------------------------------- # 9. Check that we have what's expected then (resolutions are sticky) #---------------------------------------------------------------------- aa_log "locale=$locale ----------9. Check results of third upgrade (that resolutions are sticky)----------" foreach message_key [array names conflict_resolutions] { unset -nocomplain message_array lang::message::get -package_key $package_key -message_key $message_key -locale $locale -array message_array aa_equals "$message_key - conflict message that has been resolved in UI has conflict_p=f" $message_array(conflict_p) "f" aa_equals "$message_key - the resolved conflict is not clobbered by an additional import" $message_array(message) $conflict_resolutions($message_key) }XQL Not present: Generic, PostgreSQL, Oracle