-
Notifications
You must be signed in to change notification settings - Fork 53
[WIP] Add DSL support for calling effectors in YAML #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
54d131a
Add DSL support for calling effectors in YAML
grkvlt a6f8c76
Updates for effector calling.
geomacy 5118a35
Adding integration test for entity interaction.
geomacy 8efc762
Tidy up DSL effector method
grkvlt 3bb0397
Add locking on cachedTask for DSL effector
grkvlt 70d9aca
Added changes from @drigonwin for getImmediately
grkvlt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...rooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EffectorsYamlIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.brooklyn.camp.brooklyn; | ||
|
|
||
| import com.google.common.collect.Iterables; | ||
| import org.apache.brooklyn.api.entity.Entity; | ||
| import org.apache.brooklyn.core.test.entity.TestEntity; | ||
| import org.apache.brooklyn.entity.software.base.SameServerEntity; | ||
| import org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.testng.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| import static org.apache.brooklyn.core.entity.EntityPredicates.displayNameEqualTo; | ||
| import static org.testng.Assert.assertEquals; | ||
|
|
||
| @Test | ||
| public class EffectorsYamlIntegrationTest extends AbstractYamlTest { | ||
| private static final Logger log = LoggerFactory.getLogger(EffectorsYamlIntegrationTest.class); | ||
|
|
||
| @Test(groups = "Integration") | ||
| public void testInteractingWithAnotherEntityForStartup() throws Exception { | ||
|
|
||
| final Path tempFile = Files.createTempFile("testInteractingWithAnotherEntityForStartup", ".txt"); | ||
| getLogger().info("Temp file is {}", tempFile.toAbsolutePath()); | ||
|
|
||
| try { | ||
| Entity app = createAndStartApplication( | ||
| "location: localhost:(name=localhost)", | ||
| "services:", | ||
| "- type: " + SameServerEntity.class.getName(), | ||
| " brooklyn.children:", | ||
| " - type: " + TestEntity.class.getName(), | ||
| " id: testEntity", | ||
| " name: testEntity", | ||
| " brooklyn.initializers:", | ||
| " - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor", | ||
| " brooklyn.config:", | ||
| " name: greeting", | ||
| " period: 2s", | ||
| " command: |", | ||
| " echo hello world", | ||
| " - type: " + VanillaSoftwareProcess.class.getName(), | ||
| " id: consumerEntity", | ||
| " brooklyn.config:", | ||
| " install.latch: $brooklyn:entity(\"testEntity\").attributeWhenReady(\"service.isUp\")", | ||
| " launch.command: while true; do sleep 3600 ; done & echo $! > ${PID_FILE}", | ||
| " shell.env:", | ||
| " RESPONSE: $brooklyn:entity(\"testEntity\").effector(\"identityEffector\", $brooklyn:entity(\"testEntity\").attributeWhenReady(\"greeting\"))", | ||
| " post.launch.command: echo ${RESPONSE} > " + tempFile.toAbsolutePath() | ||
| ); | ||
| waitForApplicationTasks(app); | ||
|
|
||
| final String contents = new String(Files.readAllBytes(tempFile)).trim(); | ||
| assertEquals(contents, "hello world", "file contents: " + contents); | ||
|
|
||
| } finally { | ||
| Files.delete(tempFile); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private void assertCallHistory(TestEntity testEntity, String... expectedCalls) { | ||
| List<String> callHistory = testEntity.getCallHistory(); | ||
| Assert.assertEquals(callHistory.size(), expectedCalls.length, "history = " + callHistory); | ||
| int c = 0; | ||
| for (String expected : expectedCalls) { | ||
| Assert.assertEquals(callHistory.get(c++), expected, "history = " + callHistory); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected Logger getLogger() { | ||
| return log; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should equals include the
args? Not sure when equals would actually be used in anger.