RosiKyu commented on PR #12296:
URL: https://github.com/apache/cloudstack/pull/12296#issuecomment-3744099333

   **WIP**
   
   ## Test Case 1: Same-Zone Template Copy
   
   **Objective:** Verify templates are copied from existing secondary storage 
when adding a new secondary storage in the same zone (toggle ON).
   
   **Environment:**
   - Zone: ref-trl-10584-k-Mol9-rositsa-kyuchukova
   - 1 existing secondary storage (sec1) with 2 templates (SystemVM + CentOS)
   
   **Steps:**
   1. Created empty NFS directory for sec2
   2. Added secondary storage via UI with "Copy templates from other storages" 
toggle ON
   3. Monitored management server logs
   4. Verified templates on new storage
   
   **Status:** PASSED
   
   **Test Results:**
   
   | Verification | Result |
   |--------------|--------|
   | UI toggle visible | Yes |
   | UI toggle default ON | Yes |
   | API parameter sent | 
`details[0].key=copytemplatesfromothersecondarystorages&details[0].value=true` |
   | Templates copied (not downloaded) | Logs show `CopyCommand` not 
`DownloadCommand` |
   | Both templates on sec2 | SystemVM + CentOS both DOWNLOADED |
   | Files on NFS | `/template/tmpl/1/3` and `/template/tmpl/1/4` present |
   
   **Test Evidence:**
   
   #### UI toggle visible and ON by default:
   
   <img width="1660" height="1513" alt="image" 
src="https://github.com/user-attachments/assets/0aebab69-47b6-415d-b5bb-8f9c1acd3190";
 />
   
   #### API parameter sent 
   ```
   2026-01-13 06:30:48,192 DEBUG [c.c.a.ApiServlet] 
(qtp2038105753-20:[ctx-d2717ae0, ctx-9adb537a]) (logid:2395605d) ===END===  
10.0.3.251 -- GET  
name=sec2&url=nfs:%2F%2F10.0.32.4%2Facs%2Fsecondary%2Fref-trl-10584-k-Mol9-rositsa-kyuchukova%2Fref-trl-10584-k-Mol9-rositsa-kyuchukova-sec2&provider=NFS&zoneid=4afe198a-1f07-4535-91bf-b5708a58d8e7&details[0].key=copytemplatesfromothersecondarystorages&details[0].value=true&command=addImageStore&response=json&sessionkey=JJGuk2ta3w60x46GMEpEPRAitqM
   ```
   
   #### Templates copied (not downloaded)
   ```
   2026-01-13 06:30:48,329 DEBUG [o.a.c.s.i.TemplateServiceImpl] 
(pool-508-thread-1:[]) (logid:2395605d) Copying template [centos55-x86_64] from 
image store 
[NFS://10.0.32.4/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec1]
 to [sec2].
   
   2026-01-13 06:30:48,464 DEBUG [o.a.c.s.i.TemplateServiceImpl] 
(pool-508-thread-2:[]) (logid:2395605d) Copying template [routing-3] from image 
store 
[NFS://10.0.32.4/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec1]
 to [sec2].
   
   2026-01-13 06:30:59,716 INFO  [o.a.c.s.i.TemplateServiceImpl] 
(pool-508-thread-2:[]) (logid:2395605d) Copied template [routing-3] to image 
store [sec2].
   ```
   
   #### Both templates on sec2:
   
   ````
   # BEFORE copy:
   [root@sl-nestednfs ~]# ls -la 
/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec2/
   total 0
   drwxrwxrwx. 2 root root   6 Jan 13 06:26 .
   drwxr-xr-x. 4 root root 170 Jan 13 06:26 ..
   
   # AFTER copy:
   [root@sl-nestednfs ~]# tree 
/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec2/
   
/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec2/
   ├── snapshots
   ├── template
   │   └── tmpl
   │       └── 1
   │           ├── 3
   │           │   ├── d99293b9-4d1e-418e-af74-ec2e0b3cd77b.qcow2
   │           │   └── template.properties
   │           └── 4
   │               ├── 0c364cce-8288-3a92-9234-4ffde372aec7.qcow2
   │               └── template.properties
   └── volumes
   
   7 directories, 4 files
   ````
   
   ## Test Case 2: Register Public Template with Cross-Zone Availability
   
   **Objective:** Register a new public template with a controllable URL for 
subsequent URL unavailability testing.
   
   **Steps:**
   1. Registered template via API with `zoneid=-1` (cross-zone), `ispublic=true`
   2. Waited for download to complete on both secondary storages
   
   **Status:** PASSED
   
   **Test Results:**
   
   | Verification | Result |
   |--------------|--------|
   | Template registered | Yes - ID: f313172f-4558-402c-ba58-b603271b7130 |
   | Cross-zone enabled | Yes - `crossZones: true` |
   | Downloaded on sec1 | Yes - 100% DOWNLOADED |
   | Downloaded on sec2 | Yes - 100% DOWNLOADED |
   | Files on NFS (sec1) | Present in `/template/tmpl/2/202/` |
   | Files on NFS (sec2) | Present in `/template/tmpl/2/202/` |
   
   **Test Evidence**
   
   #### Template registered, cross-zone enabled, downloaded on both sec1 and 
