Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
User fabric8 cr clients instead of api clients (#2774)
Browse files Browse the repository at this point in the history
  • Loading branch information
kornys committed May 14, 2019
1 parent 6a8c4fa commit 1642a04
Show file tree
Hide file tree
Showing 95 changed files with 5,590 additions and 4,280 deletions.
2 changes: 1 addition & 1 deletion .jenkins/Jenkinsfile-pr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pipeline {
// string(name: 'DEBUG', defaultValue: 'false', description: 'skip post actions')
// }
options {
timeout(time: 10, unit: 'HOURS')
timeout(time: 15, unit: 'HOURS')
ansiColor('xterm')
}
environment {
Expand Down
8 changes: 6 additions & 2 deletions api-model/src/main/java/io/enmasse/address/model/CoreCrd.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018, EnMasse authors.
* Copyright 2018-2019, EnMasse authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.enmasse.address.model;
Expand All @@ -25,14 +25,18 @@ public class CoreCrd {
}

public static void registerCustomCrds() {

KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, Address.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, AddressList.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, AddressList.KIND, AddressList.class);

KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, AddressSpace.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, AddressSpaceList.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpace.KIND, AddressSpace.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceList.KIND, AddressSpaceList.class);

KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, AddressSpaceSchema.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceSchema.KIND, AddressSpaceSchema.class);
KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceSchemaList.KIND, AddressSpaceSchemaList.class);
}

public static CustomResourceDefinition addresses() {
Expand Down
9 changes: 9 additions & 0 deletions api-model/src/main/java/io/enmasse/user/model/v1/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,13 @@ private void validateMetadata() {
Objects.requireNonNull(namespace, "'namespace' must be set");

}

@Override
public String toString() {
StringBuilder sb = new StringBuilder("{");
sb.append("metadata=").append(getMetadata()).append(",");
sb.append("spec=").append(spec);
sb.append("}");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ public String getFederatedUsername() {
public void validate() {
Objects.requireNonNull(type, "'type' must be set");
}

@Override
public String toString() {
return "{" + "type=" + type.toString() + "}";
}
}
10 changes: 10 additions & 0 deletions api-model/src/main/java/io/enmasse/user/model/v1/UserSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,14 @@ public void validate() {
}
}
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder("{");
sb.append("username=").append(username).append(",");
sb.append("authentication=").append(authentication).append(",");
sb.append("authorization=").append(authorization);
sb.append("}");
return sb.toString();
}
}
8 changes: 4 additions & 4 deletions systemtests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@
<id>shared-brokered-pr</id>
<properties>
<skip.tests>false</skip.tests>
<groups>shared-brokered &amp; !nonPR &amp; !smoke &amp; !marathon</groups>
<groups>shared-brokered &amp; !nonPR &amp; !smoke &amp; !marathon &amp; !shared-iot</groups>
</properties>
</profile>
<profile>
<id>shared-standard-pr</id>
<properties>
<skip.tests>false</skip.tests>
<groups>shared-standard &amp; !nonPR &amp; !smoke &amp; !marathon</groups>
<groups>shared-standard &amp; !nonPR &amp; !smoke &amp; !marathon &amp; !shared-iot</groups>
</properties>
</profile>
<profile>
<id>isolated-pr</id>
<properties>
<skip.tests>false</skip.tests>
<groups>isolated &amp; !nonPR &amp; !smoke &amp; !marathon</groups>
<groups>isolated &amp; !nonPR &amp; !smoke &amp; !marathon &amp; !shared-iot</groups>
</properties>
</profile>
<profile>
<id>isolated</id>
<properties>
<groups>isolated &amp; !marathon</groups>
<groups>isolated &amp; !marathon &amp; !shared-iot</groups>
<skip.tests>false</skip.tests>
</properties>
</profile>
Expand Down
3 changes: 1 addition & 2 deletions systemtests/scripts/run_test_kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ echo "Running test profile: ${TEST_PROFILE}"
#execute test
case "${TEST_PROFILE}" in
"smoke")
run_test shared-brokered "**.SmokeTest" || failure=$(($failure + 1))
run_test shared-standard "**.SmokeTest" || failure=$(($failure + 1))
run_test smoke "" || failure=$(($failure + 1))
;;
"smoke-iot")
run_test smoke-iot "" || failure=$(($failure + 1))
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.enmasse.systemtest;

