Example #1
0
    def setUpClass(cls):
        super(ServiceCallTestApp, cls).setUpClass()

        # Create applications for tests
        cls.parent = cls.organization.application(
            name="%s-test-servicecall-parent" % cls.prefix,
            manifest=cls.manifest)
        cls.child = cls.organization.application(
            name="%s-test-servicecall-child" % cls.prefix,
            manifest=cls.manifest)

        # Create non shared instance to use in tests
        mnf = Manifest(
            file=os.path.join(os.path.dirname(__file__), 'child.yml'))
        mnf.patch(
            'application/components/child_app/configuration/configuration.workflows/launch/return/own/value',
            'Service call child')
        cls.child.upload(mnf)
        cls.child_instance = cls.child.launch(destroyInterval=600000)
        assert cls.child_instance
        assert cls.child_instance.ready()
        cls.child_revision = cls.child.create_revision(
            name='%s-tests-servicecall-shared' % cls.prefix,
            instance=cls.child_instance)

        cls.shared_service.add_shared_instance(cls.child_revision,
                                               cls.child_instance)
    def test_smart_application_method(self):
        org = self.org
        app = self.app
        base_app = org.get_or_create_application(name='Self-smart_application_method', manifest=app.manifest)

        # Get application
        self.assertEqual(base_app, org.application(name='Self-smart_application_method'))
        self.assertEqual(base_app, org.application(id=base_app.id))
        self.assertEqual(base_app, org.application(id=base_app.id, name='Self-smart_application_method'))

        # Modify application
        new_name_app = org.application(id=base_app.id, name='Self-smart_application_method-new-name')
        self.assertEqual(base_app, new_name_app)
        self.assertEqual('Self-smart_application_method-new-name', new_name_app.name)

        new_manifest = Manifest(file=os.path.join(os.path.dirname(__file__), 'default.yml'), name='Updated')
        new_manifest.patch('application/configuration/in.app_input', 'NEW NEW')
        new_name_app = org.application(id=base_app.id, manifest=new_manifest)
        self.assertEqual(base_app, new_name_app)
        self.assertTrue('NEW NEW' in base_app.get_manifest()['manifest'])

        # Create application
        new_application = org.application(name='Self-smart_application_method-create', manifest=app.manifest)
        self.assertEqual('Self-smart_application_method-create', new_application.name)
        self.assertTrue(new_application in org.applications)
        self.assertTrue(new_application.delete())

        # Clean
        self.assertTrue(base_app.delete())
