Examples and reference implementation of Murano application packages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

77 lines
2.4 KiB

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
# by providing YAQL expression representing the predefined heat output
- inject(sys:HeatStack, push, $.heatOutput)
# Set up mock for the output method of env's stack in the same way
- inject($.env.stack, output, $.heatOutput)
# Set up mock for the call method of murano agent class
# by providing the name of the method from the test class
- 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, 'com.example.apache.Tomcat')
- $.assertEqual(true, $isDeployed)