Search in sources :

Example 36 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class LocalRepositoryTest method localRepositoryTest.

@Test
public void localRepositoryTest() throws Exception {
    // getVersions() returns an empty List but never null
    LocalRepository _localRepo = LocalRepository.getInstance();
    RepositoryInfo state = _localRepo.getRepositoryInfo();
    SoftwareVersion current = state.getCurrentVersion();
    Assert.assertNotNull(current);
    System.out.println("current=" + current);
    List<SoftwareVersion> available = state.getVersions();
    Assert.assertNotNull(available);
    System.out.println("available=");
    byte[] buf = new byte[100];
    for (SoftwareVersion v : available) {
        System.out.println(v);
        InputStream in = _localRepo.getImageInputStream(v);
        try {
            Assert.assertTrue(in.read(buf) == buf.length);
        } finally {
            in.close();
        }
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) InputStream(java.io.InputStream) LocalRepository(com.emc.storageos.systemservices.impl.upgrade.LocalRepository) Test(org.junit.Test)

Example 37 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class RemoteRepositoryTest method testDirectoryRepository.

@Test
public void testDirectoryRepository() throws Exception {
    repositoryUrl = DIRECTORY_REPO;
    _repo = RemoteRepository.getInstance();
    Assert.assertTrue(_repo != null);
    final List<SoftwareVersion> remoteVersions = _repo.getVersions();
    Assert.assertTrue(remoteVersions != null);
    Assert.assertTrue(!remoteVersions.isEmpty());
    for (SoftwareVersion v : remoteVersions) {
        System.out.println(v);
    }
    int downloadableVersions = 0;
    for (SoftwareVersion v : remoteVersions) {
        try {
            _repo.checkVersionDownloadable(v);
        } catch (RemoteRepositoryException e) {
            continue;
        } catch (BadRequestException e) {
            continue;
        }
        final InputStream in = _repo.getImageInputStream(v);
        Assert.assertTrue(in != null);
        byte[] buffer = new byte[0x10000];
        Assert.assertTrue("getImageInputStream failed for " + v, in.read(buffer) > 0);
        in.close();
        downloadableVersions++;
    }
    // Make sure there are at least some downloadable versiosn
    Assert.assertTrue(downloadableVersions > 0);
    System.out.println("Found " + downloadableVersions + " downloadable versions out of " + remoteVersions.size());
    final SoftwareVersion version = (SoftwareVersion) remoteVersions.toArray()[0];
    File file = startBackgroundDownload(version);
    Assert.assertNotNull(file);
    while (_downloader.isDownloading()) {
        System.out.println("Downloading " + file);
        Thread.sleep(2000);
    }
    Assert.assertTrue(file.exists());
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) InputStream(java.io.InputStream) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) File(java.io.File) Test(org.junit.Test)

Example 38 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class RemoteRepositoryTest method testRemoteDirectoryRepositoryViaProxy.

@Test
public void testRemoteDirectoryRepositoryViaProxy() throws Exception {
    repositoryProxy = REMOTE_PROXY;
    repositoryUrl = DIRECTORY_REPO;
    _repo = RemoteRepository.getInstance();
    Assert.assertTrue(_repo != null);
    final List<SoftwareVersion> remoteVersions = _repo.getVersions();
    Assert.assertTrue(remoteVersions != null);
    Assert.assertTrue(!remoteVersions.isEmpty());
    for (SoftwareVersion v : remoteVersions) {
        System.out.println(v);
    }
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) Test(org.junit.Test)

Example 39 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class RemoteRepositoryTest method testCatalogRepository.

