ganto / copr-lxc3

RPM spec files for building lxc-3 on Fedora COPR
MIT License
8 stars 2 forks source link

lxd-3.6-0.1 test fails with: container_test.go:55 "NOT NULL constraint failed: profiles.project_id" #11

Closed ganto closed 5 years ago

ganto commented 5 years ago

When building lxd.spec with release 3.6, the go test of github.com/lxc/lxd/lxd aborts with:

Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.R1L9ov
+ umask 022
+ cd /builddir/build/BUILD
+ cd lxd-3.7
+ export GOPATH=/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64//usr/share/gocode:/usr/share/gocode
+ GOPATH=/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64//usr/share/gocode:/usr/share/gocode
+ unset LXD_SOCKET
+ export CGO_CPPFLAGS=-I/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/include/lxd/
+ CGO_CPPFLAGS=-I/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/include/lxd/
+ export CGO_LDFLAGS=-L/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/lib64/lxd/
+ CGO_LDFLAGS=-L/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/lib64/lxd/
+ export LD_LIBRARY_PATH=/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/lib64/lxd/
+ LD_LIBRARY_PATH=/builddir/build/BUILDROOT/lxd-3.6-0.1.fc28.x86_64/usr/lib64/lxd/
+ go test -buildmode pie -compiler gc -v -tags=libsqlite3 -ldflags ' -extldflags '\''-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '\''' github.com/lxc/lxd/lxc
[...]
ok      github.com/lxc/lxd/lxc  0.031s
+ go test -buildmode pie -compiler gc -v -tags=libsqlite3 -ldflags ' -extldflags '\''-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '\''' github.com/lxc/lxd/lxd
[...]
=== RUN   TestContainerTestSuite/TestContainer_findIdmap_mixed
=== RUN   TestContainerTestSuite/TestContainer_findIdmap_raw
--- FAIL: TestContainerTestSuite (1.28s)
    --- PASS: TestContainerTestSuite/TestContainer_IsPrivileged_Privileged (0.08s)
    --- PASS: TestContainerTestSuite/TestContainer_IsPrivileged_Unprivileged (0.06s)
    --- PASS: TestContainerTestSuite/TestContainer_LoadFromDB (0.09s)
    --- PASS: TestContainerTestSuite/TestContainer_LogPath (0.07s)
    --- PASS: TestContainerTestSuite/TestContainer_Path_Regular (0.07s)
    --- PASS: TestContainerTestSuite/TestContainer_Path_Snapshot (0.06s)
    --- PASS: TestContainerTestSuite/TestContainer_ProfilesDefault (0.07s)
    --- FAIL: TestContainerTestSuite/TestContainer_ProfilesMulti (0.04s)
        require.go:765:
                        Error Trace:    container_test.go:55
                        Error:          Expected nil, but got: Failed to create profile: NOT NULL constraint failed: profiles.project_id
                        Test:           TestContainerTestSuite/TestContainer_ProfilesMulti
                        Messages:       Failed to create the unprivileged profile.
    --- PASS: TestContainerTestSuite/TestContainer_ProfilesOverwriteDefaultNic (0.08s)
    --- PASS: TestContainerTestSuite/TestContainer_Rename (0.08s)
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_isolated (0.11s)
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_maxed (0.28s)
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_mixed (0.11s)
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_raw (0.07s)
[...]
FAIL
FAIL    github.com/lxc/lxd/lxd  30.574s
BUILDSTDERR: error: Bad exit status from /var/tmp/rpm-tmp.R1L9ov (%check)
BUILDSTDERR:     Bad exit status from /var/tmp/rpm-tmp.R1L9ov (%check)

The build system is a Fedora 28 with golang-1.10.5-1.fc28.x86_64. Same issue happens with lxd-3.7 release.

ganto commented 5 years ago

Disabling the test results in another error again related to the project handling in the database:

+ go test -buildmode pie -compiler gc -v -tags=libsqlite3 -ldflags ' -extldflags '\''-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '\''' github.com/lxc/lxd/shared/generate/db
=== RUN   TestPackages
--- FAIL: TestPackages (0.00s)
    parse_test.go:25:
            Error Trace:    parse_test.go:25
            Error:          Expected value not to be nil.
            Test:           TestPackages
=== RUN   TestParse
--- PASS: TestParse (0.00s)
FAIL
FAIL    github.com/lxc/lxd/shared/generate/db   0.011s

The code returning a nil object is: obj := pkg.Scope.Lookup("Project")

ganto commented 5 years ago

And this is the third error. Similar code path than the previous one:

+ go test -buildmode pie -compiler gc -v -tags=libsqlite3 -ldflags ' -extldflags '\''-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '\''' github.com/lxc/lxd/shared/generate/lex
=== RUN   TestParse                                                    
--- FAIL: TestParse (0.00s)                                            
        parse_test.go:16:                                               
                        Error Trace:    parse_test.go:16
                        Error:          Expected value not to be nil.
                        Test:           TestParse
FAIL
FAIL    github.com/lxc/lxd/shared/generate/lex  0.010s

The code returning a nil object is: obj := pkg.Scope.Lookup("Parse")

ganto commented 5 years ago

I was expecting this to be a build issue with golang-1.10.5-1.fc28.x86_64 from Fedora 28, so I tried to build it on CentOS which is already using golang-1.11.2-3.el7.x86_64. Interestingly, the first build error mentioned above is gone. Is it the go verson? Or are maybe the go test arguments the reason? CentOS 7 doesn't define the go rpm macros the same as Fedora...

But the test of github.com/lxc/lxd/shared/generate/lex still fails with the same error:

