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();
}
}
}
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());
}
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);
}
}
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());
}
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);
}
Aggregations