перевод тестов на гит, рефакторинг проходов загрузки репозитория
This commit is contained in:
2025-03-13 17:11:05 +03:00
parent dc68667b20
commit 4ce7190905
10 changed files with 110 additions and 106 deletions

View File

@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
import java.util.Vector;
public class Constants {
public static final int version = 1207;
public static final int version = 1208;
public static final int planner_version = 15;
public static final int testingMaxKernels = 64;
//--
@@ -26,10 +26,8 @@ public class Constants {
public static final String PerformanceAnalyzerDirectoryName = "PerformanceAnalyzer";
public static final String KeyDirectoryName = "Keys";
//--
//SVN (пока оставить для тестов)
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
public static final String DVM_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/dvm";
//GIT
public static final String DVM_TESTS_REPOSITORY = "https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm-auto-test";
public static final String SAPFOR_REPOSITORY = "http://dvmh-server.ddns.net:3000/Alexander_KS/SAPFOR.git";
public static final String SAPFOR_VERSION_URL = "http://dvmh-server.ddns.net:3000/Alexander_KS/SAPFOR/raw/branch/master/src/Utils/version.h";
//-вывод задач

View File

@@ -1,41 +0,0 @@
package _VisualDVM.Passes.All;
import Common.CommonConstants;
import _VisualDVM.Constants;
import _VisualDVM.Global;
import _VisualDVM.Passes.ProcessPass;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
public class DownloadDvmRepository extends ProcessPass {
/*
git clone https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm /home/testuser/Repo/DVM/
git clone https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm-auto-test /home/testuser/Repo/DVM_AUTO_TEST/
*/
File dvmHome;
@Override
protected boolean canStart(Object... args) throws Exception {
dvmHome = Paths.get(Global.RepoDirectory.getAbsolutePath(),
"dvm").toFile();
return true;
}
private void synchronize(String src, File dst) throws Exception {
File loadedFile = Paths.get(dst.getAbsolutePath(), CommonConstants.LOADED).toFile();
if (loadedFile.exists()) {
PerformScript("cd " +
dst.getAbsolutePath() +
"\nsvn update " + Constants.REPOSITORY_AUTHENTICATION + "\n");
} else {
Utils.CleanDirectory(dst);
PerformScript("cd Repo\nsvn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + src + "\n"); //export
FileUtils.write(loadedFile, "");
}
}
@Override
protected void body() throws Exception {
ShowProgress(1, 0, true);
synchronize(Constants.DVM_REPOSITORY, dvmHome);
ShowProgress(1, 1, true);
}
}

View File

@@ -0,0 +1,22 @@
package _VisualDVM.Passes.All;
import Common.CommonConstants;
import Common.Utils.Utils_;
import _VisualDVM.Constants;
import _VisualDVM.Global;
import _VisualDVM.Passes.ProcessPass;
import _VisualDVM.Passes.Repository.DownloadRepositoryPass;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
public class DownloadDvmTestsRepository extends DownloadRepositoryPass {
/*
git clone https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm DST
git clone https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm-auto-test DST
*/
@Override
protected boolean canStart(Object... args) throws Exception {
return super.canStart(Constants.DVM_TESTS_REPOSITORY, "dvm-auto-test");
}
}

View File

@@ -4,46 +4,19 @@ import Common.Utils.Utils_;
import _VisualDVM.Constants;
import _VisualDVM.Global;
import _VisualDVM.Passes.ProcessPass;
import _VisualDVM.Passes.Repository.DownloadRepositoryPass;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
public class DownloadSapforRepository extends ProcessPass {
File sapforHome;
@Override
public String getDescription() {
return "Загрузка репозитория";
}
public class DownloadSapforRepository extends DownloadRepositoryPass {
@Override
protected boolean canStart(Object... args) throws Exception {
sapforHome = Paths.get(Global.RepoDirectory.getAbsolutePath(),
"SAPFOR").toFile();
return true;
}
private void synchronize(String src, File dst) throws Exception {
File loadedFile = Paths.get(dst.getAbsolutePath(), CommonConstants.LOADED).toFile();
if (loadedFile.exists()) {
PerformScript("cd " + dst.getAbsolutePath() + "\n" +
"git pull\n" +
"cd " + Utils_.DQuotes(sapforHome) + "\n" +
"GIT_SSL_NO_VERIFY=true git submodule update --init\n"
);
} else {
Utils.CleanDirectory(dst);
PerformScript("cd Repo\n" +
"git clone " +
Utils_.DQuotes(src) + "\n" +
"cd " + Utils_.DQuotes(sapforHome) + "\n" +
"GIT_SSL_NO_VERIFY=true git submodule update --init\n"
); //export
FileUtils.write(loadedFile, "");
}
return super.canStart(Constants.SAPFOR_REPOSITORY, "SAPFOR");
}
@Override
protected void body() throws Exception {
ShowProgress(1, 0, true);
synchronize(Constants.SAPFOR_REPOSITORY, sapforHome);
ShowProgress(1, 1, true);
protected boolean hasSubmodules() {
return true;
}
}

View File

@@ -132,7 +132,7 @@ public enum PassCode implements PassCode_ {
UpdateComponent,
BuildComponent,
DownloadSapforRepository,
DownloadDvmRepository,
DownloadDvmTestsRepository,
SaveGraph,
ApplyBugReportSettings,
DownloadBugReport,
@@ -790,8 +790,8 @@ public enum PassCode implements PassCode_ {
return "Сборка компонента";
case DownloadSapforRepository:
return "Загрузка репозитория SAPFOR";
case DownloadDvmRepository:
return "Загрузка репозитория DVM";
case DownloadDvmTestsRepository:
return "Загрузка репозитория DVM тестов";
case SaveGraph:
return "Сделать скриншот графа функций";
case ApplyBugReportSettings:

View File

@@ -0,0 +1,56 @@
package _VisualDVM.Passes.Repository;
import Common.CommonConstants;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.ProcessPass;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.Vector;
public class DownloadRepositoryPass extends ProcessPass {
String url;
String dst_name;
File dst;
@Override
public String getDescription() {
return "Загрузка репозитория";
}
@Override
protected boolean canStart(Object... args) throws Exception {
url = (String) args[0];
dst_name = (String) args[1];
dst = new File(Global.RepoDirectory, dst_name);
return true;
}
protected boolean hasSubmodules() {
return false;
}
@Override
protected void body() throws Exception {
ShowProgress(1, 0, true);
Vector<String> scriptLines = new Vector<>();
File loadedFile = Paths.get(dst.getAbsolutePath(), CommonConstants.LOADED).toFile();
boolean pull = loadedFile.exists();
if (pull){
System.out.println("PULL");
scriptLines.add("cd " + dst.getAbsolutePath());
scriptLines.add("git pull");
}else {
Utils.CleanDirectory(dst);
System.out.println("CLONE");
scriptLines.add("cd " + Utils_.DQuotes(Global.RepoDirectory.getAbsolutePath()));
scriptLines.add("git clone " + Utils_.DQuotes(url)+" "+Utils_.DQuotes(dst.getAbsolutePath()));
}
if (hasSubmodules()) {
scriptLines.add("cd " + Utils_.DQuotes(dst));
scriptLines.add("GIT_SSL_NO_VERIFY=true git submodule update --init");
}
PerformScript(String.join("\n", scriptLines));
if (!pull){
FileUtils.write(loadedFile, "");
}
ShowProgress(1, 1, true);
}
}

View File

@@ -12,7 +12,7 @@ import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
import _VisualDVM.Constants;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.Passes.All.DownloadDvmRepository;
import _VisualDVM.Passes.All.DownloadDvmTestsRepository;
import _VisualDVM.Passes.All.ZipFolderPass;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.Files.ProjectFile;
@@ -295,14 +295,19 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}).start();
}
void PerformAutoSapforTesting() throws Exception {
int sapforId = Integer.parseInt(request.arg);
if (!db.serverSapfors.containsKey(sapforId)) {
throw new RepositoryRefuseException("Версия SAPFOR " + sapforId + " не существует.");
}
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
TextLog Log = new TextLog();
SapforPackage autoPackage = tryAutoSapforTesting(Log);
SapforPackage autoPackage = tryAutoSapforTesting(sapfor,Log);
EmailMessage message = Log.isEmpty() ?
new EmailMessage(
"Запущено автоматическое тестирование версии " + request.arg + " системы SAPFOR",
"Запущено автоматическое тестирование версии " + sapfor.version + " системы SAPFOR",
"Пакет " + Utils_.Brackets(autoPackage.id)) :
new EmailMessage(
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
"Не удалось запустить автоматическое тестирование версии " + sapfor.version + " системы SAPFOR",
Log.toString()
);
for (String address : Constants.admins_mails)
@@ -350,14 +355,14 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
void RefreshDVMTests() throws Exception {
UserAccount account = new UserAccount("server", Constants.MailAddress);
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
DownloadDvmRepository downloadRepository = new DownloadDvmRepository();
DownloadDvmTestsRepository downloadRepository = new DownloadDvmTestsRepository();
if (!downloadRepository.Do())
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
//-->>
Vector<Pair<Group, Vector<File>>> groups = new Vector<>();
File testsSrc = Paths.get(
Global.RepoDirectory.getAbsolutePath(),
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
"dvm-auto-test", "test-suite").toFile();
LanguageName[] supportedLanguages = new LanguageName[]{LanguageName.fortran, LanguageName.c};
for (LanguageName languageName : supportedLanguages) {
for (TestType testType : TestType.values()) {
@@ -606,21 +611,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
response.object = serverSapfor;
}
SapforPackage tryAutoSapforTesting(TextLog Log) throws Exception {
SapforPackage tryAutoSapforTesting(ServerSapfor sapfor, TextLog Log) throws Exception {
//--
UserAccount account = new UserAccount();
account.name = "server";
account.email = Constants.MailAddress;
account.role = AccountRole.Admin;
//-
int sapforId = Integer.parseInt(request.arg);
if (!db.serverSapfors.containsKey(sapforId)) {
Log.Writeln_("Версия SAPFOR " + sapforId + " не существует.");
return null;
}
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
if (!sapfor.state.equals(ServerSapforState.Done)) {
Log.Writeln_("Выбранная версия SAPFOR " + sapforId + " не собрана!");
Log.Writeln_("Выбранная версия SAPFOR " + sapfor.version + " не собрана!");
return null;
}
Vector<SapforConfiguration> configurations = db.sapforConfigurations.getAutoConfigurations();

View File

@@ -4,6 +4,7 @@ import Common.Utils.TextLog;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.Component.Sapfor.Sapfor;
import _VisualDVM.*;
import _VisualDVM.Passes.All.DownloadSapforRepository;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.Repository.EmailMessage;
import _VisualDVM.Repository.Server.ServerCode;
@@ -233,14 +234,6 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
sapfor.state = state_in;
ServerCommand(ServerCode.EditObject, sapfor);
}
void SyncronizeRepository() throws Exception {
UpdateSapforState(ServerSapforState.SAPFORRepositorySynchronization);
Utils.CleanDirectory(repo);
Utils.startScript(repo, repo, "git_clone",
"git clone " + Constants.SAPFOR_REPOSITORY + " " + Utils_.DQuotes(repo_sapfor) + " 1>spf_out.txt 2>spf_err.txt\n" +
"cd " + Utils_.DQuotes(repo_sapfor) + "\n"+
"GIT_SSL_NO_VERIFY=true git submodule update --init\n").waitFor();
}
void CompileSapfor() throws Exception {
UpdateSapforState(ServerSapforState.Compilation);
//-
@@ -263,7 +256,10 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
max_version = CommonConstants.Nan;
current_version = CommonConstants.Nan;
//--
SyncronizeRepository();
UpdateSapforState(ServerSapforState.SAPFORRepositorySynchronization);
DownloadSapforRepository pass = new DownloadSapforRepository();
pass.Do();
//-
max_version = (int) ServerCommand(ServerCode.GetMaxSapforVersion);
current_version = Sapfor.readVersionFromCode(Paths.get(repo.getAbsolutePath(),
"/SAPFOR/src/Utils/version.h").toFile());