Example #3
0
    def test_launch_hierapp_shared_instance(self):
        """ Launch hierarchical app with shared instance.
        """

        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "parent_child1.yml")) #Todo: resolve paths
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.child_one.applicationId)

        parameters = {self.child_one.name: {'revisionId': self.child_one_revision.revisionId}}

        # Api BUG?? TODO
        parameters = {
                "parent_in.child_input": "Hello from parent to child"}
        submodules = {
                "child": {
                    "revisionId": self.child_one_revision.revisionId}}


        self.parent.upload(pmnf)
        parent_instance = self.parent.launch(destroyInterval=600000, parameters=parameters, submodules=submodules)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertEqual(parent_instance.submodules[0]['id'], self.child_one_instance.instanceId)

        # Shouldn't be able to remove child while parent use it and should return error
        # TODO: BUG
        #self.assertFalse(child_instance.destroy())

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
    def test_servicecall_hierapp(self):
        """ Launch hierarchical with non shared instance and execute service call on child.
        """

        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "parent_servicecall.yml")) #Todo: resolve paths
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.child.applicationId)
        self.parent.upload(pmnf)

        parent_instance = self.parent.launch(destroyInterval=600000)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertTrue(parent_instance.submodules, 'Parent does not start submodules')
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        sub = parent_instance.submodules

        self.assertFalse(len([sid for sid in sub if sid['id'] == self.child_instance.instanceId]))  # Way i search for id

    # Instance ready. Execute workflow with servicecall

        parent_instance.runWorkflow(name='actions.child_servicecall')
        self.assertTrue(parent_instance.ready(), "Parent instance failed to execute servicall workflow")
        sleep(10)
        self.assertEqual('child Update launched', parent_instance.returnValues['parent_out.child_workflow_status'])



        # Shouldn't be able to remove child while parent use it and should return error
        # TODO: BUG
        #self.assertFalse(child_instance.destroy())

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
Example #5
0
    def test_servicecall_hierapp_with_shared_child(self):
        """ Launch hierarchical app with shared instance and execute service call on child.
        """

        pmnf = Manifest(
            file=os.path.join(os.path.dirname(__file__),
                              "parent_servicecall.yml"))  #Todo: resolve paths
        pmnf.patch(
            'application/components/child/configuration/__locator.application-id',
            self.child.applicationId)
        self.parent.upload(pmnf)

        submodules = {"child": {"revisionId": self.child_revision.revisionId}}

        parent_instance = self.parent.launch(destroyInterval=600000,
                                             submodules=submodules)
        self.assertTrue(
            parent_instance, "%s-%s: Instance failed to launch" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.ready(),
            "%s-%s: Instance not in 'running' state after timeout" %
            (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        sub = parent_instance.submodules

        self.assertTrue(
            len([
                sid for sid in sub
                if sid['id'] == self.child_instance.instanceId
            ]))  # Way i search for id

        # Instance ready. Execute workflow with servicecall

        parent_instance.runWorkflow(name='actions.child_servicecall')
        self.assertTrue(
            parent_instance.ready(),
            "Parent instance failed to execute servicall workflow")
        sleep(10)
        self.assertEqual(
            'child Update launched',
            parent_instance.returnValues['parent_out.child_workflow_status'])

        # Shouldn't be able to remove child while parent use it and should return error
        # TODO: BUG
        #self.assertFalse(child_instance.destroy())

        self.assertTrue(
            parent_instance.delete(), "%s-%s: Instance failed to destroy" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.destroyed(),
            "%s-%s: Instance not in 'destroyed' state after timeout" %
            (self.prefix, self._testMethodName))
    def setUpClass(cls):
        super(ThreeLevelHierarchicalAppTest, cls).setUpClass()

    # Create applications for tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "child.yml"))
        cls.last_child = cls.organization.application(name="%s-test-3lhierapp-last_child" % cls.prefix, manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "middle_child.yml"))
        mnf.patch('application/components/last_child/configuration/__locator.application-id', cls.last_child.applicationId)
        cls.middle_child = cls.organization.application(name="%s-test-3lhierapp-middle-child" % cls.prefix, manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "super_parent.yml"))
        mnf.patch('application/components/middle_child/configuration/__locator.application-id', cls.middle_child.applicationId)
        cls.parent = cls.organization.application(name="%s-test-3lhierapp-super-parent" % cls.prefix, manifest=mnf)
