|
30 | 30 | import com.cloud.agent.api.Command; |
31 | 31 | import com.cloud.agent.api.GetHostStatsCommand; |
32 | 32 | import com.cloud.agent.api.SecStorageFirewallCfgCommand; |
| 33 | +import com.cloud.agent.api.SecStorageSetupCommand; |
33 | 34 | import com.cloud.agent.api.UpdateHostPasswordCommand; |
34 | 35 | import com.cloud.agent.api.storage.DownloadAnswer; |
35 | 36 | import com.cloud.agent.api.to.NfsTO; |
@@ -129,6 +130,36 @@ public void testSerDeser() { |
129 | 130 | compareRequest(cresp, sresp); |
130 | 131 | } |
131 | 132 |
|
| 133 | + |
| 134 | + public void testSerDeserTO() { |
| 135 | + s_logger.info("Testing serializing and deserializing interface TO works as expected"); |
| 136 | + |
| 137 | + NfsTO nfs = new NfsTO("nfs://192.168.56.10/opt/storage/secondary", DataStoreRole.Image); |
| 138 | + SecStorageSetupCommand cmd = new SecStorageSetupCommand(nfs, "nfs://192.168.56.10/opt/storage/secondary", null); |
| 139 | + Request sreq = new Request(2, 3, cmd, true); |
| 140 | + sreq.setSequence(892403718); |
| 141 | + |
| 142 | + |
| 143 | + byte[] bytes = sreq.getBytes(); |
| 144 | + |
| 145 | + assert Request.getSequence(bytes) == 892403718; |
| 146 | + assert Request.getManagementServerId(bytes) == 3; |
| 147 | + assert Request.getAgentId(bytes) == 2; |
| 148 | + assert Request.getViaAgentId(bytes) == 2; |
| 149 | + Request creq = null; |
| 150 | + try { |
| 151 | + creq = Request.parse(bytes); |
| 152 | + } catch (ClassNotFoundException e) { |
| 153 | + s_logger.error("Unable to parse bytes: ", e); |
| 154 | + } catch (UnsupportedVersionException e) { |
| 155 | + s_logger.error("Unable to parse bytes: ", e); |
| 156 | + } |
| 157 | + |
| 158 | + assert creq != null : "Couldn't get the request back"; |
| 159 | + |
| 160 | + compareRequest(creq, sreq); |
| 161 | + } |
| 162 | + |
132 | 163 | public void testDownload() { |
133 | 164 | s_logger.info("Testing Download answer"); |
134 | 165 | VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true, |
|
0 commit comments