baas-project/baas

Fix running unit tests on the CI

Closed this issue · 2 comments

Summary

Some of the features for the database and the REST API require accessing files on disk, which we do not have access to on Github. There are probably some way to get around this or mock accessing the disks. However, it is not a very high priority right now provided that developers run the test suite on their own first.

Example

An example of the way that it is currently broken is this run of the CI during the development of the database: https://github.com/baas-project/baas/runs/4091566066?check_suite_focus=true

Hi, @ValentijnvdBeek
I resolved privileged problem to access some files.
but it cannot to be passed the test of config_test.go because I cannot find the example of /etc/baas.toml.
Could tell me how to write that config file?

https://github.com/u5surf/baas/runs/4196057947?check_suite_focus=true

[2021-11-13 00:59:50] - ERROR - Cannot open the configuration file: 'open /etc/baas.toml: no such file or directory'
Failed to fire hook: sending log: Post "http://control_server:4848/log": dial tcp: lookup control_server: Temporary failure in name resolution
[2021-11-13 00:59:50] - ERROR - Cannot read configuration file: 'invalid argument'
Failed to fire hook: sending log: Post "http://control_server:4848/log": dial tcp: lookup control_server: Temporary failure in name resolution
[2021-11-13 00:59:51] - INFO - Creating the configuration file object
--- FAIL: TestConfigFile (0.10s)
    config_test.go:11: 
        	Error Trace:	config_test.go:11
        	Error:      	Should be true
        	Test:       	TestConfigFile
    config_test.go:12: 
        	Error Trace:	config_test.go:12
        	Error:      	Should be true
        	Test:       	TestConfigFile
FAIL
FAIL	github.com/baas-project/baas/management_os/entrypoint	0.108s

HI @u5surf,

First thank you for your interest in the project and your help! I really appreciate it.

Basically, the logic here is that the configuration code (for now) run as a part of the management server on the booted image. So that file is from management_os/config/config.toml to /etc/baas.toml in the Dockerfile. I don't think we can write to that part of the filesystem at all.

So it might be better to slightly refactor the configuration package instead. That can be a simple as just splitting the get configuration file functionality from the singleton so you can pass a different file (or just values directly) which decouples the dependency on the layout of the machine. Otherwise you can mock it or delete the test entirely, it is a bit of a grass is green style test right now.

Oh and, finally, thank you again for your work. However due to an oversight of the previous stewards of this repository it is currently unlicensed and therefore (technically) proprietary. Luckily our contract with the university handed our rights over so we can easily relicense it with the correct license. Of course this doesn't count for any of your code, so if you could indicate what license if any you would feel comfortable with that would be great. You can also separately license your own code of course :)