Search in sources :

Example 1 with ConnectorNamespaceStatus1

use of org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1 in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class NamespaceProvisionerTest method nameIsSanitized.

@Test
void nameIsSanitized() {
    // 
    // Given that no resources associated to the provided deployment exist
    // 
    final ConnectorNamespace namespace = new ConnectorNamespace();
    namespace.id(uid());
    namespace.name("--eval");
    ConnectorNamespaceTenant tenant = new ConnectorNamespaceTenant().id(uid()).kind(ConnectorNamespaceTenantKind.ORGANISATION);
    namespace.setStatus(new ConnectorNamespaceStatus1().state(ConnectorNamespaceState.READY).connectorsDeployed(0));
    namespace.setTenant(tenant);
    namespace.setExpiration(new Date().toString());
    final List<ManagedConnector> connectors = List.of();
    final List<Secret> secrets = List.of();
    final FleetShardClient fleetShard = ConnectorTestSupport.fleetShard(CLUSTER_ID, connectors, secrets);
    final FleetManagerClient fleetManager = ConnectorTestSupport.fleetManagerClient();
    final FleetShardSyncConfig config = ConnectorTestSupport.config();
    final MeterRegistry registry = Mockito.mock(MeterRegistry.class);
    final ConnectorNamespaceProvisioner provisioner = new ConnectorNamespaceProvisioner(config, fleetShard, fleetManager, registry);
    final ArgumentCaptor<Namespace> nc = ArgumentCaptor.forClass(Namespace.class);
    // 
    // When deployment is applied
    // 
    provisioner.provision(namespace);
    verify(fleetShard).createNamespace(nc.capture());
    // 
    // Then resources must be created according to the deployment
    // 
    assertThat(nc.getValue()).satisfies(val -> {
        assertThat(val.getMetadata().getLabels()).containsEntry(LABEL_KUBERNETES_NAME, "a--eval");
    });
}
Also used : FleetShardClient(org.bf2.cos.fleetshard.sync.client.FleetShardClient) ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ConnectorNamespaceStatus1(org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1) ManagedConnector(org.bf2.cos.fleetshard.api.ManagedConnector) ConnectorNamespaceProvisioner(org.bf2.cos.fleetshard.sync.resources.ConnectorNamespaceProvisioner) Date(java.util.Date) ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) Namespace(io.fabric8.kubernetes.api.model.Namespace) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Secret(io.fabric8.kubernetes.api.model.Secret) FleetManagerClient(org.bf2.cos.fleetshard.sync.client.FleetManagerClient) FleetShardSyncConfig(org.bf2.cos.fleetshard.sync.FleetShardSyncConfig) ConnectorNamespaceTenant(org.bf2.cos.fleet.manager.model.ConnectorNamespaceTenant) Test(org.junit.jupiter.api.Test)

Example 2 with ConnectorNamespaceStatus1

use of org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1 in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class SyncTestSupport method namespace.

public static ConnectorNamespace namespace(String id, String name) {
    ConnectorNamespace answer = new ConnectorNamespace().id(id).name(name);
    ConnectorNamespaceTenant tenant = new ConnectorNamespaceTenant().id(uid()).kind(ConnectorNamespaceTenantKind.ORGANISATION);
    answer.setStatus(new ConnectorNamespaceStatus1().state(ConnectorNamespaceState.READY).connectorsDeployed(0));
    answer.setTenant(tenant);
    answer.setExpiration(new Date().toString());
    return answer;
}
Also used : ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ConnectorNamespaceStatus1(org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1) ConnectorNamespaceTenant(org.bf2.cos.fleet.manager.model.ConnectorNamespaceTenant) Date(java.util.Date)

Example 3 with ConnectorNamespaceStatus1

use of org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1 in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class SyncTestSupport method namespace.

public static ConnectorNamespace namespace(String id, String name, Consumer<ConnectorNamespace> consumer) {
    ConnectorNamespace answer = new ConnectorNamespace().id(id).name(name);
    consumer.accept(answer);
    if (answer.getStatus() == null) {
        answer.setStatus(new ConnectorNamespaceStatus1());
    }
    if (answer.getStatus().getConnectorsDeployed() == null) {
        answer.getStatus().setConnectorsDeployed(0);
    }
    return answer;
}
Also used : ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ConnectorNamespaceStatus1(org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1)

Aggregations

ConnectorNamespace (org.bf2.cos.fleet.manager.model.ConnectorNamespace)3 ConnectorNamespaceStatus1 (org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus1)3 Date (java.util.Date)2 ConnectorNamespaceTenant (org.bf2.cos.fleet.manager.model.ConnectorNamespaceTenant)2 Namespace (io.fabric8.kubernetes.api.model.Namespace)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 ManagedConnector (org.bf2.cos.fleetshard.api.ManagedConnector)1 FleetShardSyncConfig (org.bf2.cos.fleetshard.sync.FleetShardSyncConfig)1 FleetManagerClient (org.bf2.cos.fleetshard.sync.client.FleetManagerClient)1 FleetShardClient (org.bf2.cos.fleetshard.sync.client.FleetShardClient)1 ConnectorNamespaceProvisioner (org.bf2.cos.fleetshard.sync.resources.ConnectorNamespaceProvisioner)1 Test (org.junit.jupiter.api.Test)1