Skip to content

Commit

Permalink
merged from main
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemosalamy committed May 19, 2024
2 parents 6db364e + e7e8b1f commit f44cd22
Show file tree
Hide file tree
Showing 121 changed files with 2,993 additions and 421 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ jobs:
run: mvn -DskipTests -B install --file pom.xml

- name: Check Formatting
run: mvn -DskipTests verify
run: mvn -DskipTests -B verify

- name: Check Jobs Tests
run: cd services/jobs && mvn test

- name: Check Users Tests
run: cd services/users && mvn test

- name: Check Payments Tests
run: cd services/payments && mvn test
- name: Check Tests
run: mvn -B test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Submit Dependency Snapshot
uses: advanced-security/maven-dependency-submission-action@v3
4 changes: 2 additions & 2 deletions autoscaler/docker-swarm-autoscaler/auto-scale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ main () {

main
while [[ $LOOP == 'yes' ]]; do
echo Waiting 5 seconds for the next test
sleep 5s
echo Waiting 30 seconds for the next test
sleep 30s
main
done
4 changes: 2 additions & 2 deletions autoscaler/prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_interval: 10s
evaluation_interval: 10s

scrape_configs:
- job_name: 'prometheus'
Expand Down
40 changes: 40 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
image: rabbitmq:3.13-management
ports:
- "5672:5672" # hacky method.. dont ever do this :(
- "15672:15672"
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
Expand All @@ -40,6 +41,10 @@ services:
networks:
- default
- frontend
labels:
com.datadoghq.ad.check_names: '["rabbitmq"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"prometheus_plugin": {"url": "http://service_mq:15692"}}]'

service_redis:
image: redis:7.2.4
Expand All @@ -50,6 +55,41 @@ services:
retries: 3
networks:
- default
labels:
com.datadoghq.ad.check_names: '["redisdb"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host": "service_redis","port":"6379"}]'

service_datadog:
image: gcr.io/datadoghq/agent:latest
deploy:
mode: global
networks:
- default
environment:
DD_API_KEY: 26913604f1968f188b5ca541aa58e092
DD_SYSTEM_PROBE_NETWORK_ENABLED: "true"
DD_PROCESS_AGENT_ENABLED: "true"
DD_SITE: us5.datadoghq.com
DD_LOGS_ENABLED: "true"
DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: "true"
DD_CONTAINER_EXCLUDE: "name:datadog-agent"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
- /sys/kernel/debug:/sys/kernel/debug
security_opt:
- apparmor:unconfined
cap_add:
- SYS_ADMIN
- SYS_RESOURCE
- SYS_PTRACE
- NET_ADMIN
- NET_BROADCAST
- NET_RAW
- IPC_LOCK
- CHOWN

# ----- JOBS MICROSERVICE -------
service_jobs:
Expand Down
37 changes: 31 additions & 6 deletions controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,41 @@
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.testcontainers</groupId>
<artifactId>cassandra</artifactId>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.workup</groupId>
<artifactId>contracts</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.workup</groupId>
<artifactId>payments</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.workup</groupId>
<artifactId>users</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down
44 changes: 15 additions & 29 deletions controller/src/main/java/com/workup/controller/CLIHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import asg.cliche.CLIException;
import asg.cliche.Command;
import com.workup.shared.commands.controller.*;
import com.workup.shared.commands.jobs.requests.CreateJobRequest;
import com.workup.shared.enums.ControllerQueueNames;
import com.workup.shared.enums.ServiceQueueNames;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -31,9 +29,6 @@ public String maxThreads(String app, int maxThreads) throws CLIException {
if (!appQueueMap.containsKey(app)) {
return "Error: app can only be jobs, users, contracts or payments!";
}
if (maxThreads > 100 || maxThreads < 1) {
return "Error: Max threads must have a value between 1 and 50";
}
rabbitTemplate.convertAndSend(
appQueueMap.get(app),
"",
Expand All @@ -57,6 +52,11 @@ public String maxdb(String app, int maxDBConn) {
return "Command Sent!";
}

@Command(description = "Adds a new command")
public String addCommand(String app, String commandName, String className) throws Exception {
return updateCommand(app, commandName, className);
}

@Command(description = "starts a specific app")
public String start(String app) {
app = app.toLowerCase();
Expand All @@ -78,12 +78,7 @@ public String freeze(String app) {
return "Command sent";
}

@Command(description = "stops a specific app")
public String setmq(String app, int appNum) {
return "setmq";
}

@Command(description = "stops a specific app")
@Command(description = "sets a logging level")
public String setLoggingLevel(String app, String level) {
app = app.toLowerCase();
if (!appQueueMap.containsKey(app)) {
Expand All @@ -96,17 +91,6 @@ public String setLoggingLevel(String app, String level) {
return "Command sent!!";
}

@Command(description = "test")
public void test() {
CreateJobRequest request = CreateJobRequest.builder().withTitle("Ziko").build();
rabbitTemplate.convertSendAndReceive(ServiceQueueNames.JOBS, request);
}

@Command(description = "Creates a new command")
public String addcommand(String app, String commandName, String className) {
return "Add command";
}

@Command(description = "Updates an existing command")
public String updateCommand(String app, String commandName, String className) throws Exception {
app = app.toLowerCase();
Expand All @@ -120,6 +104,7 @@ public String updateCommand(String app, String commandName, String className) th
"",
UpdateCommandRequest.builder()
.withCommandName(commandName)
.withClassName(className)
.withByteCode(byteArray)
.build());
} catch (Exception ex) {
Expand All @@ -142,12 +127,13 @@ private byte[] getByteCode(String commandName, String className)
}

@Command(description = "Deletes an existing command")
public String deletecommand(String app, String commandName, String className) {
return "Delete command";
}

@Command(description = "stops a specific app")
public String updateClass(String app, int appNum) {
return "update class";
public String deleteCommand(String app, String commandName) {
app = app.toLowerCase();
if (!appQueueMap.containsKey(app)) {
return "Error: app can only be jobs, users, contracts or payments!";
}
rabbitTemplate.convertAndSend(
appQueueMap.get(app), "", DeleteCommandRequest.builder().commandName(commandName).build());
return "Command sent";
}
}
2 changes: 1 addition & 1 deletion controller/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spring.application.name=controller
spring.rabbitmq.host=localhost
spring.rabbitmq.host=46.101.90.9
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
20 changes: 20 additions & 0 deletions services/contracts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.workup.contracts.logger.LoggingLevel;
import com.workup.shared.enums.ControllerQueueNames;
import com.workup.shared.enums.ServiceQueueNames;
import com.workup.shared.enums.ThreadPoolSize;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.AnonymousQueue;
import org.springframework.amqp.core.Binding;
Expand Down Expand Up @@ -71,8 +72,9 @@ public Binding fanoutBinding(FanoutExchange fanout, Queue controllerQueue) {
@Bean
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(50);
executor.setMaxPoolSize(50);
executor.setCorePoolSize(ThreadPoolSize.POOL_SIZE);
executor.setMaxPoolSize(ThreadPoolSize.POOL_SIZE);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("contracts-");
executor.initialize();
Expand Down
Loading

0 comments on commit f44cd22

Please sign in to comment.