chore: simplify and use docker for production testing
This commit is contained in:
parent
6d14e5c2aa
commit
11160b879f
3 changed files with 53 additions and 24 deletions
18
Makefile
18
Makefile
|
|
@ -20,32 +20,32 @@ build:
|
||||||
|
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
docker-build: build
|
docker-build: build
|
||||||
podman build -t ${FULL_IMAGE_NAME} .
|
docker build -t ${FULL_IMAGE_NAME} .
|
||||||
|
|
||||||
# Run the container in detached mode.
|
# Run the container in detached mode.
|
||||||
# It will first stop and remove any existing container with the same name.
|
# It will first stop and remove any existing container with the same name.
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: docker-build
|
run: docker-build
|
||||||
@echo "Stopping and removing old container if it exists..."
|
@echo "Stopping and removing old container if it exists..."
|
||||||
# -podman stop ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
# -docker stop ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
||||||
# -podman rm ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
# -docker rm ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
||||||
podman-compose stop
|
docker-compose stop
|
||||||
@echo "Starting new container '${CONTAINER_NAME}' on http://localhost:8080"
|
@echo "Starting new container '${CONTAINER_NAME}' on http://localhost:8080"
|
||||||
podman-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
.PHONY: stop
|
.PHONY: stop
|
||||||
stop:
|
stop:
|
||||||
@echo "Stopping and removing container: ${CONTAINER_NAME}"
|
@echo "Stopping and removing container: ${CONTAINER_NAME}"
|
||||||
# -podman stop ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
# -docker stop ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
||||||
# -podman rm ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
# -docker rm ${CONTAINER_NAME} > /dev/null 2>&1 || true
|
||||||
podman-compose stop > /dev/null 2>&1 || true
|
docker-compose stop > /dev/null 2>&1 || true
|
||||||
|
|
||||||
|
|
||||||
# --- Submission Target ---
|
# --- Submission Target ---
|
||||||
|
|
||||||
.PHONY: save
|
.PHONY: save
|
||||||
save: docker-build
|
save: docker-build
|
||||||
podman save -o ${SUBMISSION_FILE} ${FULL_IMAGE_NAME}
|
docker save -o ${SUBMISSION_FILE} ${FULL_IMAGE_NAME}
|
||||||
@echo "Submission file '${SUBMISSION_FILE}' created successfully."
|
@echo "Submission file '${SUBMISSION_FILE}' created successfully."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1760524057,
|
||||||
|
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,9 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@WebMvcTest(ApiController.class)
|
@WebMvcTest(ApiController.class)
|
||||||
|
|
@ -44,8 +47,8 @@ public class ApiControllerTest {
|
||||||
String endpoint = "/api/v1/uid";
|
String endpoint = "/api/v1/uid";
|
||||||
String expected = "s2522255";
|
String expected = "s2522255";
|
||||||
var mock = mockMvc.perform(get(endpoint));
|
var mock = mockMvc.perform(get(endpoint));
|
||||||
mock.andExpect(MockMvcResultMatchers.status().isOk());
|
mock.andExpect(status().isOk());
|
||||||
mock.andExpect(MockMvcResultMatchers.content().string(expected));
|
mock.andExpect(content().string(expected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,8 +70,8 @@ public class ApiControllerTest {
|
||||||
.content(objectMapper.writeValueAsString(req)));
|
.content(objectMapper.writeValueAsString(req)));
|
||||||
|
|
||||||
|
|
||||||
mock.andExpect(MockMvcResultMatchers.status().isOk());
|
mock.andExpect(status().isOk());
|
||||||
mock.andExpect(MockMvcResultMatchers.content().string(String.valueOf(expected)));
|
mock.andExpect(content().string(String.valueOf(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -88,7 +91,7 @@ public class ApiControllerTest {
|
||||||
var mock = mockMvc.perform(post(endpoint)
|
var mock = mockMvc.perform(post(endpoint)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(req))
|
.content(req))
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,8 +115,8 @@ public class ApiControllerTest {
|
||||||
.content(objectMapper.writeValueAsString(req)));
|
.content(objectMapper.writeValueAsString(req)));
|
||||||
|
|
||||||
|
|
||||||
mock.andExpect(MockMvcResultMatchers.status().isOk());
|
mock.andExpect(status().isOk());
|
||||||
mock.andExpect(MockMvcResultMatchers.content().string(String.valueOf(expected)));
|
mock.andExpect(content().string(String.valueOf(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -127,7 +130,7 @@ public class ApiControllerTest {
|
||||||
mockMvc.perform(post("/api/v1/isCloseTo")
|
mockMvc.perform(post("/api/v1/isCloseTo")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(malformedJson))
|
.content(malformedJson))
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -150,9 +153,8 @@ public class ApiControllerTest {
|
||||||
.content(objectMapper.writeValueAsString(req)));
|
.content(objectMapper.writeValueAsString(req)));
|
||||||
|
|
||||||
|
|
||||||
mock.andExpect(MockMvcResultMatchers.status().isOk());
|
mock.andExpect(status().isOk());
|
||||||
mock.andExpect(MockMvcResultMatchers.content().json(
|
mock.andExpect(content().json(objectMapper.writeValueAsString(expected)));
|
||||||
objectMapper.writeValueAsString(expected)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,8 +198,8 @@ public class ApiControllerTest {
|
||||||
.content(objectMapper.writeValueAsString(req)));
|
.content(objectMapper.writeValueAsString(req)));
|
||||||
|
|
||||||
|
|
||||||
mock.andExpect(MockMvcResultMatchers.status().isOk());
|
mock.andExpect(status().isOk());
|
||||||
mock.andExpect(MockMvcResultMatchers.content().string(String.valueOf(expected)));
|
mock.andExpect(content().string(String.valueOf(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -211,7 +213,7 @@ public class ApiControllerTest {
|
||||||
mockMvc.perform(post("/api/v1/isInRegion")
|
mockMvc.perform(post("/api/v1/isInRegion")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(objectMapper.writeValueAsString(request)))
|
.content(objectMapper.writeValueAsString(request)))
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -231,7 +233,7 @@ public class ApiControllerTest {
|
||||||
mockMvc.perform(post("/api/v1/isInRegion")
|
mockMvc.perform(post("/api/v1/isInRegion")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(objectMapper.writeValueAsString(request)))
|
.content(objectMapper.writeValueAsString(request)))
|
||||||
.andExpect(MockMvcResultMatchers.status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue