рефакторинг сборки Сапфора. Перевел ее в планировщик задач тестирования сапфора. осталось при проверке бд это отобразить.
This commit is contained in:
3
.idea/workspace.xml
generated
3
.idea/workspace.xml
generated
@@ -8,6 +8,9 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestsDatabase.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTestingPlanner.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforTestingPlanner.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -86,5 +86,7 @@ public enum ServerCode {
|
|||||||
GetFirstActiveDVMPackageForMachineURL,
|
GetFirstActiveDVMPackageForMachineURL,
|
||||||
GetServerName,
|
GetServerName,
|
||||||
StartNecessaryMachines,
|
StartNecessaryMachines,
|
||||||
GetSapforForCompilation;
|
GetSapforForCompilation,
|
||||||
|
GetMaxSapforVersion
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,6 +244,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
Print("Получить первую активную версию Sapfor для сборки");
|
Print("Получить первую активную версию Sapfor для сборки");
|
||||||
GetSapforForCompilation();
|
GetSapforForCompilation();
|
||||||
break;
|
break;
|
||||||
|
case GetMaxSapforVersion:
|
||||||
|
Print("Получить максимальную установленную версию Sapfor");
|
||||||
|
GetSapforMaxVersion();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
||||||
}
|
}
|
||||||
@@ -333,6 +337,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
response.object = db.getSapforCopyForCompilation();
|
response.object = db.getSapforCopyForCompilation();
|
||||||
}
|
}
|
||||||
|
void GetSapforMaxVersion() throws Exception{
|
||||||
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
|
response.object = db.getInstalledSapforMaxVersion();
|
||||||
|
}
|
||||||
void UpdateActiveDVMPackages() throws Exception {
|
void UpdateActiveDVMPackages() throws Exception {
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
||||||
|
|||||||
@@ -284,4 +284,20 @@ public class TestsDatabase extends SQLiteDatabase {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Integer getInstalledSapforMaxVersion() {
|
||||||
|
int max_version=Constants.Nan;
|
||||||
|
|
||||||
|
for (ServerSapfor sapfor : serverSapfors.Data.values()) {
|
||||||
|
if (sapfor.state.equals(ServerSapforState.Done)) {
|
||||||
|
int version=Constants.Nan;
|
||||||
|
try {
|
||||||
|
version = Integer.parseInt(sapfor.version);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
if (version > max_version) max_version = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max_version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import Common.Current;
|
|||||||
import Common.Global;
|
import Common.Global;
|
||||||
import Common.GlobalProperties;
|
import Common.GlobalProperties;
|
||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
|
import ProjectData.LanguageName;
|
||||||
|
import Repository.RepositoryRefuseException;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import TestingSystem.Common.TasksPackageState;
|
import TestingSystem.Common.TasksPackageState;
|
||||||
|
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||||
import TestingSystem.Common.TestingPlanner;
|
import TestingSystem.Common.TestingPlanner;
|
||||||
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
||||||
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
||||||
@@ -13,18 +16,23 @@ import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
|||||||
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||||
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||||
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
||||||
|
import javafx.util.Pair;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||||
File workspace;
|
File workspace;
|
||||||
ServerSapfor sapfor;
|
ServerSapfor sapfor;
|
||||||
//--
|
//--
|
||||||
File repo;
|
File repo;
|
||||||
File repoSapforHome;
|
File repoSapforHome;
|
||||||
|
int max_version;
|
||||||
|
int current_version;
|
||||||
|
//--
|
||||||
File repo_bin;
|
File repo_bin;
|
||||||
File repo_out;
|
File repo_out;
|
||||||
File repo_err;
|
File repo_err;
|
||||||
@@ -205,14 +213,51 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
|||||||
Constants.err_file +
|
Constants.err_file +
|
||||||
"\n").waitFor();
|
"\n").waitFor();
|
||||||
}
|
}
|
||||||
|
int getSapforRepositoryVersion() throws Exception {
|
||||||
|
int res = Constants.Nan;
|
||||||
|
File versionFile = Paths.get(repo.getAbsolutePath(), "/sapfor/experts/Sapfor_2017/_src/Utils/version.h").toFile();
|
||||||
|
if (versionFile.exists()) {
|
||||||
|
List<String> data = FileUtils.readLines(versionFile);
|
||||||
|
for (String s : data) {
|
||||||
|
if (s.startsWith("#define VERSION_SPF ")) {
|
||||||
|
String[] version_data = s.split("\"");
|
||||||
|
if (version_data.length > 0) {
|
||||||
|
String version_s = version_data[1];
|
||||||
|
//-
|
||||||
|
try {
|
||||||
|
res = Integer.parseInt(version_s);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
//--------------------
|
//--------------------
|
||||||
public void checkServerSapforsForCompilation() throws Exception {
|
public void checkServerSapforsForCompilation() throws Exception {
|
||||||
sapfor = null;
|
sapfor = null;
|
||||||
getServerSapforForCompilation();
|
getServerSapforForCompilation();
|
||||||
if (sapfor != null) {
|
if (sapfor != null) {
|
||||||
|
//---
|
||||||
|
max_version = Constants.Nan;
|
||||||
|
current_version = Constants.Nan;
|
||||||
|
//--
|
||||||
SyncronizeRepository();
|
SyncronizeRepository();
|
||||||
|
max_version = (int) ServerCommand(ServerCode.GetMaxSapforVersion);
|
||||||
|
current_version = getSapforRepositoryVersion();
|
||||||
|
if (current_version==max_version){
|
||||||
|
System.out.println("Версия SAPFOR " + max_version + " уже собрана!");
|
||||||
|
ServerCommand(ServerCode.DeleteObjectByPK, new Pair(ServerSapfor.class,sapfor.id));
|
||||||
|
return;
|
||||||
|
}
|
||||||
//-
|
//-
|
||||||
File sapforHome = new File(Global.SapforsDirectory, Utils.getDateName("sapfor"));
|
File sapforHome = new File(Global.SapforsDirectory, Utils.getDateName("sapfor"));
|
||||||
|
//--
|
||||||
|
sapfor.home_path = sapforHome.getAbsolutePath();
|
||||||
|
sapfor.languageName = LanguageName.fortran;
|
||||||
|
//--
|
||||||
File sapforBin = new File(sapforHome, "Sapfor_F");
|
File sapforBin = new File(sapforHome, "Sapfor_F");
|
||||||
File sapforOut = new File(sapforHome, Constants.out_file);
|
File sapforOut = new File(sapforHome, Constants.out_file);
|
||||||
File sapforErr = new File(sapforHome, Constants.err_file);
|
File sapforErr = new File(sapforHome, Constants.err_file);
|
||||||
@@ -228,6 +273,11 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
|||||||
System.out.println("Сборка SAPFOR успешно выполнена");
|
System.out.println("Сборка SAPFOR успешно выполнена");
|
||||||
FileUtils.copyFile(repo_bin, sapforBin);
|
FileUtils.copyFile(repo_bin, sapforBin);
|
||||||
sapforBin.setExecutable(true, false);
|
sapforBin.setExecutable(true, false);
|
||||||
|
//--
|
||||||
|
sapfor.version= String.valueOf(current_version);
|
||||||
|
sapfor.call_command = sapforBin.getAbsolutePath();
|
||||||
|
sapfor.buildDate = new Date().getTime();
|
||||||
|
//--
|
||||||
UpdateSapforState(ServerSapforState.Done);
|
UpdateSapforState(ServerSapforState.Done);
|
||||||
} else {
|
} else {
|
||||||
UpdateSapforState(ServerSapforState.DoneWithErrors);
|
UpdateSapforState(ServerSapforState.DoneWithErrors);
|
||||||
|
|||||||
Reference in New Issue
Block a user