рефакторинг определения размерности тестов на сервере.

This commit is contained in:
2025-03-06 21:48:51 +03:00
parent 7b81a8bdd0
commit b08242fed4
8 changed files with 146 additions and 207 deletions

View File

@@ -36,12 +36,6 @@ public class TestsForm extends DataSetControlForm<Test> {
return RendererLongCell.class;
}
},
new ColumnInfo<Test>("min_dim") {
@Override
public Object getFieldAt(Test object) {
return object.min_dim;
}
},
new ColumnInfo<Test>("max_dim") {
@Override
public Object getFieldAt(Test object) {

View File

@@ -107,6 +107,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
+ "\nТест будет удален"
);
}
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
} else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object;
//--
@@ -287,6 +288,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
protected void startAdditionalThreads() {
testingThread.start();
}
void PerformAutoSapforTesting() throws Exception {
TextLog Log = new TextLog();
SapforPackage autoPackage = tryAutoSapforTesting(Log);
@@ -337,7 +339,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
return new Pair<>(object, groupFiles);
}
void RefreshDVMTests() throws Exception {
UserAccount account = new UserAccount("server", Constants.MailAddress);
UserAccount account = new UserAccount("server", Constants.MailAddress);
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
DownloadRepository downloadRepository = new DownloadRepository();
if (!downloadRepository.Do())
@@ -379,8 +381,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
groups.sort(Comparator.comparing(o -> o.getKey().description));
//-теперь создать тесты.
//--
for (Pair<Group, Vector<File>> p : groups)
db.RefreshGroup(account, serverSapfor, p);
}
@@ -682,6 +682,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
ZipFolderPass zip = new ZipFolderPass();
//создание тестов.
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
Vector<Test> tests = new Vector<>();
for (String name : versions.keySet()) {
File src = versions.get(name);
@@ -716,27 +717,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
throw new RepositoryRefuseException("Не удалось переписать архив проекта");
}
tests.add(test);
db.DetectTestMinMaxDim(serverSapfor, group, test);
}
}
//определение размерности тестов
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
if (serverSapfor != null) {
File sapfor_copy = Sapfor.getTempCopy(new File(serverSapfor.call_command));
for (Test test : tests) {
try {
Sapfor.getMinMaxDim(sapfor_copy, test.getServerPath(), test);
db.Update(test);
Utils.deleteFilesByExtensions(test.getServerPath(),
"proj", "dep", "jar"
);
File visualiser_data = new File(test.getServerPath(), Constants.data);
FileUtils.forceDelete(visualiser_data);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
//-"sh"
}
void ReplaceDVMPackageJson() throws Exception {
Pair<DVMPackage, byte[]> p = (Pair<DVMPackage, byte[]>) request.object;
@@ -756,27 +739,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
if (!db.tests.containsKey(key))
throw new RepositoryRefuseException("не существует пакета с ключом " + key);
}
//определение размерности тестов
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
if (serverSapfor != null) {
File sapfor_copy = Sapfor.getTempCopy(new File(serverSapfor.call_command));
for (Object key : keys) {
Test test = db.tests.get(key);
Group group = db.groups.get(test.group_id);
if (group.language.equals(LanguageName.fortran)) {
try {
Sapfor.getMinMaxDim(sapfor_copy, test.getServerPath(), test);
db.Update(test);
Utils.deleteFilesByExtensions(test.getServerPath(),
"proj", "dep", "jar"
);
File visualiser_data = new File(test.getServerPath(), Constants.data);
FileUtils.forceDelete(visualiser_data);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
for (Object key : keys) {
Test test = db.tests.get(key);
Group group = db.groups.get(test.group_id);
db.DetectTestMinMaxDim(serverSapfor, group, test);
}
}
void GetDVMPackageCredentials() throws Exception {

View File

@@ -2,7 +2,6 @@ package _VisualDVM.TestingSystem.Common;
import Common.CommonConstants;
import Common.Database.RepositoryRefuseException;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Utils.TextLog;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.Component.Sapfor.Sapfor;
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
@@ -174,6 +173,20 @@ public class TestsDatabase extends SQLiteDatabase {
return res;
}
//--
public void DetectTestMinMaxDim(ServerSapfor serverSapfor, Group group, Test test) throws Exception {
switch (group.language) {
case fortran:
if (serverSapfor != null) {
Sapfor.getTestMinMaxDim_F(new File(serverSapfor.call_command), test);
Update(test);
}
break;
case c:
Sapfor.getTestMinMaxDime_C(test);
Update(test);
break;
}
}
public void SaveTestFromSingleFile(ServerSapfor sapfor, Group group, Test test, File file) throws Exception {
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils_.CheckAndCleanDirectory(testDirectory);
@@ -187,29 +200,10 @@ public class TestsDatabase extends SQLiteDatabase {
//----------->>
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
//---
//Определение размерности
switch (group.language) {
case fortran:
// временная папка для анализа. чтобы не засорять нормальную.
File tempProject = Utils.getTempFileName("test");
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(testDirectory, tempProject);
//--
if (sapfor!=null) {
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
Update(test);
} else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils_.Brackets(test.description));
}
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
Update(test);
break;
}
DetectTestMinMaxDim(sapfor, group, test);
}
//---
//---
public void CreateTestFromSingleFile(UserAccount account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
Test test = new Test();
test.description = testDescription;