-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #689 from Epic-Breakfast-Productions/dev
Dev
- Loading branch information
Showing
29 changed files
with
367 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 46 additions & 5 deletions
51
...java/tech/ebp/oqm/plugin/mssController/devTools/deployment/testModules/MssTestModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,58 @@ | ||
package tech.ebp.oqm.plugin.mssController.devTools.deployment.testModules; | ||
|
||
import tech.ebp.oqm.plugin.mssController.lib.command.MssCommand; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.Network; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerImageName; | ||
import tech.ebp.oqm.plugin.mssController.lib.command.response.ModuleInfo; | ||
|
||
public class MssTestModule { | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
private ModuleInfo moduleInfo; | ||
public abstract class MssTestModule<SELF extends MssTestModule<SELF>> extends GenericContainer<SELF> { | ||
|
||
protected ModuleInfo moduleInfo; | ||
protected Map<String, String> appConfig = new HashMap<>(); | ||
|
||
protected MssTestModule(ModuleInfo moduleInfo) { | ||
super(DockerImageName.parse("ebprod/oqm-plugin-mss_controller-test_module_server:" + ConfigProvider.getConfig().getValue("quarkus.application.version", String.class))); | ||
this.moduleInfo = moduleInfo; | ||
} | ||
|
||
protected MssCommand processCommand(MssCommand command) { | ||
return command;//TODO | ||
static final int PORT = 8123; | ||
|
||
public Map<String, String> getAppConfig() { | ||
return this.appConfig; | ||
} | ||
|
||
|
||
@Override | ||
protected void configure() { | ||
withNetwork(Network.SHARED); | ||
withEnv("quarkus.http.port", ""+PORT); | ||
addEnv("moduleConfig.serialId", this.moduleInfo.getSerialId()); | ||
addEnv("moduleConfig.manufactureDate", this.moduleInfo.getManufactureDate()); | ||
addEnv("moduleConfig.specVersion", this.moduleInfo.getSpecVersion()); | ||
addEnv("moduleConfig.numBlocks", "" + this.moduleInfo.getNumBlocks()); | ||
|
||
addExposedPorts(PORT); | ||
// Tell the dev service how to know the container is ready | ||
waitingFor(Wait.forLogMessage(".*MSS Test Module Server started.*", 1)); | ||
waitingFor(Wait.forHttp("/q/health").forResponsePredicate((String response)->{ | ||
ObjectNode status; | ||
try { | ||
status = (ObjectNode) new ObjectMapper().readTree(response); | ||
} catch(Exception e) { | ||
return false; | ||
} | ||
return status.get("status").asText().equals("UP"); | ||
})); | ||
} | ||
|
||
public Integer getPort() { | ||
return this.getMappedPort(PORT); | ||
} | ||
} |
26 changes: 24 additions & 2 deletions
26
...ech/ebp/oqm/plugin/mssController/devTools/deployment/testModules/MssTestSerialModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
package tech.ebp.oqm.plugin.mssController.devTools.deployment.testModules; | ||
|
||
import org.testcontainers.containers.BindMode; | ||
import org.testcontainers.containers.SelinuxContext; | ||
import tech.ebp.oqm.plugin.mssController.lib.command.response.ModuleInfo; | ||
|
||
public class MssTestSerialModule extends MssTestModule { | ||
protected MssTestSerialModule(ModuleInfo moduleInfo) { | ||
public class MssTestSerialModule extends MssTestModule<MssTestSerialModule> { | ||
private static final String HOST_SERIAL_DIR = "/tmp/oqm/mss-test/serialModules/"; | ||
|
||
public MssTestSerialModule(ModuleInfo moduleInfo) { | ||
super(moduleInfo); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
addEnv("moduleConfig.type", "SERIAL"); | ||
addFileSystemBind( | ||
HOST_SERIAL_DIR, | ||
"/dev/pts/", | ||
BindMode.READ_WRITE, | ||
SelinuxContext.NONE | ||
); | ||
|
||
this.appConfig.put("moduleConfig.serial.scanSerial", "true"); | ||
this.appConfig.put("moduleConfig.serial.scanDir", HOST_SERIAL_DIR); | ||
//TODO:: do? How? even possible? | ||
// addEnv("moduleConfig.serial.modules[0].portPath", "GET"); | ||
|
||
super.configure(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ver/src/main/java/tech/ebp/oqm/plugin/mssController/testModuleServer/ShutdownHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tech.ebp.oqm.plugin.mssController.testModuleServer; | ||
|
||
import io.quarkus.runtime.ShutdownEvent; | ||
import io.quarkus.runtime.StartupEvent; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import lombok.extern.slf4j.Slf4j; | ||
import tech.ebp.oqm.plugin.mssController.testModuleServer.config.ModuleConfig; | ||
import tech.ebp.oqm.plugin.mssController.testModuleServer.interfaces.serial.SerialModuleInterface; | ||
|
||
@Singleton | ||
@Slf4j | ||
public class ShutdownHandler { | ||
@Inject | ||
ModuleConfig moduleConfig; | ||
|
||
@Inject | ||
SerialModuleInterface serialModuleInterface; | ||
|
||
void onEnd( | ||
@Observes | ||
ShutdownEvent ev | ||
) { | ||
log.info("CLOSING test module server: \n\t{} \n\t{} \n\t{}", | ||
this.moduleConfig.type(), | ||
this.moduleConfig.serialId(), | ||
this.moduleConfig.numBlocks() | ||
); | ||
|
||
switch (this.moduleConfig.type()){ | ||
case SERIAL -> { | ||
this.serialModuleInterface.getTestSerialPort().close(); | ||
} | ||
case NETWORK -> { | ||
} | ||
} | ||
|
||
log.info("MSS Test Module Server shutdown."); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...rver/src/main/java/tech/ebp/oqm/plugin/mssController/testModuleServer/StartupHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tech.ebp.oqm.plugin.mssController.testModuleServer; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import lombok.extern.slf4j.Slf4j; | ||
import tech.ebp.oqm.plugin.mssController.testModuleServer.config.ModuleConfig; | ||
import tech.ebp.oqm.plugin.mssController.testModuleServer.interfaces.serial.SerialModuleInterface; | ||
|
||
@Singleton | ||
@Slf4j | ||
public class StartupHandler { | ||
@Inject | ||
ModuleConfig moduleConfig; | ||
|
||
@Inject | ||
SerialModuleInterface serialModuleInterface; | ||
|
||
void onStart( | ||
@Observes | ||
StartupEvent ev | ||
) { | ||
log.info("Starting test module server: \n\t{} \n\t{} \n\t{}", | ||
this.moduleConfig.type(), | ||
this.moduleConfig.serialId(), | ||
this.moduleConfig.numBlocks() | ||
); | ||
|
||
switch (this.moduleConfig.type()){ | ||
case SERIAL -> { | ||
//to ensure initted | ||
this.serialModuleInterface.getTestSerialPort(); | ||
} | ||
case NETWORK -> { | ||
} | ||
} | ||
|
||
log.info("MSS Test Module Server started."); | ||
} | ||
} |
Oops, something went wrong.