Skip to content

Commit

Permalink
Merge pull request #689 from Epic-Breakfast-Productions/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
GregJohnStewart authored Aug 28, 2024
2 parents bc43cd4 + 601cbf4 commit 10d0653
Show file tree
Hide file tree
Showing 29 changed files with 367 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class CoreApiLibDevserviceConfig {
/**
* The version/ tag of the core api container image
*/
@ConfigItem(name="coreApiVersion", defaultValue = "2.1.2")
@ConfigItem(name="coreApiVersion", defaultValue = "2.1.3")
public String coreApiVersion;
}
2 changes: 1 addition & 1 deletion software/oqm-core-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.ebp.openQuarterMaster'
version '2.1.3'
version '2.1.4-DEV'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion software/oqm-core-api/docs/development/Releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ These are the steps to take to perform a release of the software:
4. Ensure everything committed and pushed to github. Check workflows.
5. Be logged into docker hub with ebprod user `docker login`
6. Deploy jvm version
1. Clean/build/push project `./gradlew clean build -Pquarkus.container-image.build=true -Pquarkus.jib.platforms=linux/arm64,linux/amd64 -Pquarkus.container-image.group=ebprod -Pquarkus.container-image.name=oqm-core-api -Pquarkus.container-image.push=true -Pquarkus.jib.base-jvm-image=registry.access.redhat.com/ubi9/openjdk-21-runtime:1.20`
1. Clean/build/push project `./gradlew clean build -Pquarkus.container-image.build=true -Pquarkus.jib.platforms=linux/arm64,linux/amd64 -Pquarkus.container-image.push=true -Pquarkus.jib.base-jvm-image=registry.access.redhat.com/ubi9/openjdk-21-runtime:1.20`
2. Ensure was deployed successfully: https://hub.docker.com/repository/registry-1.docker.io/ebprod/open-qm-base-station/tags?page=1&ordering=last_updated
7. Make installers: `./makeInstallers.sh`
8. Make release for version on Github, attach all installers to it (`build/installers`)
3 changes: 3 additions & 0 deletions software/oqm-core-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ externalService:
quarkus:
application:
name: ${service.nameShort} - V${service.apiVersion}
container-image:
name: oqm-core-api
group: ebprod
log:
level: DEBUG
console:
Expand Down
6 changes: 3 additions & 3 deletions software/oqm-core-base-station/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.ebp.openQuarterMaster'
version '1.4.2'
version '1.4.3'