Example #7
0
    def test_launch_basic_non_shared_hierapp(self):
        """ Launch hierarchical app with child as not shared instance. Check that launching parent launches child instance.
        """
        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "parent_child1.yml")) #Todo: resolve paths
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.child_three.applicationId)
        self.parent.upload(pmnf)
        parent_instance = self.parent.launch(destroyInterval=300000)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertNotEqual(parent_instance.submodules[0]['id'], self.child_three_instance.instanceId)

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
    def setUpClass(cls):
        super(ThreeLevelHierarchicalAppTest, cls).setUpClass()

    # Create applications for tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "child.yml"))
        cls.last_child = cls.organization.application(name="%s-test-3lhierapp-last_child" % cls.prefix, manifest=mnf)
        cls.last_child_public = cls.organization_public.get_application(id=cls.last_child.applicationId)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "middle_child.yml"))
        mnf.patch('application/components/last_child/configuration/__locator.application-id', cls.last_child.applicationId)
        cls.middle_child = cls.organization.application(name="%s-test-3lhierapp-middle-child" % cls.prefix, manifest=mnf)
        cls.middle_child_public = cls.organization_public.get_application(id=cls.middle_child.applicationId)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "super_parent.yml"))
        mnf.patch('application/components/middle_child/configuration/__locator.application-id', cls.middle_child.applicationId)
        cls.parent = cls.organization.application(name="%s-test-3lhierapp-super-parent" % cls.prefix, manifest=mnf)
        cls.parent_public = cls.organization_public.get_application(id=cls.parent.applicationId)
    def setUpClass(cls):
        super(ServiceCallTestApp, cls).setUpClass()

    # Create applications for tests
        cls.parent = cls.organization.application(name="%s-test-servicecall-parent" % cls.prefix, manifest=cls.manifest)
        cls.child = cls.organization.application(name="%s-test-servicecall-child" % cls.prefix, manifest=cls.manifest)

    # Create non shared instance to use in tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), 'child.yml'))
        mnf.patch('application/components/child_app/configuration/configuration.workflows/launch/return/own/value', 'Service call child')
        cls.child.upload(mnf)
        cls.child_instance = cls.child.launch(destroyInterval=600000)
        assert cls.child_instance
        assert cls.child_instance.ready()
        cls.child_revision = cls.child.create_revision(name='%s-tests-servicecall-shared' % cls.prefix, instance=cls.child_instance)

        cls.shared_service.add_shared_instance(cls.child_revision, cls.child_instance)
    def test_switch_child_shared_standalone_and_back(self):
        """ Launch hierarchical app with non shared instance. Change child to shared, check. Switch back.
        """

        # Run parent with NON shared child
        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "hier-parent.yml"))
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.child_app.applicationId)
        self.parent_app.upload(pmnf)

        parent_instance = self.parent_app.launch(destroyInterval=3000000)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))


        non_shared_rev = self.parent_app.create_revision(name='non-shared-child', instance=parent_instance)

        # Ensure we use non shared instance
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertNotEqual(parent_instance.submodules[0]['id'], self.child_instance.instanceId)

        # Reconfigure parent to use shared child
        parameters = {
            'parent_in.child_input': 'Set on reconfiguration'}
        submodules = {
            'child': {
                'revisionId': self.child_rev.revisionId}}


        self.assertTrue(parent_instance.reconfigure(parameters=parameters, submodules=submodules))

        # Check we use shared instance
        self.assertTrue(parent_instance.ready(), "Instance failed to reconfigure")
        self.assertTrue(parent_instance.submodules, 'No submodules found')
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertEqual(parent_instance.submodules[0]['id'], self.child_instance.instanceId)

        # Switch back to non shared instance
        self.assertTrue(parent_instance.reconfigure(revisionId=non_shared_rev.revisionId))

        # Check we use shared instance again
        self.assertTrue(parent_instance.ready(), "Instance failed to reconfigure")
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertNotEqual(parent_instance.submodules[0]['id'], self.child_instance.instanceId)

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
    def test_new_child_application(self):
        """ Launch hierarchical app with child as not shared instance. Change __locator and check new child launched
        """

        # Run parent with child
        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "hier-parent.yml"))
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.child_app.applicationId)

        self.parent_app.upload(pmnf)
        parent_instance = self.parent_app.launch(destroyInterval=300000)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')


        # Run parent with new_child
        pmnf.patch('application/components/child/configuration/__locator.application-id', self.new_child_app.applicationId)
        self.parent_app.upload(pmnf)
        new_parent_instance = self.parent_app.launch(destroyInterval=300000)
        self.assertTrue(new_parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(new_parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertEqual(new_parent_instance.submodules[0]['status'], 'Running')

        new_rev = self.parent_app.create_revision(name='tests-new-child', instance=new_parent_instance)

        # Reconfigure old parent with new revision
        parent_instance.reconfigure(revisionId=new_rev.revisionId)

        # Check results
        self.assertTrue(new_parent_instance.ready(), "Instance failed to reconfigure")
        self.assertNotEqual(parent_instance.submodules[0]['id'], new_parent_instance.submodules[0]['id'])
        self.assertEqual("Child2 welcomes you", new_parent_instance.returnValues['parent_out.child_out'])

        self.assertTrue(new_rev.delete)

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
        self.assertTrue(new_parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(new_parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
    def setUpClass(cls):
        super(ThreeLevelHierappReconfiguration, cls).setUpClass()

    # Create applications for tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "3level-child.yml"))
        cls.last_child = cls.organization.application(name="%s-reconfiguration-3lhierapp-last_child" % cls.prefix, manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "3level-middle-child.yml"))
        mnf.patch('application/components/last_child/configuration/__locator.application-id', cls.last_child.applicationId)
        cls.middle_child = cls.organization.application(name="%s-reconfiguration-3lhierapp-middle-child" % cls.prefix, manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), "3level-super-parent.yml"))
        mnf.patch('application/components/middle_child/configuration/__locator.application-id', cls.middle_child.applicationId)
        cls.parent = cls.organization.application(name="%s-reconfiguration-3lhierapp-super-parent" % cls.prefix, manifest=mnf)


    # Create shared last_child
        cls.last_child_instance = cls.last_child.launch(destroyInterval=300000)
        assert cls.last_child_instance.ready()
        cls.last_child_rev = cls.last_child.create_revision(name='tests-reconf-3l-hierapp-shared', instance=cls.last_child_instance)
        cls.shared_service.add_shared_instance(cls.last_child_rev, cls.last_child_instance)
Example #13
0
    def test_smart_application_method(self):
        org = self.org
        app = self.app
        base_app = org.get_or_create_application(
            name='Self-smart_application_method', manifest=app.manifest)

        # Get application
        self.assertEqual(base_app,
                         org.application(name='Self-smart_application_method'))
        self.assertEqual(base_app, org.application(id=base_app.id))
        self.assertEqual(
            base_app,
            org.application(id=base_app.id,
                            name='Self-smart_application_method'))

        # Modify application
        new_name_app = org.application(
            id=base_app.id, name='Self-smart_application_method-new-name')
        self.assertEqual(base_app, new_name_app)
        self.assertEqual('Self-smart_application_method-new-name',
                         new_name_app.name)

        new_manifest = Manifest(file=os.path.join(os.path.dirname(__file__),
                                                  'default.yml'),
                                name='Updated')
        new_manifest.patch('application/configuration/in.app_input', 'NEW NEW')
        new_name_app = org.application(id=base_app.id, manifest=new_manifest)
        self.assertEqual(base_app, new_name_app)
        self.assertTrue('NEW NEW' in base_app.get_manifest()['manifest'])

        # Create application
        new_application = org.application(
            name='Self-smart_application_method-create', manifest=app.manifest)
        self.assertEqual('Self-smart_application_method-create',
                         new_application.name)
        self.assertTrue(new_application in org.applications)
        self.assertTrue(new_application.delete())

        # Clean
        self.assertTrue(base_app.delete())
Example #14
0
    def test_launch_hierapp_with_combined_child_instances(self):
        """ Launch hierarchical app with two shared and one non shared instance.
        """

        pmnf = Manifest(file=os.path.join(os.path.dirname(__file__), "parent_childs.yml")) #Todo: resolve paths
        pmnf.patch('application/components/child-one/configuration/__locator.application-id', self.child_one.applicationId)
        pmnf.patch('application/components/child-two/configuration/__locator.application-id', self.child_two.applicationId)
        pmnf.patch('application/components/child-three/configuration/__locator.application-id', self.child_three.applicationId)

        # TODO: bug. Need to pass params
        parameters = {
                "parent_in.child_three_input": "Hello from parent to child3 BUG"}
        submodules = {
                "child-one": {
                    "revisionId": self.child_one_revision.revisionId},
                "child-two": {
                    "revisionId": self.child_two_revision.revisionId}}


        self.parent.upload(pmnf)
        parent_instance = self.parent.launch(destroyInterval=600000, parameters=parameters, submodules=submodules)
        self.assertTrue(parent_instance, "%s-%s: Instance failed to launch" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.ready(),"%s-%s: Instance not in 'running' state after timeout" % (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        sub = parent_instance.submodules

        self.assertTrue(len([sid for sid in sub if sid['id'] == self.child_one_instance.instanceId]))  # Way i search for id
        self.assertTrue(len([sid for sid in sub if sid['id'] == self.child_two_instance.instanceId]))
        self.assertFalse(len([sid for sid in sub if sid['id'] == self.child_three_instance.instanceId]))


        # Shouldn't be able to remove child while parent use it and should return error
        # TODO: BUG
        #self.assertFalse(child_instance.destroy())

        self.assertTrue(parent_instance.delete(), "%s-%s: Instance failed to destroy" % (self.prefix, self._testMethodName))
        self.assertTrue(parent_instance.destroyed(), "%s-%s: Instance not in 'destroyed' state after timeout" % (self.prefix, self._testMethodName))
    def setUpClass(cls):
        super(ThreeLevelHierappReconfiguration, cls).setUpClass()

        # Create applications for tests
        mnf = Manifest(
            file=os.path.join(os.path.dirname(__file__), "3level-child.yml"))
        cls.last_child = cls.organization.application(
            name="%s-reconfiguration-3lhierapp-last_child" % cls.prefix,
            manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__),
                                         "3level-middle-child.yml"))
        mnf.patch(
            'application/components/last_child/configuration/__locator.application-id',
            cls.last_child.applicationId)
        cls.middle_child = cls.organization.application(
            name="%s-reconfiguration-3lhierapp-middle-child" % cls.prefix,
            manifest=mnf)

        mnf = Manifest(file=os.path.join(os.path.dirname(__file__),
                                         "3level-super-parent.yml"))
        mnf.patch(
            'application/components/middle_child/configuration/__locator.application-id',
            cls.middle_child.applicationId)
        cls.parent = cls.organization.application(
            name="%s-reconfiguration-3lhierapp-super-parent" % cls.prefix,
            manifest=mnf)

        # Create shared last_child
        cls.last_child_instance = cls.last_child.launch(destroyInterval=300000)
        assert cls.last_child_instance.ready()
        cls.last_child_rev = cls.last_child.create_revision(
            name='tests-reconf-3l-hierapp-shared',
            instance=cls.last_child_instance)
        cls.shared_service.add_shared_instance(cls.last_child_rev,
                                               cls.last_child_instance)
Example #16
0
    def setUpClass(cls):
        super(HierarchicalAppTest, cls).setUpClass()

    # Create applications for tests
        cls.parent = cls.organization.application(name="%s-test-hierapp-parent" % cls.prefix, manifest=cls.manifest)
        cls.child_one = cls.organization.application(name="%s-test-hierapp-child-one" % cls.prefix, manifest=cls.manifest)
        cls.child_two = cls.organization.application(name="%s-test-hierapp-child-two" % cls.prefix, manifest=cls.manifest)
        cls.child_three = cls.organization.application(name="%s-test-hierapp-child-tree" % cls.prefix, manifest=cls.manifest)

    # Create shared instance ONE to use in tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), 'child.yml'))
        mnf.patch('application/components/child_app/configuration/configuration.workflows/launch/return/own/value', 'Child1 Ahoy!')
        cls.child_one.upload(mnf)
        cls.child_one_instance = cls.child_one.launch(destroyInterval=600000)
        assert cls.child_one_instance
        assert cls.child_one_instance.ready()
        cls.child_one_revision = cls.child_one.create_revision(name='%s-tests-basic-hierapp-shared-one' % cls.prefix, instance=cls.child_one_instance)


    # Create shared instance Two to use in tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), 'child.yml'))
        mnf.patch('application/components/child_app/configuration/configuration.workflows/launch/return/own/value', 'Child2 Welcomes you')
        cls.child_two.upload(mnf)
        cls.child_two_instance = cls.child_two.launch(destroyInterval=600000)
        assert cls.child_two_instance
        assert cls.child_two_instance.ready()
        cls.child_two_revision = cls.child_two.create_revision(name='%s-tests-basic-hierapp-shared-two' % cls.prefix, instance=cls.child_two_instance)

        #cls.shared_service = cls.organization.create_shared_service(name='%s-HierarchicalAppTest-instance' % cls.prefix)
        cls.shared_service.add_shared_instance(cls.child_one_revision, cls.child_one_instance)
        cls.shared_service.add_shared_instance(cls.child_two_revision, cls.child_two_instance)


    # Create non shared instance Three to use in tests
        mnf = Manifest(file=os.path.join(os.path.dirname(__file__), 'child.yml'))
        mnf.patch('application/components/child_app/configuration/configuration.workflows/launch/return/own/value', 'Child3 raises hands')
        cls.child_three.upload(mnf)
        cls.child_three_instance = cls.child_three.launch(destroyInterval=600000)
        assert cls.child_three_instance
        assert cls.child_three_instance.ready()
Example #17
0
    def test_new_child_application(self):
        """ Launch hierarchical app with child as not shared instance. Change __locator and check new child launched
        """

        # Run parent with child
        pmnf = Manifest(
            file=os.path.join(os.path.dirname(__file__), "hier-parent.yml"))
        pmnf.patch(
            'application/components/child/configuration/__locator.application-id',
            self.child_app.applicationId)

        self.parent_app.upload(pmnf)
        parent_instance = self.parent_app.launch(destroyInterval=300000)
        self.assertTrue(
            parent_instance, "%s-%s: Instance failed to launch" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.ready(),
            "%s-%s: Instance not in 'running' state after timeout" %
            (self.prefix, self._testMethodName))

        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')

        # Run parent with new_child
        pmnf.patch(
            'application/components/child/configuration/__locator.application-id',
            self.new_child_app.applicationId)
        self.parent_app.upload(pmnf)
        new_parent_instance = self.parent_app.launch(destroyInterval=300000)
        self.assertTrue(
            new_parent_instance, "%s-%s: Instance failed to launch" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            new_parent_instance.ready(),
            "%s-%s: Instance not in 'running' state after timeout" %
            (self.prefix, self._testMethodName))

        self.assertEqual(new_parent_instance.submodules[0]['status'],
                         'Running')

        new_rev = self.parent_app.create_revision(name='tests-new-child',
                                                  instance=new_parent_instance)

        # Reconfigure old parent with new revision
        parent_instance.reconfigure(revisionId=new_rev.revisionId)

        # Check results
        self.assertTrue(new_parent_instance.ready(),
                        "Instance failed to reconfigure")
        self.assertNotEqual(parent_instance.submodules[0]['id'],
                            new_parent_instance.submodules[0]['id'])
        self.assertEqual(
            "Child2 welcomes you",
            new_parent_instance.returnValues['parent_out.child_out'])

        self.assertTrue(new_rev.delete)

        self.assertTrue(
            parent_instance.delete(), "%s-%s: Instance failed to destroy" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.destroyed(),
            "%s-%s: Instance not in 'destroyed' state after timeout" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            new_parent_instance.delete(), "%s-%s: Instance failed to destroy" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            new_parent_instance.destroyed(),
            "%s-%s: Instance not in 'destroyed' state after timeout" %
            (self.prefix, self._testMethodName))
# If env is not set up yet, do it. (dirty check)
if not env.json()['areProvidersAvailable']:
   prepare_env(org)
   print "Prepearing environment"
print "Environment initialized"

""" We need to create child application that runs database, using db_manifest.
After, wee need to create parent application that will use our DB application as a child"""

# Create new application for DB
db_app = org.application(manifest=db_manifest, name='database')
print "Creating DB app"

# Create main application. First, we need to patch manifest, telling where to find database. Place id of created db-application
app_manifest.patch('application/components/db/configuration/__locator.application-id', db_app.applicationId)
main_app = org.application(manifest=app_manifest, name='main_site')
print "Creating MAIN app"

# Now we can launch application.
instance = main_app.launch()
print "Launching..."

# This way we wait instance to came up in 15 minutes or break.
assert instance.ready(15)
print "Instance Running"

# Check our app could be accessed via http
site = requests.get(instance.returnValues['endpoint.url'])
assert site.text.find('PetClinic :: a Spring Framework demonstration')
print "Checking site: alive"
Example #19
0
    def test_switch_child_shared_standalone_and_back(self):
        """ Launch hierarchical app with non shared instance. Change child to shared, check. Switch back.
        """

        # Run parent with NON shared child
        pmnf = Manifest(
            file=os.path.join(os.path.dirname(__file__), "hier-parent.yml"))
        pmnf.patch(
            'application/components/child/configuration/__locator.application-id',
            self.child_app.applicationId)
        self.parent_app.upload(pmnf)

        parent_instance = self.parent_app.launch(destroyInterval=3000000)
        self.assertTrue(
            parent_instance, "%s-%s: Instance failed to launch" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.ready(),
            "%s-%s: Instance not in 'running' state after timeout" %
            (self.prefix, self._testMethodName))

        non_shared_rev = self.parent_app.create_revision(
            name='non-shared-child', instance=parent_instance)

        # Ensure we use non shared instance
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertNotEqual(parent_instance.submodules[0]['id'],
                            self.child_instance.instanceId)

        # Reconfigure parent to use shared child
        parameters = {'parent_in.child_input': 'Set on reconfiguration'}
        submodules = {'child': {'revisionId': self.child_rev.revisionId}}

        self.assertTrue(
            parent_instance.reconfigure(parameters=parameters,
                                        submodules=submodules))

        # Check we use shared instance
        self.assertTrue(parent_instance.ready(),
                        "Instance failed to reconfigure")
        self.assertTrue(parent_instance.submodules, 'No submodules found')
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertEqual(parent_instance.submodules[0]['id'],
                         self.child_instance.instanceId)

        # Switch back to non shared instance
        self.assertTrue(
            parent_instance.reconfigure(revisionId=non_shared_rev.revisionId))

        # Check we use shared instance again
        self.assertTrue(parent_instance.ready(),
                        "Instance failed to reconfigure")
        self.assertEqual(parent_instance.submodules[0]['status'], 'Running')
        self.assertNotEqual(parent_instance.submodules[0]['id'],
                            self.child_instance.instanceId)

        self.assertTrue(
            parent_instance.delete(), "%s-%s: Instance failed to destroy" %
            (self.prefix, self._testMethodName))
        self.assertTrue(
            parent_instance.destroyed(),
            "%s-%s: Instance not in 'destroyed' state after timeout" %
            (self.prefix, self._testMethodName))
# If env is not set up yet, do it. (dirty check)
if not env.json()['areProvidersAvailable']:
   prepare_env(org)
   print "Prepearing environment"
print "Environment initialized"

""" We need to create child application that runs database, using db_manifest.
After, wee need to create parent application that will use our DB application as a child"""

# Create new application for DB
db_app = org.application(manifest=db_manifest, name='database')
print "Creating DB app"

# Create main application. First, we need to patch manifest, telling where to find database. Place id of created db-application
app_manifest.patch('application/components/db/configuration/__locator.application-id', db_app.applicationId)
main_app = org.application(manifest=app_manifest, name='main_site')
print "Creating MAIN app"

# Now we can launch application.
instance = main_app.launch()
print "Launching..."

# This way we wait instance to came up in 15 minutes or break.
assert instance.ready(15)
print "Instance Running"

# Check our app could be accessed via http
site = requests.get(instance.returnValues['endpoint.url'])
assert site.text.find('PetClinic :: a Spring Framework demonstration')
print "Checking site: alive"