Beispiel #1
0
import requests
import time
import configuration
from mamba import description, context, it
from expects import expect, be_true, have_length, equal, be_a, have_property, be_none

headers = {'content-type': 'application/json', 'accept': 'application/json'}
with description('Zipkin tracing functionality'):
    with before.all:
        #Read Config file
        configuration.setenv(self)

    with context('Deploy Zipkin and make sure port forwarded to localhost'):
        with it('Bookinfo Zipkin tracing feature'):
            for _ in range(10):
                r = requests.get(self.url)
                r.status_code
                expect(r.status_code).to(equal(200))
            r1 = requests.get(self.zipkin)
            r1.status_code
            expect(r1.status_code).to(equal(200))
            if 'productpage' in r1.text:
                expect(0).to(equal(0))
            else:
                expect(0).not_to(equal(0))
            configuration.generate_request(self)
Beispiel #2
0
        with it('Testing route "jason" user to V2'):
            while self.total_count < self.request_count:
                cookie = {'user': '******'}
                u = self.url
                r = requests.get('http://' + self.GATEWAY_URL + '/productpage',
                                 cookies=cookie)
                expect(r.status_code).to(equal(200))
                if 'color="black"' not in r.text and 'color="red"' not in r.text:
                    self.total_count += 1
                    self.v1_count += 1
                elif 'color="black"' in r.text:
                    self.total_count += 1
                    self.v2_count += 1
                elif 'color="red"' in r.text:
                    self.total_count += 1
                    self.v3_count += 1
                else:
                    self.total_count += 1

            print(" | V1 Hit=" + str(self.v1_count) + " | V2 Hit=" +
                  str(self.v2_count) + " | V3 Hit=" + str(self.v3_count) +
                  " | Total Hit=" + str(self.total_count) + " |")
            expect(self.v1_count).to(equal(0))
            expect(self.v2_count).not_to(equal(0))
            expect(self.v3_count).to(equal(0))
            configuration.generate_request(self, rule_name)

    with context('Clean environment'):
        with it('Delete routing rule'):
            Rule.delete(rule_name)