repositories {
mavenCentral()
Expand All @@ -28,7 +28,7 @@ dependencies {
implementation 'io.quarkus:quarkus-opentelemetry'
implementation 'io.quarkus:quarkus-scheduler'

implementation 'tech.ebp.oqm.lib:core-api-lib-quarkus:2.1.0-SNAPSHOT'
implementation 'tech.ebp.oqm.lib:core-api-lib-quarkus:2.2.0-SNAPSHOT'

implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'org.apache.commons:commons-text:1.12.0'
Expand All @@ -42,7 +42,7 @@ dependencies {
implementation 'org.webjars:bootstrap:5.3.3'

testImplementation 'io.quarkus:quarkus-junit5'
testImplementation "org.junit.jupiter:junit-jupiter-params:5.10.3"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.11.0"
testImplementation 'io.rest-assured:rest-assured'
testImplementation 'net.datafaker:datafaker:2.3.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ const navSearchInput = $('#navSearchInput');
const navSearchForm = $('#navSearchForm');
const navSearchTypeSelect = $('#navSearchTypeSelect');

navSearchTypeSelect.on("change", function(event){
console.log(
"Changing nav form to " +
"action: " + navSearchTypeSelect[0].options[event.target.selectedIndex].dataset.action +
" with fieldName: " + navSearchTypeSelect[0].options[event.target.selectedIndex].dataset.field
);
navSearchForm.attr("action", navSearchTypeSelect[0].options[event.target.selectedIndex].dataset.action);
navSearchInput.attr("name", navSearchTypeSelect[0].options[event.target.selectedIndex].dataset.field);
});
function updateNavSearchDestination(action, icon, fieldName){
navSearchForm.attr("action", action);
navSearchTypeSelect.html(icon);
navSearchInput.attr("name", fieldName);
}

TimeHelpers.setupDateTimeInputs();
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ ui:
quarkus:
application:
name: ${service.nameShort} - V${service.apiVersion}
container-image:
name: oqm-core-base_station
group: ebprod
rest-client:
logging:
scope: all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,13 @@

<form class="d-flex me-auto" method="get" action="/items" id="navSearchForm">
<div class="input-group">
<input class="form-control" id="navSearchInput" type="text" placeholder="Search" name="name">
<select class="form-select" id="navSearchTypeSelect" aria-label="Navbar Quick Search search type" style="max-width: 140px;">
<option data-action="/items" data-field="name" selected>Items</option>
<option data-action="/storage" data-field="label">Storage Blocks</option>
</select>
<button class="btn btn-outline-dark" type="submit">{#icons/search}{/icons/search} Search</button>
<input class="form-control" id="navSearchInput" type="text" placeholder="Search" name="name" style="max-width:150px;">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" id="navSearchTypeSelect">{#icons/items}{/icons/items}</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#" onclick="updateNavSearchDestination('/items', Icons.items, 'name')">{#icons/items}{/icons/items} Items</a></li>
<li><a class="dropdown-item" href="#" onclick="updateNavSearchDestination('/storage', Icons.storageBlocks, 'labelOrNickname')">{#icons/storageBlocks}{/icons/storageBlocks} Storage Blocks</a></li>
</ul>
<button class="btn btn-outline-dark" type="submit">{#icons/search}{/icons/search}</button>
</div>
</form>
<ul class="navbar-nav mb-auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
import tech.ebp.oqm.plugin.mssController.devTools.deployment.config.DevModuleConfig;
import tech.ebp.oqm.plugin.mssController.devTools.deployment.config.MssControllerDevtoolBuildTimeConfig;
import tech.ebp.oqm.plugin.mssController.devTools.deployment.testModules.MssTestModule;
import tech.ebp.oqm.plugin.mssController.devTools.deployment.testModules.MssTestSerialModule;
import tech.ebp.oqm.plugin.mssController.lib.command.response.ModuleInfo;

import java.util.*;

class CoreApiLibQuarkusProcessor {

private static final String FEATURE = "mss-controller-devtooling";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

// @BuildStep
// List<RunTimeConfigurationDefaultBuildItem> addRestConfiguration() {
// return List.of(
Expand All @@ -37,27 +38,50 @@ public List<DevServicesResultBuildItem> createContainer(
) {
List<DevServicesResultBuildItem> output = new ArrayList<>();

for(DevModuleConfig curModuleConfig : config.devServices().modules()){
for (DevModuleConfig curModuleConfig : config.devServices().modules()) {
ModuleInfo newModuleInfo = new ModuleInfo(
curModuleConfig.info().specVersion().orElse("1"),
curModuleConfig.info().serialId().orElse(UUID.randomUUID().toString()),
curModuleConfig.info().manufactureDate().orElse("today"),
curModuleConfig.info().numBlocks()
);

MssTestModule testModule = switch (curModuleConfig.type()){
case SERIAL -> null;
MssTestModule<?> testModule = switch (curModuleConfig.type()) {
case SERIAL -> new MssTestSerialModule(newModuleInfo);
case NETWORK -> null;
} ;
};

testModule.start();

// new DevServicesResultBuildItem.RunningDevService()
output.add(new DevServicesResultBuildItem.RunningDevService(
FEATURE,
testModule.getContainerId(),
testModule::close,
testModule.getAppConfig()
)
.toBuildItem()
);

}

// ModuleInfo newModuleInfo = new ModuleInfo(
// "1",
// UUID.randomUUID().toString(),
// "today",
// 5
// );
//
// MssTestModule<?> testModule = new MssTestSerialModule(newModuleInfo);
// testModule.start();
// output.add(new DevServicesResultBuildItem.RunningDevService(
// FEATURE,
// testModule.getContainerId(),
// testModule::close,
// testModule.getAppConfig()
// )
// .toBuildItem()
// );



return List.of();
return output;
}
}
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);
}
}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-scheduler</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
Expand Down
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.");
}
}
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.");
}
}
Loading

0 comments on commit 10d0653

Please sign in to comment.