cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rafaelweingartner commented on a change in pull request #2412: CLOUDSTACK-9677: Adding storage policy support for swift as secondary?
Date Thu, 01 Jan 1970 00:00:00 GMT
rafaelweingartner commented on a change in pull request #2412: CLOUDSTACK-9677: Adding storage
policy support for swift as secondary?
URL: https://github.com/apache/cloudstack/pull/2412#discussion_r164267825
 
 

 ##########
 File path: plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessorTest.java
 ##########
 @@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.hypervisor.xenserver.resource;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.agent.api.to.SwiftTO;
+
+public class XenServerStorageProcessorTest {
+    @Test
+    public void testOrderOfSwiftUplodScriptParams() {
+        CitrixResourceBase resource = Mockito.mock(CitrixResourceBase.class);
+        XenServerStorageProcessor mock = new XenServerStorageProcessor(resource);
+
+        SwiftTO swift = Mockito.mock(SwiftTO.class);
+        String container = "sample-container-name";
+        String ldir = "sample-ldir";
+        String lfilename = "sample-lfilename";
+        Boolean isISCSI = true;
+
+        List<String> params = mock.getSwiftParams(swift, container, ldir, lfilename,
isISCSI);
+
+        // make sure the params not null and has correct number of items in it
+        Assert.assertNotNull("params is null", params);
+        Assert.assertTrue("Expected param list size is either 18 or 20 but it was" + params.size(),
params.size() == 18 || params.size() == 20);
+
+        // check the order of params
+        Assert.assertEquals("unexpected param.", "op", params.get(0));
+        Assert.assertEquals("unexpected param.", "upload", params.get(1));
+        Assert.assertEquals("unexpected param.", "url", params.get(2));
+        Assert.assertEquals("unexpected param.", swift.getUrl(), params.get(3));
+        Assert.assertEquals("unexpected param.", "account", params.get(4));
+        Assert.assertEquals("unexpected param.", swift.getAccount(), params.get(5));
+        Assert.assertEquals("unexpected param.", "username", params.get(6));
+        Assert.assertEquals("unexpected param.", swift.getUserName(), params.get(7));
+        Assert.assertEquals("unexpected param.", "key", params.get(8));
+        Assert.assertEquals("unexpected param.", swift.getKey(), params.get(9));
+        Assert.assertEquals("unexpected param.", "container", params.get(10));
+        Assert.assertEquals("unexpected param.", container, params.get(11));
+        Assert.assertEquals("unexpected param.", "ldir", params.get(12));
+        Assert.assertEquals("unexpected param.", ldir, params.get(13));
+        Assert.assertEquals("unexpected param.", "lfilename", params.get(14));
+        Assert.assertEquals("unexpected param.", lfilename, params.get(15));
+        Assert.assertEquals("unexpected param.", "isISCSI", params.get(16));
+        Assert.assertEquals("unexpected param.", isISCSI.toString(), params.get(17));
+
+        if (swift.getStoragePolicy() != null) {
 
 Review comment:
   @khos2ow thanks for creating the unit test case.
   I have a doubt here. What is the execution flow you are testing? the one with storage policy
or without it?
   Also, what do you think about two distinct tests? One to execute the test with a storagePolicy
and other without. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message