76 lines
2.2 KiB
YAML
76 lines
2.2 KiB
YAML
|
|
Namespaces:
|
|
=: io.murano.test
|
|
sys: io.murano.system
|
|
|
|
Extends: TestFixture
|
|
|
|
Name: TomcatTest
|
|
|
|
Methods:
|
|
.init:
|
|
Body:
|
|
# Object model can be loaded from json file, or provided
|
|
# directly in MuranoPL code as a yaml insertion.
|
|
- $.appJson: new(sys:Resources).json('tomcat-for-mock.json')
|
|
- $.heatOutput: new(sys:Resources).json('output.json')
|
|
- $.log: logger('test')
|
|
- $.agentCallCount: 0
|
|
|
|
# Mock method to replace the original one
|
|
agentMock:
|
|
Arguments:
|
|
- template:
|
|
Contract: $
|
|
- resources:
|
|
Contract: $
|
|
- timeout:
|
|
Contract: $
|
|
Default: null
|
|
Body:
|
|
- $.log.info('Mocking murano agent')
|
|
- $.assertEqual('Deploy Tomcat', $template.Name)
|
|
- $.agentCallCount: $.agentCallCount + 1
|
|
|
|
# Mock method, that returns predefined heat stack output
|
|
getStackOut:
|
|
Body:
|
|
- $.log.info('Mocking heat stack')
|
|
- Return: $.heatOutput
|
|
|
|
testDeploy1:
|
|
Body:
|
|
# Loading object model
|
|
- $.env: $this.load($.appJson)
|
|
|
|
# Set up mock for the push method of *io.murano.system.HeatStack* class
|
|
- inject(sys:HeatStack, push, $.heatOutput)
|
|
|
|
# Set up mock for the concrete object with mock method name
|
|
- inject($.env.stack, output, $.heatOutput)
|
|
|
|
# Set up mock with YAQL function
|
|
- inject('io.murano.system.Agent', call, $this, agentMock)
|
|
|
|
# Mocks will be called instead of original function during the deployment
|
|
- $.env.deploy()
|
|
|
|
# Check, that mock worked correctly
|
|
- $.assertEqual($.agentCallCount, 1)
|
|
|
|
|
|
testDeploy2:
|
|
Body:
|
|
- inject(sys:HeatStack, push, $this, getStackOut)
|
|
- inject(sys:HeatStack, output, $this, getStackOut)
|
|
|
|
# Mock is defined with YAQL function and it will print the original variable (agent template)
|
|
- inject(sys:Agent, call, withOriginal(t => $template) -> $.log.info('{0}', $t))
|
|
|
|
- $.env: $this.load($.appJson)
|
|
- $.env.deploy()
|
|
|
|
# Check, that variable has a correct value
|
|
- $isDeployed: $.env.applications[0].getAttr(deployed, false, 'io.murano.apps.apache.Tomcat')
|
|
- $.assertEqual(true, $isDeployed)
|