1 # Xtesting in a nutshell
3 Xtesting is a simple framework to assemble sparse test cases and to accelerate
4 the adoption of continuous integration best practices. By managing all
5 the interactions with the components (test scheduler, test results database,
6 artifact repository), it allows the developer to work only on the test suites
7 without diving into CI/CD.
9 It asks for a few low constraints
10 [quickly achievable](https://www.sdxcentral.com/articles/news/opnfvs-6th-release-brings-testing-capabilities-that-orange-is-already-using/2018/05/)
11 to verify multiple components in the same CI/CD toolchain. Even more, it brings
12 the capability to run third-party test cases in our CI toolchains and then to
13 also rate network functions by the coverage.
16 [the Katacoda scenarios](https://www.katacoda.com/ollivier/courses/xtestingci)
17 to try Xtesting. You will love them!
19 ## [Write your own Xtesting driver](https://www.katacoda.com/ollivier/courses/xtestingci/firstdriver)
21 ### dump all the following files in an empty dir
28 # pylint: disable=missing-docstring
37 from xtesting.core import testcase
40 class Weather(testcase.TestCase):
42 url = "https://samples.openweathermap.org/data/2.5/weather"
43 city_name = "London,uk"
44 app_key = "439d4b804bc8187953eb36d2a8c26a02"
46 def run(self, **kwargs):
48 self.start_time = time.time()
49 req = requests.get("{}?q={}&&appid={}".format(
50 self.url, self.city_name, self.app_key))
51 req.raise_for_status()
53 os.makedirs(self.res_dir, exist_ok=True)
54 with open('{}/dump.txt'.format(self.res_dir), 'w+') as report:
55 json.dump(data, report, indent=4, sort_keys=True)
57 if data["main"][key] > kwargs[key]:
58 self.result = self.result + 100/len(kwargs)
59 self.stop_time = time.time()
60 except Exception: # pylint: disable=broad-except
61 print("Unexpected error:", sys.exc_info()[0])
63 self.stop_time = time.time()
71 # pylint: disable=missing-docstring
76 setup_requires=['pbr>=2.0.0'],
92 weather = weather:Weather
99 requests!=2.20.0,!=2.24.0 # Apache-2.0
114 project_name: weather
125 project_name: weather
136 project_name: weather
152 project_name: weather
171 RUN apk --no-cache add --update python3 py3-pip py3-wheel git && \
172 git init /src && pip3 install /src
173 COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml
174 CMD ["run_tests", "-t", "all"]
179 Deploy your own Xtesting toolchain
183 . xtesting/bin/activate
185 ansible-galaxy install collivier.xtesting
186 ansible-galaxy collection install ansible.posix community.general community.grafana community.kubernetes
187 ansible-playbook site.yml
195 sudo docker build -t 127.0.0.1:5000/weather .
198 Publish your container on your local repository
201 sudo docker push 127.0.0.1:5000/weather
204 ### That's all folks!