- 
                Notifications
    
You must be signed in to change notification settings  - Fork 179
 
migration: Add case testing the abort operation #6619
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
      
      
            cliping
  wants to merge
  1
  commit into
  autotest:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
cliping:abort
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +136
        
        
          −0
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
        
          
          
            52 changes: 52 additions & 0 deletions
          
          52 
        
  libvirt/tests/cfg/migration/async_job/abort_before_qemu_layer_mig_start.cfg
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| - migration.async_job.abort_before_qemu_layer_mig_start: | ||
| type = abort_before_qemu_layer_mig_start | ||
| migration_setup = 'yes' | ||
| storage_type = 'nfs' | ||
| setup_local_nfs = 'yes' | ||
| disk_type = "file" | ||
| disk_source_protocol = "netfs" | ||
| mnt_path_name = ${nfs_mount_dir} | ||
| # Console output can only be monitored via virsh console output | ||
| only_pty = True | ||
| take_regular_screendumps = no | ||
| # Extra options to pass after <domain> <desturi> | ||
| virsh_migrate_extra = '' | ||
| # SSH connection time out | ||
| ssh_timeout = 60 | ||
| # Local URI | ||
| virsh_migrate_connect_uri = 'qemu:///system' | ||
| virsh_migrate_dest_state = "running" | ||
| virsh_migrate_src_state = "shut off" | ||
| image_convert = 'no' | ||
| server_ip = "${migrate_dest_host}" | ||
| server_user = "root" | ||
| server_pwd = "${migrate_dest_pwd}" | ||
| status_error = "yes" | ||
| check_network_accessibility_after_mig = "yes" | ||
| migrate_speed = "15" | ||
| err_msg = "error: operation aborted: migration out: canceled by client" | ||
| migrate_again_status_error = "no" | ||
| start_vm = "yes" | ||
| variants: | ||
| - p2p: | ||
| virsh_migrate_options = '--live --p2p --verbose' | ||
| variants: | ||
| - with_precopy: | ||
| variants: | ||
| - tcp: | ||
| migrate_desturi_port = "16509" | ||
| migrate_desturi_type = "tcp" | ||
| virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" | ||
| - unix: | ||
| transport_type = "unix_proxy" | ||
| service_to_check = "" | ||
| migrateuri_socket_path = "/var/lib/libvirt/qemu/migrateuri-socket" | ||
| desturi_socket_path = "/tmp/desturi-socket" | ||
| migrate_desturi_type = "unix_proxy" | ||
| virsh_migrate_desturi = "qemu+unix:///system?socket=${desturi_socket_path}" | ||
| migrateuri_port = "33334" | ||
| port_to_check = "${migrateuri_port}" | ||
| virsh_migrate_migrateuri = "unix://${migrateuri_socket_path}" | ||
| virsh_migrate_extra = "--migrateuri ${virsh_migrate_migrateuri}" | ||
| variants abort_mig: | ||
| - domjobabort: | 
        
          
          
            84 changes: 84 additions & 0 deletions
          
          84 
        
  libvirt/tests/src/migration/async_job/abort_before_qemu_layer_mig_start.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # | ||
| # Copyright Redhat | ||
| # | ||
| # SPDX-License-Identifier: GPL-2.0 | ||
| # | ||
| # Author: Liping Cheng <[email protected]> | ||
| # | ||
| # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 
     | 
||
| import queue | ||
| import threading | ||
| import time | ||
| 
     | 
||
| from virttest import remote | ||
| from virttest import virsh | ||
| from virttest.utils_test import libvirt | ||
| 
     | 
||
| from provider.migration import base_steps | ||
| 
     | 
||
| msg_queue = queue.Queue() | ||
| 
     | 
||
| 
     | 
||
| def run_migration(vm_name, dest_uri, option, extra): | ||
| """ | ||
| Run migration | ||
| :param vm_name: VM name | ||
| :param dest_uri: virsh uri | ||
| :param option: virsh migrate option parameters | ||
| :param extra: virsh migrate extra parameters | ||
| """ | ||
| ret = virsh.migrate(vm_name, dest_uri, option, extra, ignore_status=True, debug=True) | ||
| msg_queue.put(ret) | ||
| 
     | 
||
| 
     | 
||
| def run(test, params, env): | ||
| """ | ||
| Abort migration job before qemu layer migration starts, then migrate vm | ||
| again. | ||
| """ | ||
| def setup_test(): | ||
| """ | ||
| Setup steps | ||
| """ | ||
| test.log.info("Setup steps.") | ||
| migration_obj.setup_connection() | ||
| remote.run_remote_cmd("pkill -19 virtqemud", params) | ||
| 
     | 
||
| def run_test(): | ||
| """ | ||
| Run test | ||
| """ | ||
| dest_uri = params.get("virsh_migrate_desturi") | ||
| option = params.get("virsh_migrate_options", "--live --verbose") | ||
| extra = params.get("virsh_migrate_extra") | ||
| err_msg = params.get("err_msg") | ||
| 
     | 
||
| mig_t = threading.Thread(target=run_migration, args=(vm_name, dest_uri, option, extra)) | ||
| mig_t.start() | ||
| time.sleep(3) | ||
| 
     | 
||
| virsh.domjobabort(vm_name, debug=True) | ||
| remote.run_remote_cmd("pkill -18 virtqemud", params) | ||
| mig_t.join() | ||
| 
     | 
||
| output = msg_queue.get() | ||
| libvirt.check_result(output, err_msg) | ||
| 
     | 
||
| 
         
      Comment on lines
    
      +67
     to 
      +72
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid hangs: add timeouts to join() and queue.get(). Ensure the test fails fast instead of blocking indefinitely. Apply: -        remote.run_remote_cmd("pkill -18 virtqemud", params)
-        mig_t.join()
-
-        output = msg_queue.get()
+        migrate_vm.run_remote_cmd(
+            "pkill -18 virtqemud",
+            params.get("server_ip"),
+            params.get("server_user"),
+            params.get("server_pwd"),
+        )
+        mig_t.join(timeout=int(params.get("ssh_timeout", 60)))
+        if mig_t.is_alive():
+            test.error("Migration thread did not exit in time after abort")
+        try:
+            output = msg_queue.get(timeout=int(params.get("ssh_timeout", 60)))
+        except queue.Empty:
+            test.error("No migrate result retrieved from worker thread")
         libvirt.check_result(output, err_msg)
 🤖 Prompt for AI Agents | 
||
| vm_name = params.get("migrate_main_vm") | ||
| 
     | 
||
| vm = env.get_vm(vm_name) | ||
| migration_obj = base_steps.MigrationBase(test, vm, params) | ||
| 
     | 
||
| try: | ||
| setup_test() | ||
| run_test() | ||
| migration_obj.run_migration_again() | ||
| migration_obj.verify_default() | ||
| finally: | ||
| migration_obj.cleanup_connection() | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong remote command helper/signature. Use migrate_vm.run_remote_cmd with server creds.
remote.run_remote_cmd(params) is not the exported helper; call migrate_vm.run_remote_cmd(command, server_ip, server_user, server_pwd).
Apply:
Note: Keep the new import; repeat the same change for the resume step below.
🤖 Prompt for AI Agents