Skip to content

Commit

Permalink
Attempt to repair package download feature - unsure it works for no
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimo committed Jul 9, 2022
1 parent 4dfd806 commit a395528
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void addInfo(OperationId operation, String message) {
throw new IllegalStateException("Need to start an Operations group first.");
}
MessagingManager msgMgr = operationLogs.computeIfAbsent(operation, (op) -> {
throw new IllegalStateException();
throw new IllegalStateException("No operation " + operation + " is know.");
});
msgMgr.addLines(message);
}
Expand All @@ -196,7 +196,7 @@ public void addInfo(OperationId operation, String[] messages) {
throw new IllegalStateException("Need to start an Operations group first.");
}
MessagingManager msgMgr = operationLogs.computeIfAbsent(operation, (op) -> {
throw new IllegalStateException();
throw new IllegalStateException("No operation " + operation + " is know.");
});
msgMgr.addLines(messages);
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/ch/niceideas/eskimo/services/SetupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ public String applySetup(SetupCommand setupCommand) {
String softwareVersion = (String) packagesVersion.getValueForPath(packageName + ".software");
String distributionVersion = (String) packagesVersion.getValueForPath(packageName + ".distribution");

downloadPackage(DOCKER_TEMPLATE_PREFIX + packageName + "_" + softwareVersion + "_" + distributionVersion + TAR_GZ_EXTENSION);
downloadPackage(
packageName + "_" + softwareVersion + "_" + distributionVersion,
DOCKER_TEMPLATE_PREFIX + packageName + "_" + softwareVersion + "_" + distributionVersion + TAR_GZ_EXTENSION);
}
}
}
Expand Down Expand Up @@ -599,7 +601,9 @@ public String applySetup(SetupCommand setupCommand) {
String softwareVersion = (String) packagesVersion.getValueForPath(kubePackageName + ".software");
String distributionVersion = (String) packagesVersion.getValueForPath(kubePackageName + ".distribution");

downloadPackage(KUBE_PREFIX + kubePackageName + "_" + softwareVersion + "_" + distributionVersion + TAR_GZ_EXTENSION);
downloadPackage(
kubePackageName + "_" + softwareVersion + "_" + distributionVersion,
KUBE_PREFIX + kubePackageName + "_" + softwareVersion + "_" + distributionVersion + TAR_GZ_EXTENSION);
}

} else {
Expand Down Expand Up @@ -632,7 +636,7 @@ public String applySetup(SetupCommand setupCommand) {

if (compareVersion (new Pair<> (newSoftwareVersion, newDistributionVersion),
lastVersionValues) > 0) {
downloadPackage(DOCKER_TEMPLATE_PREFIX + imageName + "_" + newSoftwareVersion + "_" + newDistributionVersion + TAR_GZ_EXTENSION);
downloadPackage(imageName, DOCKER_TEMPLATE_PREFIX + imageName + "_" + newSoftwareVersion + "_" + newDistributionVersion + TAR_GZ_EXTENSION);
}
}
}
Expand Down Expand Up @@ -704,11 +708,11 @@ public int compareSoftwareVersion (String firstVersion, String secondVersion) {
return 0;
}

protected void downloadPackage(String fileName) throws SetupException {
protected void downloadPackage(String packageIdentifier, String fileName) throws SetupException {
if (!operationsMonitoringService.isInterrupted()) {
try {
systemOperationService.applySystemOperation(
new SetupCommand.SetupOperationId(SetupCommand.TYPE_DOWNLOAD, fileName),
new SetupCommand.SetupOperationId(SetupCommand.TYPE_DOWNLOAD, packageIdentifier),
ml -> {

File targetFile = new File(packageDistributionPath + "/" + fileName);
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/ch/niceideas/eskimo/services/SetupServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ protected void dowloadFile(MessageLogger ml, File destinationFile, URL downloadU
SetupCommand setupCommand = SetupCommand.create(setupConfigJson, setupService, servicesDefinition);
operationsMonitoringService.operationsStarted(setupCommand);

setupService.downloadPackage("cerebro_0.8.4_1");
setupService.downloadPackage("cerebro_0.8.4_1", "cerebro_0.8.4_1.tgz");

assertEquals (1, packageDevPathTest.listFiles().length);
assertEquals("cerebro_0.8.4_1", packageDevPathTest.listFiles()[0].getName());
assertEquals("cerebro_0.8.4_1.tgz", packageDevPathTest.listFiles()[0].getName());
assertEquals("TEST DOWNLOADED CONTENT", FileUtils.readFile(packageDevPathTest.listFiles()[0]));

FileUtils.delete(packageDevPathTest);
Expand Down Expand Up @@ -468,7 +468,7 @@ protected void buildPackage(String image) throws SetupException {
builtPackageList.add (image);
}
@Override
protected void downloadPackage(String fileName) throws SetupException {
protected void downloadPackage(String packageName, String fileName) throws SetupException {
downloadPackageList.add (fileName);
}
@Override
Expand Down Expand Up @@ -531,7 +531,7 @@ protected void buildPackage(String image) throws SetupException {
builtPackageList.add (image);
}
@Override
protected void downloadPackage(String fileName) throws SetupException {
protected void downloadPackage(String packageName, String fileName) throws SetupException {
downloadPackageList.add (fileName);
}
@Override
Expand Down Expand Up @@ -594,7 +594,7 @@ protected void buildPackage(String image) {
builtPackageList.add (image);
}
@Override
protected void downloadPackage(String fileName) {
protected void downloadPackage(String packageName, String fileName) {
downloadPackageList.add (fileName);
}
@Override
Expand Down Expand Up @@ -639,7 +639,7 @@ protected void buildPackage(String image) {
builtPackageList.add (image);
}
@Override
protected void downloadPackage(String fileName) {
protected void downloadPackage(String packageName, String fileName) {
downloadPackageList.add (fileName);
}
@Override
Expand Down Expand Up @@ -682,7 +682,7 @@ protected void buildPackage(String image) {
builtPackageList.add (image);
}
@Override
protected void downloadPackage(String fileName) {
protected void downloadPackage(String packageName, String fileName) {
downloadPackageList.add (fileName);
}
@Override
Expand Down

0 comments on commit a395528

Please sign in to comment.