Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,63 @@ public void testYamlUrlReferencingCatalog() throws Exception {
checkChildEntitySpec(app, entityName);
}

@Test
public void testYamlReferencingEarlierItemShortForm() throws Exception {
addCatalogItems(
"brooklyn.catalog:",
" itemType: entity",
" items:",
" - id: yaml.basic",
" version: " + TEST_VERSION,
" item:",
" type: org.apache.brooklyn.entity.stock.BasicEntity",
" - id: yaml.reference",
" version: " + TEST_VERSION,
" item:",
" type: yaml.basic");

String entityName = "YAML -> catalog item -> yaml url";
Entity app = createAndStartApplication(
"services:",
"- name: " + entityName,
" type: " + ver("yaml.reference"));

checkChildEntitySpec(app, entityName);
}

@Test(groups="WIP") // references to earlier items only work with short form syntax
public void testYamlReferencingEarlierItemLongForm() throws Exception {
addCatalogItems(
"brooklyn.catalog:",
" itemType: entity",
" items:",
" - id: yaml.basic",
" version: " + TEST_VERSION,
" item:",
" services:",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've recommended in the docs (http://brooklyn.apache.org/v/0.11.0/ops/catalog/) that one should use services: with itemType: template, and not with itemType: entity (because the latter only ever has one thing in it).

Can you change this test to use itemType: template, or indicate in a comment at the top that this is testing a discouraged catalog format?

" - type: org.apache.brooklyn.entity.stock.BasicEntity",
" - id: yaml.reference",
" version: " + TEST_VERSION,
" item:",
" services:",
" - type: yaml.basic");

String entityName = "YAML -> catalog item -> yaml url";
Entity app = createAndStartApplication(
"services:",
"- name: " + entityName,
" type: " + ver("yaml.reference"));

checkChildEntitySpec(app, entityName);
}

@Test(groups="WIP") //Not able to use caller provided catalog items when referencing entity specs (as opposed to catalog meta)
public void testYamlUrlReferencingCallerCatalogItem() throws Exception {
addCatalogItems(
"brooklyn.catalog:",
" itemType: entity",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, can we use itemType: template here if we're using services: ...?

" items:",
" - id: yaml.standalone",
" - id: yaml.basic",
" version: " + TEST_VERSION,
" item:",
" services:",
Expand All @@ -142,7 +192,7 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception {
" version: " + TEST_VERSION,
" item:",
" services:",
" - type: classpath://yaml-ref-parent-catalog.yaml");
" - type: classpath://yaml-ref-catalog.yaml"); // this references yaml.basic above
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I didn't no we supported this. Why?!

It looks like classpath://yaml-ref-catalog.yaml contains:

name: Basic app
services:
- name: service
  type: yaml.basic:0.1.2

so it's not a catalog item. Should we really be able to reference it as a type in a catalog item like this? I'd have thought the right way of doing it (for an end-user) would be to re-write yaml-ref-catalog.yaml as a catalog item, deploy it to the catalog, and then reference its type in the normal way (which clearly would invalidate this test case).

I suggest we deprecate this asap. I don't think we've documented it anywhere, so hopefully no-one is relying on it in anger.

I therefore think it's not worth fixing this test.


String entityName = "YAML -> catalog item -> yaml url";
Entity app = createAndStartApplication(
Expand All @@ -152,7 +202,7 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception {

checkChildEntitySpec(app, entityName);
}

private void checkChildEntitySpec(Entity app, String entityName) {
Collection<Entity> children = app.getChildren();
Assert.assertEquals(children.size(), 1);
Expand Down