@Test
public void testCatalogRepository() throws Exception {
    repositoryUrl = CATALOG_SERVER_URL;
    _repo = RemoteRepository.getInstance();
    Assert.assertTrue(_repo != null);
    final List<SoftwareVersion> remoteVersions = _repo.getVersions();
    Assert.assertTrue(remoteVersions != null);
    Assert.assertTrue(!remoteVersions.isEmpty());
    for (SoftwareVersion v : remoteVersions) {
        System.out.println(v);
    }
    int downloadableVersions = 0;
    for (SoftwareVersion v : remoteVersions) {
        try {
            _repo.checkVersionDownloadable(v);
        } catch (RemoteRepositoryException e) {
            continue;
        } catch (BadRequestException e) {
            continue;
        }
        final InputStream in = _repo.getImageInputStream(v);
        Assert.assertTrue(in != null);
        byte[] buffer = new byte[0x10000];
        Assert.assertTrue("getImageInputStream failed for " + v, in.read(buffer) > 0);
        in.close();
        downloadableVersions++;
    }
    // Make sure there are at least some downloadable versiosn
    Assert.assertTrue(downloadableVersions > 0);
    System.out.println("Found " + downloadableVersions + " downloadable versions out of " + remoteVersions.size());
    SoftwareVersion version = null;
    // avoid version 121 since it is bad
    for (SoftwareVersion remoteVersion : remoteVersions) {
        // / Avoid a specific version on the downloads test site because it is no good
        if (0 != remoteVersion.compareTo(new SoftwareVersion("vipr-1.0.0.7.121"))) {
            version = remoteVersion;
            break;
        }
    }
    Assert.assertNotNull(version);
    File file = startBackgroundDownload(version);
    Assert.assertNotNull(file);
    while (_downloader.isDownloading()) {
        System.out.println("Downloading " + file);
        Thread.sleep(2000);
    }
    Assert.assertTrue(file.exists());
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) InputStream(java.io.InputStream) RemoteRepositoryException(com.emc.storageos.systemservices.exceptions.RemoteRepositoryException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) File(java.io.File) Test(org.junit.Test)

Example 40 with SoftwareVersion

use of com.emc.storageos.coordinator.client.model.SoftwareVersion in project coprhd-controller by CoprHD.

the class SoftwareVersionTest method pairTest.

// Call with A < B
private void pairTest(String versionStrA, String versionStrB) throws Exception {
    System.out.println("pairTest: " + versionStrA + " : " + versionStrB);
    final SoftwareVersion versionA = new SoftwareVersion(versionStrA);
    final SoftwareVersion versionB = new SoftwareVersion(versionStrB);
    final String noPrefixVersionStrA = toNoPrefix(versionStrA);
    final SoftwareVersion noPrefixVersionA = new SoftwareVersion(noPrefixVersionStrA);
    final String noPrefixVersionStrB = toNoPrefix(versionStrB);
    final SoftwareVersion noPrefixVersionB = new SoftwareVersion(noPrefixVersionStrB);
    Assert.assertFalse(versionA.equals(versionB));
    Assert.assertFalse(versionB.equals(versionA));
    Assert.assertTrue(versionA.compareTo(versionB) < 0);
    Assert.assertTrue(versionB.compareTo(versionA) > 0);
    Assert.assertFalse(noPrefixVersionA.equals(noPrefixVersionB));
    Assert.assertFalse(noPrefixVersionB.equals(noPrefixVersionA));
    Assert.assertTrue(noPrefixVersionA.compareTo(noPrefixVersionB) < 0);
    Assert.assertTrue(noPrefixVersionB.compareTo(noPrefixVersionA) > 0);
    Assert.assertFalse(versionA.equals(noPrefixVersionB));
    Assert.assertFalse(noPrefixVersionB.equals(versionA));
    Assert.assertTrue(versionA.compareTo(noPrefixVersionB) < 0);
    Assert.assertTrue(noPrefixVersionB.compareTo(versionA) > 0);
    Assert.assertFalse(noPrefixVersionA.equals(versionB));
    Assert.assertFalse(versionB.equals(noPrefixVersionA));
    Assert.assertTrue(noPrefixVersionA.compareTo(versionB) < 0);
    Assert.assertTrue(versionB.compareTo(noPrefixVersionA) > 0);
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion)

Aggregations

SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)44 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)10 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)9 RemoteRepositoryException (com.emc.storageos.systemservices.exceptions.RemoteRepositoryException)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 Path (javax.ws.rs.Path)8 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)7 IOException (java.io.IOException)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 ServiceUnavailableException (com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException)6 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)6 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)5 File (java.io.File)5 Produces (javax.ws.rs.Produces)5 InputStream (java.io.InputStream)4 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)3 POST (javax.ws.rs.POST)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3