[...]
Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.gthaAx                                                                                                                    
+ umask 022                                                                                                                                                              
+ cd /builddir/build/BUILD                                                                                                                                               
+ cd lxd-3.7                                                                                                                                                             
+ export GOPATH=/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64//usr/share/gocode:/usr/share/gocode                                                                     
+ GOPATH=/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64//usr/share/gocode:/usr/share/gocode                                                                            
+ unset LXD_SOCKET                                                                                                                                                        
+ export CGO_CPPFLAGS=-I/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/include/lxd/                                                                                
+ CGO_CPPFLAGS=-I/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/include/lxd/                                                                                        
+ export CGO_LDFLAGS=-L/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/lib64/lxd/                                                                                   
+ CGO_LDFLAGS=-L/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/lib64/lxd/                                                                                          
+ export LD_LIBRARY_PATH=/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/lib64/lxd/                                                                                 
+ LD_LIBRARY_PATH=/builddir/build/BUILDROOT/lxd-3.7-0.1.el7.x86_64/usr/lib64/lxd/
[...]
+ go test -v -tags libsqlite3 github.com/lxc/lxd/shared/generate/lex
=== RUN   TestParse
--- FAIL: TestParse (0.00s)
    parse_test.go:16:
                Error Trace:    parse_test.go:16
                Error:          Expected value not to be nil.
                Test:           TestParse
FAIL
FAIL    github.com/lxc/lxd/shared/generate/lex  0.004s
error: Bad exit status from /var/tmp/rpm-tmp.gthaAx (%check)
    Bad exit status from /var/tmp/rpm-tmp.gthaAx (%check)

RPM build errors:
ERROR: Exception(SRPMS/lxd-3.7-0.1.el7.src.rpm) Config(epel-7-x86_64) 6 minutes 58 seconds
ganto commented 5 years ago

Running the tests manually on CentOS 7 doesn't reveal the same error, so it's simply an issue with the spec file:

[vagrant@localhost lxd]$ go test -v -tags libsqlite3 github.com/lxc/lxd/shared/generate/lex
=== RUN   TestParse
--- PASS: TestParse (0.00s)
PASS
ok      github.com/lxc/lxd/shared/generate/lex  (cached)
[vagrant@localhost lxd]$ go test -v -tags libsqlite3 github.com/lxc/lxd/shared/generate/db
=== RUN   TestPackages
--- PASS: TestPackages (0.03s)
=== RUN   TestParse
--- PASS: TestParse (0.00s)
PASS
ok      github.com/lxc/lxd/shared/generate/db   0.046s
avollmerhaus commented 5 years ago

Thanks for the lxc3 copr, I couldn't believe Fedora didn't have package for LXD. I've been using it from copr for month now.

But now it seems I need to upgrade beyond 3.5, is there any news on this?

ganto commented 5 years ago

Thanks a lot for your interest. I'm still working on it... :roll_eyes:

Unfortunately I don't fully understand what's going wrong here. Somehow the RPM build process does some magic that results in a different binary. But because I don't understand exactly what's the problem with the final binary, I don't really know where I need to look for the reason. Will try once more with 3.8 that was just released...

ganto commented 5 years ago

Tried to build lxd-3.8 on fc28 and el7 and both now have the same error as initially reported:

--- FAIL: TestContainerTestSuite (0.83s)                                                                                                                                                                                                      
    --- PASS: TestContainerTestSuite/TestContainer_IsPrivileged_Privileged (0.04s)                                                                                                                                                            
    --- PASS: TestContainerTestSuite/TestContainer_IsPrivileged_Unprivileged (0.05s)                                                                                                                                                          
    --- PASS: TestContainerTestSuite/TestContainer_LoadFromDB (0.06s)                                                                                                                                                                         
    --- PASS: TestContainerTestSuite/TestContainer_LogPath (0.05s)                                                                                                                                                                            
    --- PASS: TestContainerTestSuite/TestContainer_Path_Regular (0.05s)                                                                                                                                                                       
    --- PASS: TestContainerTestSuite/TestContainer_Path_Snapshot (0.05s)                                                                                                                                                                      
    --- PASS: TestContainerTestSuite/TestContainer_ProfilesDefault (0.05s)                                                                                                                                                                    
    --- FAIL: TestContainerTestSuite/TestContainer_ProfilesMulti (0.03s)                                                                                                                                                                      
        require.go:765:                                                                                                                                                                                                                       
                Error Trace:    container_test.go:55                                                                                                                                                                                          
                Error:          Expected nil, but got: Failed to create profile: NOT NULL constraint failed: profiles.project_id
                Test:           TestContainerTestSuite/TestContainer_ProfilesMulti                                            
                Messages:       Failed to create the unprivileged profile.                                   
    --- PASS: TestContainerTestSuite/TestContainer_ProfilesOverwriteDefaultNic (0.05s)
    --- PASS: TestContainerTestSuite/TestContainer_Rename (0.05s)                      
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_isolated (0.07s)
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_maxed (0.16s)                  
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_mixed (0.07s)                                     
    --- PASS: TestContainerTestSuite/TestContainer_findIdmap_raw (0.05s)    
ganto commented 5 years ago

Reported my struggling upstream in lxc/lxd#5380. Let's see if someone has an idea what's going wrong here.

ganto commented 5 years ago

Originally reported test failure was fixed by upstream commit af340ce. I added the patch in 93572d0e731705af981fe3e6bfe5005dc1749ee5 and now the test suite passes this test.

Opened a new issue #13 for the other test failure found in https://github.com/ganto/copr-lxc3/issues/11#issuecomment-443419608