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 Note that [running MongoDB 5.0+ requires _avx_ CPU instruction set](https://www.mongodb.com/docs/manual/administration/production-notes/#x86_64)
22 that is usually shipped in all recent _x86_ hardware processors.
23 Though, it may not be available in your virtualized environments.
24 For example, Qemu _avx_ support is only available [since version 7.2](https://github.com/nodkz/mongodb-memory-server/issues/710#issuecomment-1297462935)
25 and must be explicitly enabled (e.g. with the argument _-cpu max_).
27 You can check the presence of the _avx_ CPU instruction set on your processor
28 with the following command.
30 grep '^processor\|^flags.* avx' /proc/cpuinfo
33 ### dump all the following files in an empty dir
40 # pylint: disable=missing-docstring
49 from xtesting.core import testcase
52 class Weather(testcase.TestCase):
54 url = "https://samples.openweathermap.org/data/2.5/weather"
55 city_name = "London,uk"
56 app_key = "439d4b804bc8187953eb36d2a8c26a02"
58 def run(self, **kwargs):
60 self.start_time = time.time()
61 req = requests.get("{}?q={}&&appid={}".format(
62 self.url, self.city_name, self.app_key))
63 req.raise_for_status()
65 os.makedirs(self.res_dir, exist_ok=True)
66 with open('{}/dump.txt'.format(self.res_dir), 'w+') as report:
67 json.dump(data, report, indent=4, sort_keys=True)
69 if data["main"][key] > kwargs[key]:
70 self.result = self.result + 100/len(kwargs)
71 self.stop_time = time.time()
72 except Exception: # pylint: disable=broad-except
73 print("Unexpected error:", sys.exc_info()[0])
75 self.stop_time = time.time()
83 # pylint: disable=missing-docstring
88 setup_requires=['pbr>=2.0.0'],
104 weather = weather:Weather
111 requests!=2.20.0,!=2.24.0 # Apache-2.0
126 project_name: weather
137 project_name: weather
148 project_name: weather
164 project_name: weather
183 RUN apk --no-cache add --update python3 py3-pip py3-wheel git py3-lxml && \
184 git init /src && pip3 install /src
185 COPY testcases.yaml /etc/xtesting/testcases.yaml
186 CMD ["run_tests", "-t", "all"]
196 - role: collivier.xtesting
198 registry_deploy: true
212 Deploy your own Xtesting toolchain
215 virtualenv xtesting -p python3 --system-site-packages
216 . xtesting/bin/activate
218 ansible-galaxy install collivier.xtesting
219 ansible-galaxy collection install ansible.posix community.general community.grafana \
220 community.kubernetes community.docker community.postgresql
221 ansible-playbook site.yml
229 sudo docker build -t 127.0.0.1:5000/weather .
232 Publish your container on your local registry
235 sudo docker push 127.0.0.1:5000/weather
240 Jenkins is accessible via http://127.0.0.1:8080 and you can identify yourself
241 as admin to be allowed to trigger a build:
245 The default Jenkins view lists all the Jenkins jobs. You can easily find your
246 main job, weather-latest-daily, via the Jenkins view named weather.
248 You're ready to start a new build of weather-latest-daily without changing
249 the default parameters.
251 The test case is executed after a few seconds and all the test outputs are
252 accessible via the console icons. If you open the
253 weather-127_0_0_1-weather-latest-humidity-run, you will first read:
254 - the test output highlighting its status
255 - a link to the test database where its results are stored
256 - a couple of links to its artifacts automatically published
258 A zip file dumping all test campaign data is printed in the
259 weather-latest-zip console.
261 ### That's all folks!