Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update test develop #947

Merged
merged 5 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public List<Command> getCommandList() {
}

private void runInDatabase(String query, String databaseName) {
ServerEvaluationCall eval = hubConfig.newStagingClient().newServerEval();
ServerEvaluationCall eval = hubConfig.newModulesDbClient().newServerEval();
String xqy =
"xdmp:invoke-function(function() {" +
query +
Expand Down Expand Up @@ -506,7 +506,7 @@ private Map<Integer, String> getServerPortsInUse() {
}

//DataHubUpgrader stuff
public static String MIN_UPGRADE_VERSION = "1.1.3";
public static String MIN_UPGRADE_VERSION = "2.0.0";

@Override public boolean upgradeHub() throws CantUpgradeException {
return upgradeHub(null);
Expand Down Expand Up @@ -545,6 +545,8 @@ private Map<Integer, String> getServerPortsInUse() {
updatedFlows.addAll(flows);
}

runInDatabase("cts:uris(\"\", (), cts:and-not-query(cts:collection-query(\"hub-core-module\"), cts:document-query((\"/com.marklogic.hub/config.sjs\", \"/com.marklogic.hub/config.xqy\")))) ! xdmp:document-delete(.)", hubConfig.getDbName(DatabaseKind.MODULES));

if (isHubInstalled) {
// install hub modules into MarkLogic
this.install();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ public DatabaseClient newModulesDbClient() {

// this lets debug builds work from an IDE
if (version.equals("${project.version}")) {
version = "0.1.2";
version = "3.0.0";
}
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public boolean update2xFlow(String entityName, String flowName, FlowType flowTyp

Path flowDir = getFlowDir(entityName, flowName, flowType);
Path mainPath = flowDir.resolve("main.sjs");
Path xqyMainPath = flowDir.resolve("main.xqy");
if (mainPath.toFile().exists()) {
try {
String mainFile = FileUtils.readFileToString(mainPath.toFile());
Expand Down Expand Up @@ -309,6 +310,22 @@ public boolean update2xFlow(String entityName, String flowName, FlowType flowTyp
throw new RuntimeException(e);
}
}

if (mainPath.toFile().exists() || xqyMainPath.toFile().exists()) {
if (xqyMainPath.toFile().exists()) {
mainPath = xqyMainPath;
}
try {
String mainFile = FileUtils.readFileToString(mainPath.toFile());
mainFile = mainFile.replaceFirst("com\\.marklogic\\.hub", "MarkLogic/data-hub-framework");
FileOutputStream fileOutputStream = new FileOutputStream(mainPath.toFile());
IOUtils.write(mainFile, fileOutputStream);
fileOutputStream.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

return updated;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class UpdateHubTaskTest extends BaseTest {
def setupSpec() {
createGradleFiles()
runTask('hubInit')
println(runTask('mlDeploy', '-i').getOutput())
}

def "no updates needed"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,14 @@ public ResponseEntity<?> clearDatabase() {

@RequestMapping(value = "/update-hub", method = RequestMethod.POST)
public ResponseEntity<?> updateHub() throws IOException, CantUpgradeException {
if (dataHubService.updateHub(envConfig().getMlSettings())) {
installUserModules(envConfig().getMlSettings(), true);
startProjectWatcher();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
try {
if (dataHubService.updateHub(envConfig().getMlSettings())) {
installUserModules(envConfig().getMlSettings(), true);
startProjectWatcher();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
} catch (CantUpgradeException e) {
return new ResponseEntity<>(e, HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
Expand Down
1 change: 1 addition & 0 deletions quick-start/src/main/ui/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ <h3 *ngIf="currentEnvironment">Congratulations on updating to version<br>{{curre
<h3>Automatic Hub Update Failed!</h3>
<p *ngIf="currentEnvironment" class="error">
Sorry. We failed to update you to version <span class="version">{{currentEnvironment.runningVersion}}</span>.
<span>{{hubUpdateError}}.</span>
</p>
<p>Go read the wiki page that describes the changes necessary and try them manually.</p>
<a target="_blank" [href]="hubUpdateUrl()">How to update a Hub Project</a>
Expand Down
5 changes: 4 additions & 1 deletion quick-start/src/main/ui/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class LoginComponent implements OnInit {
hubVersions: any;
hubUpdating: boolean = false;
hubUpdateFailed: boolean = false;
hubUpdateError: string = '';

currentTab: string = 'ProjectDir';

Expand Down Expand Up @@ -314,11 +315,13 @@ export class LoginComponent implements OnInit {
this.hubUpdating = true;
this.projectService.updateProject().subscribe(() => {
this.hubUpdating = false;
this.hubUpdateError = '';
this.loginNext();
},
() => {
error => {
this.hubUpdating = false;
this.hubUpdateFailed = true;
this.hubUpdateError = error.json().message;
});
}

Expand Down