use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project che-server by eclipse-che.
the class KubernetesMachinesCacheTest method shouldGetMachines.
@Test
public void shouldGetMachines() throws Exception {
// given
RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
// when
machineCache.getMachines(runtimeId);
// then
Map<String, KubernetesMachineImpl> fetched = machineCache.getMachines(runtimeId);
assertEquals(fetched.size(), 2);
assertTrue(fetched.keySet().containsAll(asList("machine1", "machine2")));
assertTrue(fetched.values().containsAll(asList(machines[0], machines[1])));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project che-server by eclipse-che.
the class KubernetesMachinesCacheTest method shouldThrowExceptionWhenServerWasNotFoundOnGetting.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Server with name 'non-existing' was not found")
public void shouldThrowExceptionWhenServerWasNotFoundOnGetting() throws Exception {
// given
RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
KubernetesMachineImpl machine = machines[0];
// when
machineCache.getServer(runtimeId, machine.getName(), "non-existing");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method shouldReturnTrueIfOnlyOnePodExistsOnRuntimeConsistencyChecking.
@Test
public void shouldReturnTrueIfOnlyOnePodExistsOnRuntimeConsistencyChecking() throws Exception {
// given
KubernetesMachineImpl machine1 = new KubernetesMachineImpl(WORKSPACE_ID, "machine1", "pod1", "container 1", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine2 = new KubernetesMachineImpl(WORKSPACE_ID, "machine2", "pod1", "container 2", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine3 = new KubernetesMachineImpl(WORKSPACE_ID, "machine3", "pod2", "container 1", null, emptyMap(), emptyMap());
machinesCache.put(IDENTITY, machine1);
machinesCache.put(IDENTITY, machine2);
machinesCache.put(IDENTITY, machine3);
doReturn(Optional.of(mock(Pod.class))).when(deployments).get("pod1");
doReturn(Optional.empty()).when(deployments).get("pod2");
// when
boolean isConsistent = internalRuntime.isConsistent();
// then
assertTrue(isConsistent);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project che-server by eclipse-che.
the class PostgreSqlTckModule method configure.
@Override
protected void configure() {
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
// jpa
install(new PersistTestModuleBuilder().setDriver(Driver.class).setUrl(dbUrl).setUser(dbUser).setPassword(dbPassword).setExceptionHandler(PostgreSqlExceptionHandler.class).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, RecipeImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, SshPairImpl.class, WorkspaceActivity.class, VolumeImpl.class, // devfile
UserDevfileImpl.class, ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class, // k8s-runtimes
KubernetesRuntimeState.class, KubernetesRuntimeCommandImpl.class, KubernetesMachineImpl.class, KubernetesMachineImpl.MachineId.class, KubernetesServerImpl.class, KubernetesServerImpl.ServerId.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).build());
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// db initialization
bind(DBInitializer.class).asEagerSingleton();
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
// account
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// user
bind(UserDao.class).to(JpaUserDao.class);
bind(ProfileDao.class).to(JpaProfileDao.class);
bind(PreferenceDao.class).to(JpaPreferenceDao.class);
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserRepo.class);
bind(new TypeLiteral<TckRepository<Pair<String, Map<String, String>>>>() {
}).to(PreferencesRepo.class);
bind(new TypeLiteral<TckRepository<ProfileImpl>>() {
}).toInstance(new JpaTckRepository<>(ProfileImpl.class));
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class);
// machine
bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
}).toInstance(new JpaTckRepository<>(RecipeImpl.class));
// ssh
bind(SshDao.class).to(JpaSshDao.class);
bind(new TypeLiteral<TckRepository<SshPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SshPairImpl.class));
// workspace
bind(WorkspaceDao.class).to(JpaWorkspaceDao.class);
bind(WorkspaceActivityDao.class).to(JpaWorkspaceActivityDao.class);
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new WorkspaceRepository());
bind(UserDevfileDao.class).to(JpaUserDevfileDao.class);
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
// k8s runtimes
bind(new TypeLiteral<TckRepository<KubernetesRuntimeState>>() {
}).toInstance(new JpaTckRepository<>(KubernetesRuntimeState.class));
bind(new TypeLiteral<TckRepository<KubernetesMachineImpl>>() {
}).toInstance(new JpaTckRepository<>(KubernetesMachineImpl.class));
bind(KubernetesRuntimeStateCache.class).to(JpaKubernetesRuntimeStateCache.class);
bind(KubernetesMachineCache.class).to(JpaKubernetesMachineCache.class);
bind(JpaKubernetesRuntimeStateCache.RemoveKubernetesRuntimeBeforeWorkspaceRemoved.class).asEagerSingleton();
bind(JpaKubernetesMachineCache.RemoveKubernetesMachinesBeforeRuntimesRemoved.class).asEagerSingleton();
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method shouldReturnTrueIfOnlyOnePodExistsOnRuntimeConsistencyChecking.
@Test
public void shouldReturnTrueIfOnlyOnePodExistsOnRuntimeConsistencyChecking() throws Exception {
// given
KubernetesMachineImpl machine1 = new KubernetesMachineImpl(WORKSPACE_ID, "machine1", "pod1", "container 1", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine2 = new KubernetesMachineImpl(WORKSPACE_ID, "machine2", "pod1", "container 2", null, emptyMap(), emptyMap());
KubernetesMachineImpl machine3 = new KubernetesMachineImpl(WORKSPACE_ID, "machine3", "pod2", "container 1", null, emptyMap(), emptyMap());
machinesCache.put(IDENTITY, machine1);
machinesCache.put(IDENTITY, machine2);
machinesCache.put(IDENTITY, machine3);
doReturn(Optional.of(mock(Pod.class))).when(deployments).get("pod1");
doReturn(Optional.empty()).when(deployments).get("pod2");
// when
boolean isConsistent = internalRuntime.isConsistent();
// then
assertTrue(isConsistent);
}
Aggregations