use of org.eclipse.che.api.workspace.server.model.impl.RecipeImpl in project che-server by eclipse-che.
the class KubernetesEnvironmentProvisionerTest method shouldMergeProjectPVCIntoOne.
@Test
public void shouldMergeProjectPVCIntoOne() throws Exception {
// given
PersistentVolumeClaim volumeClaim = newPVC(PROJECTS_VOLUME_NAME, "ReadWriteMany", "1Gb");
workspaceConfig.setDefaultEnv("default");
RecipeImpl existingRecipe = new RecipeImpl("kubernetes", YAML_CONTENT_TYPE, Serialization.asYaml(volumeClaim), null);
doReturn(singletonList(volumeClaim)).when(k8sRecipeParser).parse(anyString());
workspaceConfig.getEnvironments().put("default", new EnvironmentImpl(existingRecipe, emptyMap()));
// try add same claim one more time (like another component adds it)
List<HasMetadata> componentsObject = new ArrayList<>();
componentsObject.add(volumeClaim);
// when
k8sEnvProvisioner.provision(workspaceConfig, KubernetesEnvironment.TYPE, componentsObject, emptyMap());
// we still have only one PVC
EnvironmentImpl resultEnv = workspaceConfig.getEnvironments().get(workspaceConfig.getDefaultEnv());
assertEquals(toK8SList(resultEnv.getRecipe().getContent()).getItems().size(), 1);
}
use of org.eclipse.che.api.workspace.server.model.impl.RecipeImpl in project che-server by eclipse-che.
the class KubernetesEnvironmentProvisionerTest method shouldThrowAnExceptionIfWorkspaceAlreadyContainNonK8sNorOSRecipe.
@Test(expectedExceptions = DevfileException.class, expectedExceptionsMessageRegExp = "Kubernetes component can only be applied to a workspace with any of kubernetes or openshift " + "recipe type but workspace has a recipe of type 'any'")
public void shouldThrowAnExceptionIfWorkspaceAlreadyContainNonK8sNorOSRecipe() throws Exception {
// given
workspaceConfig.setDefaultEnv("default");
RecipeImpl existingRecipe = new RecipeImpl("any", "yaml", "existing-content", null);
workspaceConfig.getEnvironments().put("default", new EnvironmentImpl(existingRecipe, emptyMap()));
List<HasMetadata> componentsObject = new ArrayList<>();
Deployment componentDeployment = new DeploymentBuilder().withNewMetadata().withName("db").endMetadata().withNewSpec().endSpec().build();
componentsObject.add(new DeploymentBuilder(componentDeployment).build());
// when
k8sEnvProvisioner.provision(workspaceConfig, KubernetesEnvironment.TYPE, componentsObject, emptyMap());
}
use of org.eclipse.che.api.workspace.server.model.impl.RecipeImpl in project che-server by eclipse-che.
the class TestObjectsFactory method createEnv.
public static EnvironmentImpl createEnv() {
final RecipeImpl newRecipe = new RecipeImpl();
newRecipe.setLocation("new-location");
newRecipe.setType("new-type");
newRecipe.setContentType("new-content-type");
newRecipe.setContent("new-content");
final MachineConfigImpl newMachine = new MachineConfigImpl();
final ServerConfigImpl serverConf1 = new ServerConfigImpl("2265", "http", "/path1", singletonMap("key", "value"));
final ServerConfigImpl serverConf2 = new ServerConfigImpl("2266", "ftp", "/path2", singletonMap("key", "value"));
newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2));
newMachine.setAttributes(singletonMap("att1", "val"));
newMachine.setEnv(singletonMap("CHE_ENV", "value"));
final EnvironmentImpl newEnv = new EnvironmentImpl();
newEnv.setMachines(ImmutableMap.of("new-machine", newMachine));
newEnv.setRecipe(newRecipe);
return newEnv;
}
use of org.eclipse.che.api.workspace.server.model.impl.RecipeImpl 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.api.workspace.server.model.impl.RecipeImpl in project che-server by eclipse-che.
the class InternalEnvironmentFactoryTest method shouldUseRetrievedRecipeWhileInternalEnvironmentCreation.
@Test
public void shouldUseRetrievedRecipeWhileInternalEnvironmentCreation() throws Exception {
// given
RecipeImpl recipe = new RecipeImpl("type", "contentType", "content", "location");
InternalRecipe retrievedRecipe = mock(InternalRecipe.class);
doReturn(retrievedRecipe).when(recipeRetriever).getRecipe(any());
EnvironmentImpl env = new EnvironmentImpl(recipe, null);
// when
environmentFactory.create(env);
// then
verify(recipeRetriever).getRecipe(recipe);
verify(environmentFactory).doCreate(eq(retrievedRecipe), any(), any());
}
Aggregations