import io.enmasse.admin.model.v1.*;
import io.enmasse.systemtest.apiclients.AdminApiClient;
import io.enmasse.systemtest.utils.TestUtils;
import io.fabric8.kubernetes.api.model.Pod;
import org.slf4j.Logger;
Expand All @@ -20,37 +19,43 @@ public class AdminResourcesManager {
private static Logger log = CustomLogger.getLogger();
private ArrayList<AddressPlan> addressPlans;
private ArrayList<AddressSpacePlan> addressSpacePlans;
private ArrayList<InfraConfig> infraConfigs;
private ArrayList<StandardInfraConfig> standardInfraConfigs;
private ArrayList<BrokeredInfraConfig> brokeredInfraConfigs;
private ArrayList<AuthenticationService> authServices;
private final AdminApiClient adminApiClient;

public AdminResourcesManager(Kubernetes kubernetes) {
this.adminApiClient = new AdminApiClient(kubernetes);
}

public void setUp() {
addressPlans = new ArrayList<>();
addressSpacePlans = new ArrayList<>();
infraConfigs = new ArrayList<>();
standardInfraConfigs = new ArrayList<>();
brokeredInfraConfigs = new ArrayList<>();
authServices = new ArrayList<>();
}

public void tearDown() throws Exception {
if (!Environment.getInstance().skipCleanup()) {
for (AddressSpacePlan addressSpacePlan : addressSpacePlans) {
adminApiClient.deleteAddressSpacePlan(addressSpacePlan);
Kubernetes.getInstance().getAddressSpacePlanClient().delete(addressSpacePlan);
log.info("AddressSpace plan {} deleted", addressSpacePlan.getMetadata().getName());
}

for (AddressPlan addressPlan : addressPlans) {
adminApiClient.deleteAddressPlan(addressPlan);
Kubernetes.getInstance().getAddressPlanClient().delete(addressPlan);
log.info("Address plan {} deleted", addressPlan.getMetadata().getName());
}

for (StandardInfraConfig infraConfigDefinition : standardInfraConfigs) {
Kubernetes.getInstance().getStandardInfraConfigClient().delete(infraConfigDefinition);
log.info("Standardinfraconfig {} deleted", infraConfigDefinition.getMetadata().getName());
}

for (InfraConfig infraConfigDefinition : infraConfigs) {
adminApiClient.deleteInfraConfig(infraConfigDefinition);
for (BrokeredInfraConfig infraConfigDefinition : brokeredInfraConfigs) {
Kubernetes.getInstance().getBrokeredInfraConfigClient().delete(infraConfigDefinition);
log.info("Brokeredinfraconfig {} deleted", infraConfigDefinition.getMetadata().getName());
}

for (AuthenticationService authService : authServices) {
adminApiClient.deleteAuthService(authService);
Kubernetes.getInstance().getAuthenticationServiceClient().delete(authService);
log.info("AuthService {} deleted", authService.getMetadata().getName());
}

addressPlans.clear();
Expand All @@ -67,21 +72,28 @@ public void createAddressPlan(AddressPlan addressPlan) throws Exception {
}

public void createAddressPlan(AddressPlan addressPlan, boolean replaceExisting) throws Exception {
log.info("Address plan {} will be created {}", addressPlan.getMetadata().getName(), addressPlan);
var client = Kubernetes.getInstance().getAddressPlanClient();
if (replaceExisting) {
adminApiClient.replaceAddressPlan(addressPlan);
client.createOrReplace(addressPlan);
} else {
adminApiClient.createAddressPlan(addressPlan);
client.create(addressPlan);
}
addressPlans.add(addressPlan);
Thread.sleep(1000);
}

public void removeAddressPlan(AddressPlan addressPlan) throws Exception {
adminApiClient.deleteAddressPlan(addressPlan);
Kubernetes.getInstance().getAddressPlanClient().delete(addressPlan);
addressPlans.removeIf(addressPlanIter -> addressPlanIter.getMetadata().getName().equals(addressPlan.getMetadata().getName()));
}

public void replaceAddressPlan(AddressPlan plan) throws Exception {
adminApiClient.replaceAddressPlan(plan);
Kubernetes.getInstance().getAddressPlanClient().createOrReplace(plan);
}

public AddressPlan getAddressPlan(String name) throws Exception {
return Kubernetes.getInstance().getAddressPlanClient().withName(name).get();
}

//------------------------------------------------------------------------------------------------
Expand All @@ -93,74 +105,83 @@ public void createAddressSpacePlan(AddressSpacePlan addressSpacePlan) throws Exc
}

public void createAddressSpacePlan(AddressSpacePlan addressSpacePlan, boolean replaceExisting) throws Exception {
log.info("AddressSpace plan {} will be created {}", addressSpacePlan.getMetadata().getName(), addressSpacePlan);
var client = Kubernetes.getInstance().getAddressSpacePlanClient();
if (replaceExisting) {
adminApiClient.replaceAddressSpacePlan(addressSpacePlan);
client.createOrReplace(addressSpacePlan);
} else {
adminApiClient.createAddressSpacePlan(addressSpacePlan);
client.create(addressSpacePlan);
}
addressSpacePlans.add(addressSpacePlan);
Thread.sleep(1000);
}

public void removeAddressSpacePlan(AddressSpacePlan addressSpacePlan) throws Exception {
adminApiClient.deleteAddressSpacePlan(addressSpacePlan);
Kubernetes.getInstance().getAddressSpacePlanClient().delete(addressSpacePlan);
addressSpacePlans.removeIf(spacePlanIter -> spacePlanIter.getMetadata().getName().equals(addressSpacePlan.getMetadata().getName()));
}

public AddressSpacePlan getAddressSpacePlan(String config) throws Exception {
return adminApiClient.getAddressSpacePlan(config);
}

public AddressPlan getAddressPlan(String name) throws Exception {
return adminApiClient.getAddressPlan(name);
return Kubernetes.getInstance().getAddressSpacePlanClient().withName(config).get();
}

//------------------------------------------------------------------------------------------------
// Infra configs
//------------------------------------------------------------------------------------------------

public BrokeredInfraConfig getBrokeredInfraConfig(String name) throws Exception {
return (BrokeredInfraConfig) adminApiClient.getInfraConfig(AddressSpaceType.BROKERED, name);
return Kubernetes.getInstance().getBrokeredInfraConfigClient().withName(name).get();
}

public StandardInfraConfig getStandardInfraConfig(String name) throws Exception {
return (StandardInfraConfig) adminApiClient.getInfraConfig(AddressSpaceType.STANDARD, name);
return Kubernetes.getInstance().getStandardInfraConfigClient().withName(name).get();
}

public void createInfraConfig(InfraConfig infraConfigDefinition) throws Exception {
createInfraConfig(infraConfigDefinition, false);
}

public void createInfraConfig(InfraConfig infraConfigDefinition, boolean replaceExisting) throws Exception {
if (replaceExisting) {
adminApiClient.replaceInfraConfig(infraConfigDefinition);
log.info("InfraConfig {} will be created {}", infraConfigDefinition.getMetadata().getName(), infraConfigDefinition);
if (infraConfigDefinition instanceof StandardInfraConfig) {
var client = Kubernetes.getInstance().getStandardInfraConfigClient();
client.createOrReplace((StandardInfraConfig) infraConfigDefinition);
standardInfraConfigs.add((StandardInfraConfig) infraConfigDefinition);
} else {
adminApiClient.createInfraConfig(infraConfigDefinition);
var client = Kubernetes.getInstance().getBrokeredInfraConfigClient();
client.createOrReplace((BrokeredInfraConfig) infraConfigDefinition);
brokeredInfraConfigs.add((BrokeredInfraConfig) infraConfigDefinition);
}
infraConfigs.add(infraConfigDefinition);
Thread.sleep(1000);
}

public void removeInfraConfig(InfraConfig infraConfigDefinition) throws Exception {
adminApiClient.deleteInfraConfig(infraConfigDefinition);
infraConfigs.removeIf(infraId -> infraId.getMetadata().getName().equals(infraConfigDefinition.getMetadata().getName()));
if (infraConfigDefinition instanceof StandardInfraConfig) {
var client = Kubernetes.getInstance().getStandardInfraConfigClient();
client.delete((StandardInfraConfig) infraConfigDefinition);
standardInfraConfigs.removeIf(infraId -> infraId.getMetadata().getName().equals(infraConfigDefinition.getMetadata().getName()));
} else {
var client = Kubernetes.getInstance().getBrokeredInfraConfigClient();
client.delete((BrokeredInfraConfig) infraConfigDefinition);
brokeredInfraConfigs.removeIf(infraId -> infraId.getMetadata().getName().equals(infraConfigDefinition.getMetadata().getName()));
}
}

//------------------------------------------------------------------------------------------------
// Authentication services
//------------------------------------------------------------------------------------------------

public AuthenticationService getAuthService(String name) throws Exception {
return adminApiClient.getAuthService(name);
return Kubernetes.getInstance().getAuthenticationServiceClient().withName(name).get();
}

public void createAuthService(AuthenticationService authService) throws Exception {
createAuthService(authService, false);
}

public void createAuthService(AuthenticationService authenticationService, boolean replaceExisting) throws Exception {
log.info("AuthService {} will be created {}", authenticationService.getMetadata().getName(), authenticationService);
var client = Kubernetes.getInstance().getAuthenticationServiceClient();
if (replaceExisting) {
adminApiClient.replaceAuthService(authenticationService);
client.createOrReplace(authenticationService);
} else {
adminApiClient.createAuthService(authenticationService);
client.create(authenticationService);
authServices.add(authenticationService);
}
String desiredPodName = authenticationService.getMetadata().getName();
Expand All @@ -175,12 +196,12 @@ public void createAuthService(AuthenticationService authenticationService, boole
}

return matching == 1;
},
},
new TimeoutBudget(5, TimeUnit.MINUTES));
}

public void removeAuthService(AuthenticationService authService) throws Exception {
adminApiClient.deleteAuthService(authService);
Kubernetes.getInstance().getAuthenticationServiceClient().delete(authService);
authServices.removeIf(authserviceId -> authserviceId.getMetadata().getName().equals(authService.getMetadata().getName()));
TestUtils.waitUntilCondition("Auth service is deleted: " + authService.getMetadata().getName(), (phase) ->
TestUtils.listReadyPods(Kubernetes.getInstance()).stream().noneMatch(pod ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public interface DestinationPlan {
String STANDARD_XLARGE_QUEUE = "standard-xlarge-queue";
String STANDARD_XLARGE_TOPIC = "standard-xlarge-topic";
String STANDARD_SMALL_ANYCAST = "standard-small-anycast";
String STANDARD_MEDIUM_ANYCAST = "standard-medium-anycast";
String STANDARD_SMALL_MULTICAST = "standard-small-multicast";
String STANDARD_MEDIUM_MULTICAST = "standard-medium-multicast";
String STANDARD_SMALL_SUBSCRIPTION = "standard-small-subscription";
String STANDARD_LARGE_SUBSCRIPTION = "standard-large-subscription";
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public static synchronized Environment getInstance() {
return instance;
}

/**
* Create dummy address in shared address-spaces due to faster deploy of next addresses
*/
private final boolean useDummyAddress = Boolean.parseBoolean(System.getenv("USE_DUMMY_ADDRESS"));

/**
* Skip removing address-spaces
*/
Expand Down Expand Up @@ -104,10 +99,6 @@ public boolean useMinikube() {
return useMinikube;
}

public boolean useDummyAddress() {
return useDummyAddress;
}

public boolean skipCleanup() {
return skipCleanup;
}
Expand Down
Loading

0 comments on commit 1642a04

Please sign in to comment.