Make tests work again.
This commit is contained in:
parent
c79d678a2a
commit
c716e32534
3 changed files with 127 additions and 16 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
apiVersion: "vmoperator.jdrupes.org/v1"
|
apiVersion: "vmoperator.jdrupes.org/v1"
|
||||||
kind: VirtualMachine
|
kind: VirtualMachine
|
||||||
metadata:
|
metadata:
|
||||||
namespace: vmop-dev
|
namespace: vmop-test
|
||||||
name: unittest-vm
|
name: test-vm
|
||||||
spec:
|
spec:
|
||||||
image:
|
image:
|
||||||
repository: docker-registry.lan.mnl.de
|
repository: docker-registry.lan.mnl.de
|
||||||
|
|
|
||||||
111
org.jdrupes.vmoperator.manager/test-resources/kustomization.yaml
Normal file
111
org.jdrupes.vmoperator.manager/test-resources/kustomization.yaml
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- ../../deploy
|
||||||
|
|
||||||
|
namespace: vmop-test
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- patch: |-
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: vmop-image-repository
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
storageClassName: local-path
|
||||||
|
|
||||||
|
- patch: |-
|
||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: vm-operator
|
||||||
|
data:
|
||||||
|
# Keep in sync with config.yaml
|
||||||
|
config.yaml: |
|
||||||
|
"/Manager":
|
||||||
|
# clusterName: "test"
|
||||||
|
"/Controller":
|
||||||
|
"/Reconciler":
|
||||||
|
runnerData:
|
||||||
|
storageClassName: null
|
||||||
|
loadBalancerService:
|
||||||
|
labels:
|
||||||
|
label1: label1
|
||||||
|
label2: toBeReplaced
|
||||||
|
annotations:
|
||||||
|
metallb.universe.tf/loadBalancerIPs: 192.168.168.1
|
||||||
|
metallb.universe.tf/ip-allocated-from-pool: single-common
|
||||||
|
metallb.universe.tf/allow-shared-ip: single-common
|
||||||
|
"/GuiSocketServer":
|
||||||
|
port: 8888
|
||||||
|
"/GuiHttpServer":
|
||||||
|
# This configures the GUI
|
||||||
|
"/ConsoleWeblet":
|
||||||
|
"/WebConsole":
|
||||||
|
"/LoginConlet":
|
||||||
|
users:
|
||||||
|
- name: admin
|
||||||
|
fullName: Administrator
|
||||||
|
password: "$2b$05$NiBd74ZGdplLC63ePZf1f.UtjMKkbQ23cQoO2OKOFalDBHWAOy21."
|
||||||
|
- name: test1
|
||||||
|
fullName: Test Account
|
||||||
|
password: "$2b$05$hZaI/jToXf/d3BctZdT38Or7H7h6Pn2W3WiB49p5AyhDHFkkYCvo2"
|
||||||
|
- name: test2
|
||||||
|
fullName: Test Account
|
||||||
|
password: "$2b$05$hZaI/jToXf/d3BctZdT38Or7H7h6Pn2W3WiB49p5AyhDHFkkYCvo2"
|
||||||
|
- name: test3
|
||||||
|
fullName: Test Account
|
||||||
|
password: "$2b$05$hZaI/jToXf/d3BctZdT38Or7H7h6Pn2W3WiB49p5AyhDHFkkYCvo2"
|
||||||
|
"/RoleConfigurator":
|
||||||
|
rolesByUser:
|
||||||
|
# User admin has role admin
|
||||||
|
admin:
|
||||||
|
- admin
|
||||||
|
test1:
|
||||||
|
- user
|
||||||
|
test2:
|
||||||
|
- user
|
||||||
|
test3:
|
||||||
|
- user
|
||||||
|
# All users have role other
|
||||||
|
"*":
|
||||||
|
- other
|
||||||
|
replace: false
|
||||||
|
"/RoleConletFilter":
|
||||||
|
conletTypesByRole:
|
||||||
|
# Admins can use all conlets
|
||||||
|
admin:
|
||||||
|
- "*"
|
||||||
|
user:
|
||||||
|
- org.jdrupes.vmoperator.vmviewer.VmViewer
|
||||||
|
# Others cannot use any conlet (except login conlet to log out)
|
||||||
|
other:
|
||||||
|
- org.jgrapes.webconlet.locallogin.LoginConlet
|
||||||
|
"/ComponentCollector":
|
||||||
|
"/VmAccess":
|
||||||
|
displayResource:
|
||||||
|
preferredIpVersion: ipv4
|
||||||
|
syncPreviewsFor:
|
||||||
|
- role: user
|
||||||
|
- target:
|
||||||
|
group: apps
|
||||||
|
version: v1
|
||||||
|
kind: Deployment
|
||||||
|
name: vm-operator
|
||||||
|
patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/image
|
||||||
|
value: docker-registry.lan.mnl.de/vmoperator/org.jdrupes.vmoperator.manager:test
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/imagePullPolicy
|
||||||
|
value: Always
|
||||||
|
- op: replace
|
||||||
|
path: /spec/replicas
|
||||||
|
value: 0
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ class BasicTests {
|
||||||
private static APIResource vmsContext;
|
private static APIResource vmsContext;
|
||||||
private static K8sV1DeploymentStub mgrDeployment;
|
private static K8sV1DeploymentStub mgrDeployment;
|
||||||
private static K8sDynamicStub vmStub;
|
private static K8sDynamicStub vmStub;
|
||||||
private static final String VM_NAME = "unittest-vm";
|
private static final String VM_NAME = "test-vm";
|
||||||
private static final Object EXISTS = new Object();
|
private static final Object EXISTS = new Object();
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
|
|
@ -54,7 +54,7 @@ class BasicTests {
|
||||||
|
|
||||||
// Update manager pod by scaling deployment
|
// Update manager pod by scaling deployment
|
||||||
mgrDeployment
|
mgrDeployment
|
||||||
= K8sV1DeploymentStub.get(client, "vmop-dev", "vm-operator");
|
= K8sV1DeploymentStub.get(client, "vmop-test", "vm-operator");
|
||||||
mgrDeployment.scale(0);
|
mgrDeployment.scale(0);
|
||||||
mgrDeployment.scale(1);
|
mgrDeployment.scale(1);
|
||||||
waitForManager();
|
waitForManager();
|
||||||
|
|
@ -65,13 +65,13 @@ class BasicTests {
|
||||||
vmsContext = apiRes.get();
|
vmsContext = apiRes.get();
|
||||||
|
|
||||||
// Cleanup existing VM
|
// Cleanup existing VM
|
||||||
K8sDynamicStub.get(client, vmsContext, "vmop-dev", VM_NAME)
|
K8sDynamicStub.get(client, vmsContext, "vmop-test", VM_NAME)
|
||||||
.delete();
|
.delete();
|
||||||
ListOptions listOpts = new ListOptions();
|
ListOptions listOpts = new ListOptions();
|
||||||
listOpts.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
listOpts.setLabelSelector("app.kubernetes.io/name=" + APP_NAME + ","
|
||||||
+ "app.kubernetes.io/instance=" + VM_NAME + ","
|
+ "app.kubernetes.io/instance=" + VM_NAME + ","
|
||||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
||||||
var secrets = K8sV1SecretStub.list(client, "vmop-dev", listOpts);
|
var secrets = K8sV1SecretStub.list(client, "vmop-test", listOpts);
|
||||||
for (var secret : secrets) {
|
for (var secret : secrets) {
|
||||||
secret.delete();
|
secret.delete();
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ class BasicTests {
|
||||||
"app.kubernetes.io/managed-by=" + VM_OP_NAME + ","
|
"app.kubernetes.io/managed-by=" + VM_OP_NAME + ","
|
||||||
+ "app.kubernetes.io/name=" + APP_NAME + ","
|
+ "app.kubernetes.io/name=" + APP_NAME + ","
|
||||||
+ "app.kubernetes.io/instance=" + VM_NAME);
|
+ "app.kubernetes.io/instance=" + VM_NAME);
|
||||||
var knownPvcs = K8sV1PvcStub.list(client, "vmop-dev", listOpts);
|
var knownPvcs = K8sV1PvcStub.list(client, "vmop-test", listOpts);
|
||||||
for (var pvc : knownPvcs) {
|
for (var pvc : knownPvcs) {
|
||||||
pvc.delete();
|
pvc.delete();
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ class BasicTests {
|
||||||
@AfterAll
|
@AfterAll
|
||||||
static void tearDownAfterClass() throws Exception {
|
static void tearDownAfterClass() throws Exception {
|
||||||
// Cleanup
|
// Cleanup
|
||||||
K8sDynamicStub.get(client, vmsContext, "vmop-dev", VM_NAME)
|
K8sDynamicStub.get(client, vmsContext, "vmop-test", VM_NAME)
|
||||||
.delete();
|
.delete();
|
||||||
deletePvcs();
|
deletePvcs();
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ class BasicTests {
|
||||||
void testConfigMap()
|
void testConfigMap()
|
||||||
throws IOException, InterruptedException, ApiException {
|
throws IOException, InterruptedException, ApiException {
|
||||||
K8sV1ConfigMapStub stub
|
K8sV1ConfigMapStub stub
|
||||||
= K8sV1ConfigMapStub.get(client, "vmop-dev", VM_NAME);
|
= K8sV1ConfigMapStub.get(client, "vmop-test", VM_NAME);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -134,7 +134,7 @@ class BasicTests {
|
||||||
// Check config map
|
// Check config map
|
||||||
var config = stub.model().get();
|
var config = stub.model().get();
|
||||||
Map<List<? extends Object>, Object> toCheck = Map.of(
|
Map<List<? extends Object>, Object> toCheck = Map.of(
|
||||||
List.of("namespace"), "vmop-dev",
|
List.of("namespace"), "vmop-test",
|
||||||
List.of("name"), VM_NAME,
|
List.of("name"), VM_NAME,
|
||||||
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
List.of("labels", "app.kubernetes.io/name"), Constants.APP_NAME,
|
||||||
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
List.of("labels", "app.kubernetes.io/instance"), VM_NAME,
|
||||||
|
|
@ -191,7 +191,7 @@ class BasicTests {
|
||||||
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
+ "app.kubernetes.io/component=" + DisplaySecret.NAME);
|
||||||
Collection<K8sV1SecretStub> secrets = null;
|
Collection<K8sV1SecretStub> secrets = null;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
secrets = K8sV1SecretStub.list(client, "vmop-dev", listOpts);
|
secrets = K8sV1SecretStub.list(client, "vmop-test", listOpts);
|
||||||
if (secrets.size() > 0) {
|
if (secrets.size() > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ class BasicTests {
|
||||||
@Test
|
@Test
|
||||||
void testRunnerPvc() throws ApiException, InterruptedException {
|
void testRunnerPvc() throws ApiException, InterruptedException {
|
||||||
var stub
|
var stub
|
||||||
= K8sV1PvcStub.get(client, "vmop-dev", VM_NAME + "-runner-data");
|
= K8sV1PvcStub.get(client, "vmop-test", VM_NAME + "-runner-data");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -227,7 +227,7 @@ class BasicTests {
|
||||||
@Test
|
@Test
|
||||||
void testSystemDiskPvc() throws ApiException, InterruptedException {
|
void testSystemDiskPvc() throws ApiException, InterruptedException {
|
||||||
var stub
|
var stub
|
||||||
= K8sV1PvcStub.get(client, "vmop-dev", VM_NAME + "-system-disk");
|
= K8sV1PvcStub.get(client, "vmop-test", VM_NAME + "-system-disk");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -248,7 +248,7 @@ class BasicTests {
|
||||||
@Test
|
@Test
|
||||||
void testDisk1Pvc() throws ApiException, InterruptedException {
|
void testDisk1Pvc() throws ApiException, InterruptedException {
|
||||||
var stub
|
var stub
|
||||||
= K8sV1PvcStub.get(client, "vmop-dev", VM_NAME + "-disk-1");
|
= K8sV1PvcStub.get(client, "vmop-test", VM_NAME + "-disk-1");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -274,7 +274,7 @@ class BasicTests {
|
||||||
new V1Patch("[{\"op\": \"replace\", \"path\": \"/spec/vm/state"
|
new V1Patch("[{\"op\": \"replace\", \"path\": \"/spec/vm/state"
|
||||||
+ "\", \"value\": \"Running\"}]"),
|
+ "\", \"value\": \"Running\"}]"),
|
||||||
client.defaultPatchOptions()).isPresent());
|
client.defaultPatchOptions()).isPresent());
|
||||||
var stub = K8sV1PodStub.get(client, "vmop-dev", VM_NAME);
|
var stub = K8sV1PodStub.get(client, "vmop-test", VM_NAME);
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -303,7 +303,7 @@ class BasicTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadBalancer() throws ApiException, InterruptedException {
|
public void testLoadBalancer() throws ApiException, InterruptedException {
|
||||||
var stub = K8sV1ServiceStub.get(client, "vmop-dev", VM_NAME);
|
var stub = K8sV1ServiceStub.get(client, "vmop-test", VM_NAME);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (stub.model().isPresent()) {
|
if (stub.model().isPresent()) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue