Example #1
0
 def test_request_dyn_variable(self):
     profile = self.make_profile()
     self.add_request(profile, dyn_variable='foo')
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http">',
         '      <thinktime random="true" value="1"/>',
         '      <request>',
         '        <dyn_variable name="foo"/>',
         '        <http method="" url="http://example.com" version="1.1"/>',
         '      </request>',
         '    </session>',
         '  </sessions>',
         '</tsung>',
     ])
Example #2
0
 def test_request_put(self):
     profile = self.make_profile()
     self.add_request(
         profile, path='/foo', method='PUT',
         content_type='application/json', content='{}')
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http">',
         '      <thinktime random="true" value="1"/>',
         '      <request>',
         ('        <http method="PUT" url="http://example.com/foo"'
          ' version="1.1" content_type="application/json" contents="{}"/>'),
         '      </request>',
         '    </session>',
         '  </sessions>',
         '</tsung>',
     ])
Example #3
0
 def test_request_dyn_variable(self):
     profile = self.make_profile()
     self.add_request(profile, dyn_variable='foo')
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http">',
         '      <thinktime random="true" value="1"/>',
         '      <request>',
         '        <dyn_variable name="foo"/>',
         '        <http method="" url="http://example.com" version="1.1"/>',
         '      </request>',
         '    </session>',
         '  </sessions>',
         '</tsung>',
     ])
Example #4
0
 def test_request_put(self):
     profile = self.make_profile()
     self.add_request(profile,
                      path='/foo',
                      method='PUT',
                      content_type='application/json',
                      content='{}')
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http">',
         '      <thinktime random="true" value="1"/>',
         '      <request>',
         ('        <http method="PUT" url="http://example.com/foo"'
          ' version="1.1" content_type="application/json" contents="{}"/>'),
         '      </request>',
         '    </session>',
         '  </sessions>',
         '</tsung>',
     ])
Example #5
0
def profile_run(request, id):
    profile = Profile.objects.get(id=id)

    test = Test.objects.create(profile=profile, running=False)

    task = tasks.run_test.delay(test, generate_config_xml(profile))

    test.task_id = task.task_id
    test.save()

    return redirect('profile_view', id=id)
Example #6
0
def profile_run(request, id):
    profile = Profile.objects.get(id=id)

    test = Test.objects.create(
        profile=profile,
        running=False
    )

    task = tasks.run_test.delay(test, generate_config_xml(profile))

    test.task_id = task.task_id
    test.save()

    return redirect('profile_view', id=id)
Example #7
0
 def test_empty_profile(self):
     profile = self.make_profile()
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http"/>',
         '  </sessions>',
         '</tsung>',
     ])
Example #8
0
 def test_empty_profile(self):
     profile = self.make_profile()
     xml = models.generate_config_xml(profile)
     self.assertXML(xml, [
         '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">',
         '<tsung loglevel="notice" version="1.0">',
         '  <clients/>',
         '  <servers>',
         '    <server host="example.com" port="80" type="tcp"/>',
         '  </servers>',
         '  <load>',
         '    <arrivalphase duration="1" phase="1" unit="minute">',
         '      <users interarrival="0.00" unit="second"/>',
         '    </arrivalphase>',
         '  </load>',
         '  <options>',
         '    <option name="user_agent" type="ts_http"/>',
         '  </options>',
         '  <sessions>',
         '    <session name="testgc" probability="100" type="ts_http"/>',
         '  </sessions>',
         '</tsung>',
     ])