// 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.ovm3.objects;
import org.junit.Test;
public class RepositoryTest {
ConnectionTest con = new ConnectionTest();
Repository repo = new Repository(con);
XmlTestResultTest results = new XmlTestResultTest();
private String REPOID = "f12842ebf5ed3fe78da1eb0e17f5ede8";
private String MGRID = "d1a749d4295041fb99854f52ea4dea97";
private String REPOALIAS = "OVS Repository";
private String REMOTENFS = "cs-mgmt:/volumes/cs-data/primary/ovm";
private String LOCALMOUNT = "/OVS/Repositories/f12842ebf5ed3fe78da1eb0e17f5ede8";
private String REPOVERSION = "3.0";
private String REPOSTATUS = "Mounted";
private String ISO = "systemvm.iso";
private String TEMPLATE = "0b53acb1-6554-41b8-b1e1-7b27a01b6acb";
private String DISK = "cfb5ee12-b99d-41d1-a5b2-44dea36c9de1.raw";
private String VM = "7efbdbe0-3d01-3b22-a8a0-1d41c6f2502f";
private String REPODISCOVERXML = "<string>"
+ "<?xml version=\"1.0\" ?>"
+ "<Discover_Repositories_Result>" + "<RepositoryList>"
+ "<Repository Name=\""
+ REPOID
+ "\">"
+ "<Version>"
+ REPOVERSION
+ "</Version>"
+ "<Manager_UUID>"
+ MGRID
+ "</Manager_UUID>"
+ "<Repository_UUID>"
+ REPOID
+ "</Repository_UUID>"
+ "<Repository_Alias>"
+ REPOALIAS
+ "</Repository_Alias>"
+ "<Assemblies/>"
+ "<Templates>"
+ "<Template Name=\""
+ TEMPLATE
+ "\">"
+ "<File>"
+ TEMPLATE
+ ".raw</File>"
+ "</Template>"
+ "<Template Name=\"7d5c29db-6343-4431-b509-9646b45cc31b\">"
+ "<File>7d5c29db-6343-4431-b509-9646b45cc31b.raw</File>"
+ "</Template>"
+ "</Templates>"
+ "<VirtualMachines>"
+ "<VirtualMachine Name=\""
+ VM
+ "\">"
+ "<File>vm.cfg</File>"
+ "</VirtualMachine>"
+ "<VirtualMachine Name=\"pool\">"
+ "<File>ovspoolfs.img</File>"
+ "</VirtualMachine>"
+ "<VirtualMachine Name=\"4fb50e31-b032-3012-b70b-7e27c2acdfe2\">"
+ "<File>vm.cfg</File>"
+ "</VirtualMachine>"
+ "<VirtualMachine Name=\"5ffe3ddc-606d-3fec-a956-67638f7ba838\">"
+ "<File>vm.cfg</File>"
+ "</VirtualMachine>"
+ "<VirtualMachine Name=\"14fc3846-45e5-3c08-ad23-432ceb07407b\">"
+ "<File>vm.cfg</File>"
+ "</VirtualMachine>"
+ "</VirtualMachines>"
+ "<VirtualDisks>"
+ "<Disk>"
+ DISK
+ "</Disk>"
+ "<Disk>b92dd5c5-0f24-4cca-b86a-153ac6e950a8.raw</Disk>"
+ "<Disk>d144c278-0825-41d5-b9c6-8bb21f3dd1e7.raw</Disk>"
+ "<Disk>99650d9f-c7ee-42df-92e3-6cafc0876141.raw</Disk>"
+ "</VirtualDisks>"
+ "<ISOs>"
+ "<ISO>"
+ ISO
+ "</ISO>"
+ "</ISOs>"
+ "</Repository>"
+ "</RepositoryList>"
+ "</Discover_Repositories_Result>" + "</string>";
private String REPODBDISCOVERXML = "<string>"
+ "<?xml version=\"1.0\" ?>"
+ "<Discover_Repository_Db_Result>"
+ "<RepositoryDbList>" + "<Repository Uuid=\""
+ REPOID
+ "\">"
+ "<Fs_location>"
+ REMOTENFS
+ "</Fs_location>"
+ "<Mount_point>"
+ LOCALMOUNT
+ "</Mount_point>"
+ "<Filesystem_type>nfs</Filesystem_type>"
+ "<Version>"
+ REPOVERSION
+ "</Version>"
+ "<Alias>"
+ REPOALIAS
+ "</Alias>"
+ "<Manager_uuid>"
+ MGRID
+ "</Manager_uuid>"
+ "<Status>"
+ REPOSTATUS
+ "</Status>"
+ "</Repository>"
+ "</RepositoryDbList>"
+ "</Discover_Repository_Db_Result>" + "</string>";
/*
* @Test Create a test repo that mimics the above so we can test against a
* live box... public void testCreateRepo() throws Ovm3ResourceException {
* con.setResult(null); repo.createRepo(REMOTENFS, LOCALMOUNT, REPOID,
* REPOALIAS); }
*/
@Test
public void testDiscoverRepoBase() throws Ovm3ResourceException {
con.setResult(results.simpleResponseWrapWrapper(this.REPODISCOVERXML));
repo.discoverRepo(REPOID);
results.basicStringTest(repo.getRepo(REPOID).getUuid(), REPOID);
results.basicStringTest(repo.getRepo(REPOID).getAlias(), REPOALIAS);
results.basicStringTest(repo.getRepo(REPOID).getVersion(), REPOVERSION);
results.basicStringTest(repo.getRepo(REPOID).getManagerUuid(), MGRID);
}
@Test
public void testDiscoverRepoDetails() throws Ovm3ResourceException {
con.setResult(results.simpleResponseWrapWrapper(this.REPODISCOVERXML));
repo.discoverRepo(REPOID);
results.basicBooleanTest(results.basicListHasString(repo
.getRepo(REPOID).getRepoVirtualDisks(), DISK), true);
results.basicBooleanTest(results.basicListHasString(repo
.getRepo(REPOID).getRepoVirtualMachines(), VM), true);
results.basicBooleanTest(results.basicListHasString(repo
.getRepo(REPOID).getRepoTemplates(), TEMPLATE + ".raw"), true);
results.basicBooleanTest(results.basicListHasString(repo
.getRepo(REPOID).getRepoISOs(), ISO), true);
results.basicBooleanTest(results.basicListHasString(repo
.getRepo(REPOID).getRepoISOs(), VM), false);
}
@Test
public void testDiscoverRepoDb() throws Ovm3ResourceException {
con.setResult(results.simpleResponseWrapWrapper(this.REPODBDISCOVERXML));
repo.discoverRepoDb();
results.basicStringTest(repo.getRepoDb(REPOID).getUuid(), REPOID);
results.basicStringTest(repo.getRepoDb(REPOID).getAlias(), REPOALIAS);
results.basicStringTest(repo.getRepoDb(REPOID).getVersion(),
REPOVERSION);
results.basicStringTest(repo.getRepoDb(REPOID).getManagerUuid(), MGRID);
results.basicStringTest(repo.getRepoDb(REPOID).getMountPoint(),
LOCALMOUNT);
results.basicStringTest(repo.getRepoDb(REPOID).getFsLocation(),
REMOTENFS);
results.basicStringTest(repo.getRepoDb(REPOID).getStatus(), REPOSTATUS);
results.basicStringTest(repo.getRepoDb(REPOID).getFilesystemType(),
"nfs");
}
}