sec2 
   
   <details><summary><code>(localcloud) 🐱 >  list templates templatefilter=all 
name="Debian12-test" listall=true
   </code></summary>
   
   ```json
   {
     "count": 1,
     "template": [
       {
         "account": "admin",
         "arch": "x86_64",
         "bits": 0,
         "checksum": 
"8314fd5daa02f3a0e0e88bec50a60577fae9c78698b7f7130dde8a8d9e59a925a51e15ab4f49fc55e857b1056e9ff89f022276553ccc01fb4393c40a27b285b9",
         "created": "2026-01-13T06:48:00+0000",
         "crossZones": true,
         "deployasis": false,
         "details": {},
         "directdownload": false,
         "displaytext": "Debian 12 Test Template",
         "domain": "ROOT",
         "domainid": "32d7aa7f-ef9b-11f0-8706-1e00370002be",
         "domainpath": "/",
         "downloaddetails": [
           {
             "datastore": 
"NFS://10.0.32.4/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec1",
             "datastoreId": "248fc87c-6ee7-4f46-a386-fdc82408ce0f",
             "datastoreRole": "Image",
             "downloadPercent": "100",
             "downloadState": "DOWNLOADED"
           },
           {
             "datastore": "sec2",
             "datastoreId": "057b701c-516c-4339-b35a-e47a4a9e6e6d",
             "datastoreRole": "Image",
             "downloadPercent": "100",
             "downloadState": "DOWNLOADED"
           }
         ],
         "format": "QCOW2",
         "hasannotations": false,
         "hypervisor": "KVM",
         "id": "f313172f-4558-402c-ba58-b603271b7130",
         "isdynamicallyscalable": false,
         "isextractable": true,
         "isfeatured": false,
         "ispublic": true,
         "isready": true,
         "name": "Debian12-test",
         "ostypeid": "cf4aca12-6602-48ad-81ac-8f56a62dcfc7",
         "ostypename": "Debian GNU/Linux 12 (64-bit)",
         "passwordenabled": false,
         "physicalsize": 335740928,
         "requireshvm": true,
         "size": 10737418240,
         "sshkeyenabled": false,
         "status": "Download Complete",
         "tags": [],
         "templatetype": "USER",
         "url": 
"http://10.0.3.122/vladitemplates/qcow2/linux-debian-12-x86_64-gen2-v1.qcow2";,
         "zoneid": "4afe198a-1f07-4535-91bf-b5708a58d8e7",
         "zonename": "ref-trl-10584-k-Mol9-rositsa-kyuchukova"
       }
     ]
   }
   ```
   
   </details>
   
   #### Files on NFS (sec1) and Files on NFS (sec2)
   
   ```
   [root@sl-nestednfs ~]# cat 
/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec1/template/tmpl/2/202/template.properties
   #
   #Tue Jan 13 06:48:10 UTC 2026
   uniquename=202-2-9cf81fe9-ce46-3f4b-9f6c-55972d2fac8f
   qcow2.filename=b9d9c791-c347-3579-8fe8-bee101944438.qcow2
   qcow2.virtualsize=10737418240
   description=Debian 12 Test Template
   qcow2.size=335740928
   filename=b9d9c791-c347-3579-8fe8-bee101944438.qcow2
   size=335740928
   public=true
   id=202
   hvm=true
   virtualsize=10737418240
   qcow2=true
   [root@sl-nestednfs ~]# cat 
/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec2/template/tmpl/2/202/template.properties
   #
   #Tue Jan 13 06:48:10 UTC 2026
   uniquename=202-2-9cf81fe9-ce46-3f4b-9f6c-55972d2fac8f
   qcow2.filename=53104138-5ac7-3ce6-b6e1-4ad1eb9f8363.qcow2
   qcow2.virtualsize=10737418240
   description=Debian 12 Test Template
   qcow2.size=335740928
   filename=53104138-5ac7-3ce6-b6e1-4ad1eb9f8363.qcow2
   size=335740928
   public=true
   id=202
   hvm=true
   virtualsize=10737418240
   qcow2=true
   [root@sl-nestednfs ~]# 
   ```
   
   ## Test Case 3: Add Third Secondary Storage with URL Unavailable
   
   **Objective:** Verify templates are copied from existing secondary storage 
when the source URL is unavailable.
   
   Ran into this issue while testing: 
https://github.com/apache/cloudstack/issues/12415 but it seems to be unrelated 
to this PR. However, it's a blocker to continue with Test Case 3 execution
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to