Skip to content

Commit

Permalink
MID-8842 verification step started, progress and ask/stop after proce…
Browse files Browse the repository at this point in the history
…ssing still missing
  • Loading branch information
1azyman committed May 29, 2023
1 parent 186864c commit 45fe0e5
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class UpgradeAction extends Action<UpgradeOptions> {

private static final Class<? extends UpgradeStep>[] STEPS = new Class[] {
UpgradePreCheckStep.class,
// VerifyStep.class,
VerifyStep.class,
// UpgradeObjectsBeforeShutdownStep.class, // todo upgrade initial objects, also all other objects that can be upgraded before midpoint version/DB/midpoint home was upgraded
DownloadDistributionStep.class,
// DatabaseSchemaStep.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class UpgradeConstants {
public static final String[] SUPPORTED_VERSIONS = { SUPPORTED_VERSION_LTS, SUPPORTED_VERSION_FEATURE, "4.8-SNAPSHOT" }; // todo remove viliam

public static final String UPGRADE_TEMP_DIRECTORY = ".upgrade";

public static final String VERIFY_OUTPUT_FILE = "verify-output.csv";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.validators.PositiveInteger;

@Parameters(resourceBundle = "messages", commandDescriptionKey = "upgrade")
public class UpgradeOptions {
Expand All @@ -27,6 +28,8 @@ public class UpgradeOptions {

public static final String P_INSTALLATION_DIRECTORY = "--installation-directory";

public static final String P_VERIFY_THREADS = "--verify-threads";

@Parameter(names = { P_ABORT_LONG }, descriptionKey = "upgrade.abort")
private Boolean abort;

Expand All @@ -45,6 +48,9 @@ public class UpgradeOptions {
@Parameter(names = { P_INSTALLATION_DIRECTORY }, descriptionKey = "upgrade.installationDirectory")
private File installationDirectory;

@Parameter(names = { P_VERIFY_THREADS }, descriptionKey = "upgrade.verifyThreads", validateWith = PositiveInteger.class)
private int verifyThreads = 1;

public Boolean isAbort() {
return abort;
}
Expand All @@ -68,4 +74,8 @@ public Boolean isBackupMidpointDirectory() {
public File getInstallationDirectory() {
return installationDirectory;
}

public int getVerifyThreads() {
return verifyThreads;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

package com.evolveum.midpoint.ninja.action.upgrade.step;

import java.io.File;

import com.evolveum.midpoint.ninja.action.VerifyRepositoryAction;
import com.evolveum.midpoint.ninja.action.upgrade.StepResult;
import com.evolveum.midpoint.ninja.action.upgrade.UpgradeConstants;
import com.evolveum.midpoint.ninja.action.upgrade.UpgradeStep;
import com.evolveum.midpoint.ninja.action.upgrade.UpgradeStepsContext;
import com.evolveum.midpoint.ninja.opts.VerifyOptions;

public class VerifyStep implements UpgradeStep<StepResult> {

private UpgradeStepsContext context;
private final UpgradeStepsContext context;

public VerifyStep(UpgradeStepsContext context) {
this.context = context;
Expand All @@ -28,18 +31,24 @@ public String getIdentifier() {

@Override
public StepResult execute() throws Exception {
// todo implement
final VerifyOptions options = new VerifyOptions();
options.setCreateReport(true);
options.setOverwrite(true);

int threads = context.getOptions().getVerifyThreads();
options.setMultiThread(threads);

VerifyOptions options = new VerifyOptions();
// options.isCreateReport();
// options.getMultiThread();
// options.getOutput();
// options.isOverwrite();
final File tempDirectory = context.getTempDirectory();
File output = new File(tempDirectory, UpgradeConstants.VERIFY_OUTPUT_FILE);
options.setOutput(output);

VerifyRepositoryAction action = new VerifyRepositoryAction();
action.init(context.getContext(), options);
action.execute();

// todo progress reporting
// todo ask after this finishes, whether to exit or continue to next step

return new StepResult() {
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,34 @@ public String getOid() {
public int getMultiThread() {
return multiThread;
}

public BaseImportExportOptions setRaw(boolean raw) {
this.raw = raw;
return this;
}

public BaseImportExportOptions setOid(String oid) {
this.oid = oid;
return this;
}

public BaseImportExportOptions setType(Set<ObjectTypes> type) {
this.type = type;
return this;
}

public BaseImportExportOptions setFilter(FileReference filter) {
this.filter = filter;
return this;
}

public BaseImportExportOptions setZip(boolean zip) {
this.zip = zip;
return this;
}

public BaseImportExportOptions setMultiThread(int multiThread) {
this.multiThread = multiThread;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,19 @@ public boolean isOverwrite() {
public boolean isSkipContainerIds() {
return skipIds;
}

public ExportOptions setOutput(File output) {
this.output = output;
return this;
}

public ExportOptions setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
return this;
}

public ExportOptions setSkipIds(boolean skipIds) {
this.skipIds = skipIds;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public String getWarn() {
public Boolean isCreateReport() {
return createReport;
}

public VerifyOptions setWarn(String warn) {
this.warn = warn;
return this;
}

public VerifyOptions setCreateReport(Boolean createReport) {
this.createReport = createReport;
return this;
}
}
5 changes: 3 additions & 2 deletions tools/ninja/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ upgrade.abort=Abort upgrade, cleans local files created by ninja during upgrade
upgrade.tempDir=Temp directory. By default, JVM temp directory is used.
upgrade.confirmSteps=Confirm execution after each step.
upgrade.distributionArchive=Distribution archive file. This can be used to skip downloading archive.
upgrade.backupMidpointDirectory=Backup midPoint home directory
upgrade.installationDirectory=MidPoint installation directory
upgrade.backupMidpointDirectory=Backup midPoint home directory.
upgrade.installationDirectory=MidPoint installation directory.
upgrade.verifyThreads=Number of threads to use to verify objects in midPoint.
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ public static void main(String[] args) {
// "-O", "./export.xml",
// "-t", "users",
// "-o", SystemObjectsType.USER_ADMINISTRATOR.value());
String[] input = new String[]{"-v", "-m", "./src/test/resources/midpoint-home",
String[] input = new String[] { "-v", "-m", "./src/test/resources/midpoint-home",
"export",
"-O", "./export.xml",
"-t", "roles"};
"-t", "roles" };
// "-f", "<inOid xmlns=\"http://prism.evolveum.com/xml/ns/public/query-3\"><value>00000000-0000-0000-0000-000000000002</value></inOid>");

// input = "-m /Users/lazyman/Work/monoted/git/evolveum/midpoint/_mess/midpoint-home verify --create-report".split(" ");
// input = "-m ../../_mess/midpoint-home verify --create-report".split(" ");
// input = "-h upgrade".split(" ");
input = (""
+ "-m /Users/lazyman/Work/monoted/git/evolveum/midpoint-support/_mess/mid8842/var "
input = ("-m ../../_mess/mid8842/var "
+ "upgrade "
+ "--distribution-archive /Users/lazyman/Downloads/midpoint-latest-dist.zip "
+ "--installation-directory /Users/lazyman/Work/monoted/git/evolveum/midpoint-support/_mess/mid8842 "
+ "--distribution-archive ~/Downloads/midpoint-latest-dist.zip "
+ "--installation-directory ../../_mess/mid8842 "
+ "--backup-midpoint-directory "
+ "--temp-dir /Users/lazyman/Work/monoted/git/evolveum/midpoint-support/_mess/mid8842/.upgrade-process"
+ "").split(" ");
+ "--temp-dir ../../_mess/mid8842/.upgrade-process")
.split(" ");

Main.main(input);
}
Expand Down

0 comments on commit 45fe0e5

Please sign in to comment.