Questions regarding the relationship between run CN and tests

Hello,

I wish to modify the current tests for my study. Seeing the code, I was wondering where within the code initializes and shuts down the core network.

I wish to run the entire core with run.sh, execute my tests and then kill the core whenever I want. I run the core successufully but when I try to run testRegistration an error appears that NFR IP is already bind in. I guess this happens because within the test, it tries to start the core again which is already initialized. Do you know any work around this? I have seen some people from this forum do this without this error.

Thanks

@classo88
If you want to test UE Registration via testRegistration then just execute below command.
./test.sh TestRegistration

If you want to just run the core network then just ./run.sh

So you need not run both run.sh & test.sh. Just execute one of then based on the scenario.

Thanks,
Rashmi

Hello,

Maybe I haven’t explained correctly. All the tests available initialized the core, execute their test and shuts it down (haven’t found where in the code though).

What I would like is to initialize the core, then in another terminal execute my prepared tests (it can be several), and finally shut down the core when si choose.

There is a post called “ping to google” or something like that where the user @thornton suggest to this by I get the letter message when running a test after core is up of NFR bind up address is already in use.

@classo88

If you want to run only the core then, IMO you should run it by executing ./run.sh & in another terminal you can execute tests prepared by you.

Thanks,
Rashmi

Hello again,

I did what you said. After running the core and trying to execute exclusively TestRegistration test, the folowing error message appears:

=== RUN TestRegistration
— FAIL: TestRegistration (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x260 pc=0xb65a87]

goroutine 20 [running]:
testing.tRunner.func1.1(0x1212840, 0x1fe9a70)
/usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc00045b9e0)
/usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x1212840, 0x1fe9a70)
/usr/local/go/src/runtime/panic.go:969 +0x166
go.mongodb.org/mongo-driver/mongo.newDatabase(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0004ab550)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/database.go:37 +0x67
go.mongodb.org/mongo-driver/mongo.(*Client).Database(…)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/client.go:418
free5gc/lib/MongoDBLibrary.RestfulAPIPutOne(0x142543e, 0x3e, 0xc000463980, 0xc0004dd350, 0xc0004d9f48)
/home/carlos/free5gc_mongo/lib/MongoDBLibrary/api_mongoDB.go:73 +0x68
free5gc/src/test.InsertAuthSubscriptionToMongoDB(0x13f3a82, 0x12, 0x13d8f87, 0x6, 0xc0004adb60, 0x13e6ec4, 0xc, 0x13d6435, 0x4, 0x0, …)
/home/carlos/free5gc_mongo/src/test/mongodb.go:30 +0x1ba
free5gc/src/test_test.TestRegistration(0xc00045b9e0)
/home/carlos/free5gc_mongo/src/test/registration_test.go:76 +0x795
testing.tRunner(0xc00045b9e0, 0x1435d18)
/usr/local/go/src/testing/testing.go:991 +0xdc
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1042 +0x357
exit status 2
FAIL free5gc/src/test 0.027s

I do not understand what is the problem with mongodb since when initializing the core network, the NFR is also initialized and with that the db.

Thank you,

If you want to run the core network by yourself then run the test,
just comment out the function init at src/test/ngsetup_test.go

and maybe you will need to comment out the array of line 31 also

Hello,

I did that but when I run the test registration this error occurred:

=== RUN TestRegistration
— FAIL: TestRegistration (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x260 pc=0xb65a87]

goroutine 20 [running]:
testing.tRunner.func1.1(0x1212840, 0x1fe9a70)
/usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc00045b9e0)
/usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x1212840, 0x1fe9a70)
/usr/local/go/src/runtime/panic.go:969 +0x166
go.mongodb.org/mongo-driver/mongo.newDatabase(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0004ab550)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/database.go:37 +0x67
go.mongodb.org/mongo-driver/mongo.(*Client).Database(…)
/home/carlos/go/pkg/mod/go.mongodb.org/[email protected]/mongo/client.go:418
free5gc/lib/MongoDBLibrary.RestfulAPIPutOne(0x142543e, 0x3e, 0xc000463980, 0xc0004dd350, 0xc0004d9f48)
/home/carlos/free5gc_mongo/lib/MongoDBLibrary/api_mongoDB.go:73 +0x68
free5gc/src/test.InsertAuthSubscriptionToMongoDB(0x13f3a82, 0x12, 0x13d8f87, 0x6, 0xc0004adb60, 0x13e6ec4, 0xc, 0x13d6435, 0x4, 0x0, …)
/home/carlos/free5gc_mongo/src/test/mongodb.go:30 +0x1ba
free5gc/src/test_test.TestRegistration(0xc00045b9e0)
/home/carlos/free5gc_mongo/src/test/registration_test.go:76 +0x795
testing.tRunner(0xc00045b9e0, 0x1435d18)
/usr/local/go/src/testing/testing.go:991 +0xdc
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1042 +0x357
exit status 2
FAIL free5gc/src/test 0.027s

Using debugging tools I have found that even though mongodB has been initialized by the NRF in the core, the test doesn’t seem to have a conection with the DB. Client and mongoDBName variables are null, therefore it doesn’t know where to put or extract the data.

What I have done to solve this is to put the following lines at the beginning of the test so it initializes again the DB, it have seemed to worked but I don’t know if it is correct:

MongoDBLibrary.SetMongoDB(factory.NrfConfig.Configuration.MongoDBName

Thanks,

Your solution is fine. And I found another way to do the same thing without modifying the code and maybe you can try it.

go test -v -run TestRegistration -args noinit

the init function at ngsetup_test.go will parse the argument noinit and just init the database connection but does not run the NFs (you can trace the code for more information)

1 Like

hi
you can search the “ping to google” topic. in memory i once attached one instruction.
again,there is a dir “sample” in free5gc,there are the configuration files to integrate with a real ran.
it means,you shall run the CN as one independent Core.(you shall create a site connectivity).
then you can run the simulator(study from the registration.test) will help you to create.
you can’t run the run.sh and test.sh together if you study the sh files,you will find the reason.
br,thornton.

Hello @thornton,

I have manage to run the core and then run the test separately with a little modification.

The next problem I’m having is that I cannot ping from ue to an internet address. I have made all the modification that you suggested in the pdf file (actually I have it very similar as you). But the ping does not get a reply. I do get a reply when pinging to my local address though.

Do I need to install a RAN simulator to get this working? Since I do not see that either you or @koh user install this.

My main goal is to get several UEs registering I’m the core to see its capabilities.

If you have some suggestions I will really appreciate it.

Thank you.

hi
Did you get the response from the internet?some times if you have vpn active, the iptable can’t work correctly to route the packet into the gtp tunnel.
and if you have configured the ue ip address in the localhost,it will also affect the gtp tunnel.
which messages are missed in your test.
br,thornton

Hello,

I can ping the internet from a normal command window from my gi ip address (192.168.1.60) to the internet (8.8.8.8). But when I send a ping with my UE to 8.8.8.8, it does not get a reply. I do not know where to get more information of where the error is.

I do not have any vpn active. My internet interface is wlp2s0 with 192.168.1.60, which pinging 8.8.8.8 works.

I have also setup the iptables accordingly:

sudo iptables -t nat -A POSTROUTING -s 60.60.0.0/24 -j SNAT --to-source 192.168.1.60

I also noticed that with the core launched, I can ping amf or smf ip addresses in a command window from 192.168.1.60 but I cannot ping 60.60.0.1, maybe there is a relation there.

Here is a screenshot: