Hey all, first time messaging, hoping to get some ...
# box-products
m
Hey all, first time messaging, hoping to get some help. I am getting started with unit testing in TestBox using the xUnit syntax. I want to do a simple test on a function that renames a postgres table column. In the test I create a new table with one column and do the testing. However, I get the error
datasource [name] doesn't exist
Was trying to look through all the files and .jsons and such, but nothing seemed to do the trick. Did manually set the database in a couple spots(including using data cfconfig save) Any help would be appreciated 😃
b
How is the datasource normally defined in our application? A setting in the server admin? The `Application.cfc`'s
this.datsources
?
m
We import cfconfig through our Dockerfile
b
Ok. So did it import this time?
Have you looked in the admin to see if it's there?
I'm not really not clear on what steps you've taken to troubleshoot, but it seems like there are some very easy and obvious steps that haven't been done
The fact his happens to be in a test shouldn't really matter. This is just a matter of a setting not existing.
m
Yes it imports for the rest of the code without any problem, there is only an issue when doing the tests. I did do a cfconfig datasource list from=servername and that it showed up ther
Our source has the admin page turned off for security reasons
b
That doesn't really make sense-- if the datasource is defined in the CF administrator, then it's defined for the whole entire server, regardless of whether the code in question happens to be a unit test or not
for security reasons
On Development??
m
I would agree it doesn't make sense either ahah, I am very brand new to this
Yes even on devlopment
b
If I were to guess, you have some sort of setup where you're starting a second server with different config to run your tests. But that's just a guess-- it's hard to tell what you have going on.
You need to have some words with whoever is in charge
That's ridiculous
I've never heard of that in dev!
They need to back off a little if they expect you to be able to get any work done
šŸ’Æ 2
ā˜šŸ¾ 1
Honestly, it's bad enough they make you use Docker for local dev, lol
m
What's bad about using Docker for local dev?
b
Nothing, other than it's a bloated, slow, annoying, complex, hard-to-debug mess šŸ™‚
When you could just be running
Copy code
server start
with literally nothing installed and you'd be ready to go!
I love docker, but I avoid it like the plague for just doing quick local dev. it adds about 1000 moving parts to everything
Now you can't get to the file system because it's wrapped in a container-- you can't get to the networking stack because it's wrapped in a container. You can't debug the image if the image won't build, you can't access something unless you've found the ports, you can't easily access log files, etc
The list goes on šŸ™‚
m
Yeah that makes sense!
b
Anyway, ignore my ramblings on Docker. I'm jaded, lol
Nice profile pic BTW, do you play trumpet I assume?
m
I used to during school since fifth grade. Still have it though, probably very rusty!
b
Nice! I'm a brass player myself. I fill in a local jazz band occasionally, but practice with my daughters a lot.
m
Oh that's awesome, which brass instrument(s) do you play?
b
I started on Trumpet, but I really like playing Euphonium which my oldest daughter switched to. It's the same fingers and you can get TC music for most arrangements
m
Oh yeah makes sense. I played Tuba for a while as well, same fingerings as well
b
Right, most low brass are non-transposing when they play bass clef, but when you play treble cleff Euphonium you transpose like any Bb instrument like Trumpet or Clarinet
but yeah, very similar fingerings, the BC players just have different notes that go to each one, lol
Anway, as far as security-- you can do what you want on your local server for debugging, right? I don't know how your CF admin is being blocked, but you can turn that off on your machine, right? I mean, are they going to march into your office and smack your knuckles with a ruler because the CF admin was visible on your local docker container?
The first questions to ask are • what docker image are you using • what CF engine are you running • how and where is your CFConfig imported • how and where is the server that your tests run on started? • Is there more than one server living inside the docker container (confirm with
server list
)
d
What we do is block access to cf admin from the public internet. you have to be in the building or on the vpn to get to it. I really think that's sufficient. To put it differently, if an attacker is in the building or on the vpn, you have much bigger problems!
b
In this case the attacker would need to be in the dev's computer!
m
• lucee/lucee:5.3.8.206-nginx • Lucee 5 • Our Dockerfile imports our main
.cfonfig
but working within the container there is another box.json • I docker exec into the container, and use the
box start
command. Its a server from our box.Json file • There are three servers in there. Only one is running • Our Database is also running in a separate container
Nginix automatically blocks it on a container level, like hitting anything with `/Lucee`That's what I have been told anyway - Tbh this is my first intern postiion, I only started a few weeks ago, trying to learn all the ropes! So I didn't even know it was a thing before this šŸ˜†
b
Sorry, my power went out so I'll reply when I can...
m
No problem šŸ™‚
b
Ok, I'm back
Nginix automatically blocks it on a container level,
This is common, and the workaround is easy. expose the HTTP port Lucee is listening on (that nginx proxies to) and just hit Lucee directly to visit the admin
I have a client who has a docker compose for local CF dev with nginx and the works and that's exactly what I do
• lucee/lucee:5.3.8.206-nginx
May I interest you in the
ortussolutions/commandbox
docker images šŸ™‚ They have CFConfig and more baked in AND they also do automatically configurable lockdowns based on environment/profile!! So you set your
profile=production
env var and you're 100% locked down, but you set your
profile=development
env var and you're unlocked for dev. It's amazing šŸ™‚
• There are three servers in there. Only one is running
This sounds a little terrifying. Docker containers are designed to run one server/site. I don't know what crazy they have going on, but I can almost guaruntee your datasoruces are being imported into one server and your tests are running on another server
use the
box start
command
This makes negative 0 sense. You're using the
lucee/lucee
docker image, which already has a baked in Tomcat/Lucee installation, but you also installed CommandBox and then you're firing up more Lucee servers via CommandBox? WUT??
This is a setup unlike any I've ever seen and any knuckly cracking needs to be done on whoever dreamed this up šŸ˜†
It's odd enough that you have 3 servers in one container, but having a mixure of Tomcat and CommandBox is just wild
m
I believe I accidentally created the 3 servers so please don't crack my knuckles I need them for more typing šŸ˜‚ I tried forgetting them but it didn't seem to shut them all down. It's specifically the command box servers I should add "box server start" not sure if that's what you were meaning or not. I think we also recently migrated a lot of the tools and services and stuff we used so it's still getting you to date, but I could be wrong
And sorry can't check all you said rn, logged off for the day :)
I will definitely look into that docker image though!
And yeah that's how we do it, docker compose as well using that nginx
b
Right, the point is, if you're using
lucee/lucee
to start your Lucee server, then your tests should be running on that server. But if you're wanting to make use of "Box" features like
box.json
, CFConfig, and
server.json
, then I'd ditch the Lucee image entirely and use the Ortus CommandBox one.
Of course, I'm biased, but you'll find it comes ready to do out of the box what you've probably spent a great deal of time trying to shoehorn into the "official" Lucee images.
m
Ahh yeah I get that. I'll definitely bring it up with that other devs, thanks for the all the info!
b
It's also worth noting the CommandBox image comes with Ortus' professional support services if you want. You can pay us to actually sit down and help you set them up.