Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for the renamed commands #1

Merged
merged 56 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3970699
inc: Update env variables
stgraber Aug 2, 2023
a96d88e
incus: Update env variables
stgraber Aug 2, 2023
4d1c752
shared: Update env variables
stgraber Aug 2, 2023
d31308a
scripts: Update env variables
stgraber Aug 2, 2023
1ff5981
client: Update env variables
stgraber Aug 2, 2023
d814b88
doc: Update env variables
stgraber Aug 2, 2023
bd2ee03
incus/apparmor: Change profile name
stgraber Aug 2, 2023
ad1f7c9
incus/instance/lxc: Rename lxd-mounts to incus-mounts
stgraber Aug 2, 2023
3014c34
incus/network: Change default domain to incus
stgraber Aug 2, 2023
18d8e38
client: Rename custom HTTP headers
stgraber Aug 2, 2023
32bbbd8
incus: Rename custom HTTP headers
stgraber Aug 2, 2023
27610ed
shared: Rename custom HTTP headers
stgraber Aug 2, 2023
7cdc0e4
incus: Change network interface prefix
stgraber Aug 2, 2023
904af45
incus/firewall: Rename tables
stgraber Aug 2, 2023
6267a77
incus/network: Rename OVN fields
stgraber Aug 2, 2023
00b8b9d
incus/firewall: Remove all LXD mentions
stgraber Aug 3, 2023
ef5d1a2
gitignore: Update for dev_incus
stgraber Aug 3, 2023
be08988
incus: Rename security.devlxd to security.guestapi
stgraber Aug 3, 2023
b187e46
shared: Rename security.devlxd to security.guestapi
stgraber Aug 3, 2023
ce01ef2
scripts/bash: Rename security.devlxd to security.guestapi
stgraber Aug 3, 2023
cc3ecd4
incus/storage/drivers: Handle newer losetup
stgraber Jul 20, 2023
d95e01d
incus: Change default profile/project descriptions
stgraber Aug 3, 2023
9cbe5d4
incus: Rename /dev/lxd to /dev/incus
stgraber Aug 3, 2023
b48bd60
tests: Port the testsuite to inc/incus
stgraber Aug 2, 2023
7d2bc2d
tests: Port sql test
stgraber Aug 2, 2023
f97e3da
tests: Port deps test
stgraber Aug 2, 2023
b91b37b
tests: Port database test
stgraber Aug 2, 2023
a8d7bdb
tests: Port tls_restrictions test
stgraber Aug 2, 2023
e767e95
tests: Port basic_usage test
stgraber Aug 2, 2023
ed27e69
tests: Port remote test
stgraber Aug 2, 2023
c7c7fd8
tests: Port clustering test
stgraber Aug 2, 2023
f92b490
tests: Port projects test
stgraber Aug 2, 2023
e743864
tests: Skip LVM project test when not on LVM
stgraber Jul 20, 2023
89e40e2
tests: Rename lxc_to_lxd to lxc_to_incus
stgraber Aug 2, 2023
e225b27
tests: Skip tests on missing commands
stgraber Jul 20, 2023
31454e3
tests: Port container devices tests
stgraber Aug 2, 2023
a57d991
tests: Port security tests
stgraber Aug 2, 2023
dd049bd
tests: Don't quote function name
stgraber Aug 2, 2023
8b81646
tests: Port image tests
stgraber Aug 2, 2023
ef79844
tests: Port cloud-init test
stgraber Aug 3, 2023
4e739db
tests: Port exec tests
stgraber Aug 3, 2023
1ba0b7e
tests: Port snapshot tests
stgraber Aug 3, 2023
c788dd5
tests: Port config tests
stgraber Aug 3, 2023
52bce03
tests: Port file manipulation tests
stgraber Aug 3, 2023
ad2782e
tests: Port network tests
stgraber Aug 3, 2023
7c2936d
tests: Port various tests
stgraber Aug 3, 2023
7f05401
tests: Port storage tests
stgraber Aug 3, 2023
1fad381
tests: Port init tests
stgraber Aug 3, 2023
183759f
tests: Port various tests
stgraber Aug 3, 2023
22b08a9
tests: Port various tests
stgraber Aug 3, 2023
92071d3
tests: Port the rest of the testsuite
stgraber Aug 3, 2023
8011a6f
github: Remove snap build
stgraber Aug 2, 2023
fa99ace
github: Update env variables
stgraber Aug 2, 2023
da58dac
github: Update tests for Incus
stgraber Aug 2, 2023
956eedb
doc/rest-api: Refresh swagger YAML
stgraber Aug 3, 2023
7e68582
tests: Make shellcheck happy
stgraber Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 18 additions & 67 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
go mod download

- name: Run LXD build
- name: Run Incus build
run: |
make

Expand All @@ -73,14 +73,14 @@ jobs:
system-tests:
env:
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
LXD_SHIFTFS_DISABLE: "true"
LXD_CEPH_CLUSTER: "ceph"
LXD_CEPH_CEPHFS: "cephfs"
LXD_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1"
LXD_VERBOSE: "1"
LXD_OFFLINE: "1"
LXD_TMPFS: "1"
LXD_REQUIRED_TESTS: "test_storage_buckets"
INCUS_SHIFTFS_DISABLE: "true"
INCUS_CEPH_CLUSTER: "ceph"
INCUS_CEPH_CEPHFS: "cephfs"
INCUS_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1"
INCUS_VERBOSE: "1"
INCUS_OFFLINE: "1"
INCUS_TMPFS: "1"
INCUS_REQUIRED_TESTS: "test_storage_buckets"
name: System tests
runs-on: ubuntu-22.04
strategy:
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
run: |
go mod download

- name: Run LXD build
- name: Run Incus build
run: |
make

Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
cd test
sudo --preserve-env=PATH,GOPATH,LXD_VERBOSE,LXD_BACKEND,LXD_CEPH_CLUSTER,LXD_CEPH_CEPHFS,LXD_CEPH_CEPHOBJECT_RADOSGW,LXD_OFFLINE,LXD_SKIP_TESTS,LXD_REQUIRED_TESTS,LXD_SHIFTFS_DISABLE LXD_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}
sudo --preserve-env=PATH,GOPATH,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS,INCUS_SHIFTFS_DISABLE INCUS_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}

client:
name: Client tests
Expand Down Expand Up @@ -261,35 +261,35 @@ jobs:
run: |
mkdir bin

- name: Build static lxc
- name: Build static incc
env:
CGO_ENABLED: 0
run: |
go build -o bin ./lxc
go build -o bin ./inc

- name: Build static lxd-migrate
- name: Build static incus-migrate
if: runner.os == 'Linux'
env:
CGO_ENABLED: 0
run: |
go build -o bin ./lxd-migrate
go build -o bin ./incus-migrate

- name: Unit tests (client)
env:
CGO_ENABLED: 0
run: go test -v ./client/...

- name: Unit tests (lxc)
- name: Unit tests (inc)
env:
CGO_ENABLED: 0
run: go test -v ./lxc/...
run: go test -v ./inc/...

- name: Unit tests (shared)
env:
CGO_ENABLED: 0
run: go test -v ./shared/...

- name: Upload lxc client artifacts
- name: Upload inc client artifacts
uses: actions/upload-artifact@v3
continue-on-error: true
with:
Expand Down Expand Up @@ -338,52 +338,3 @@ jobs:
with:
name: documentation
path: doc/html

snap:
name: Trigger snap edge build
runs-on: ubuntu-22.04
needs: [code-tests, system-tests, client, documentation]
if: ${{ github.repository == 'canonical/lxd' && github.event_name == 'push'}}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Launchpad SSH access
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
LAUNCHPAD_LXD_BOT_KEY: ${{ secrets.LAUNCHPAD_LXD_BOT_KEY }}
run: |
ssh-agent -a "${SSH_AUTH_SOCK}" > /dev/null
ssh-add - <<< "${{ secrets.LAUNCHPAD_LXD_BOT_KEY }}"
mkdir -m 0700 -p ~/.ssh/
# In ephemeral environments like GitHub Action runners, relying on TOFU isn't providing any security
# so require the key obtained by `ssh-keyscan` to match the expected hash from https://help.launchpad.net/SSHFingerprints
ssh-keyscan git.launchpad.net >> ~/.ssh/known_hosts
ssh-keygen -qlF git.launchpad.net | grep -xF 'git.launchpad.net RSA SHA256:UNOzlP66WpDuEo34Wgs8mewypV0UzqHLsIFoqwe8dYo'

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.18.x

- name: Trigger Launchpad snap build
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
TARGET: >-
${{ fromJson('{
"main": "latest-edge",
"stable-5.0": "5.0-edge",
}')[github.ref_name] }}
run: |
set -x
git config --global user.name "Canonical LXD Bot"
git config --global user.email "[email protected]"
localRev=$(git rev-parse HEAD)
go install github.com/canonical/lxd-ci/lxd-snapcraft@latest
git clone -b "${TARGET}" git+ssh://[email protected]/~canonical-lxd/lxd ~/lxd-pkg-snap-lp
cd ~/lxd-pkg-snap-lp
lxd-snapcraft -set-version "git-${localRev:0:7}" -set-source-commit "${localRev}"
git add --all
git commit --all --quiet -s --allow-empty -m "Automatic upstream build (${TARGET})" -m "Upstream commit: ${localRev}"
git show
git push --quiet
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lxd-agent/lxd-agent
lxd-benchmark/lxd-benchmark
lxd-migrate/lxd-migrate
lxd-user/lxd-user
test/devlxd-client/devlxd-client
test/dev_incus-client/dev_incus-client
test/macaroon-identity/macaroon-identity
test/syscall/sysinfo/sysinfo

Expand Down
12 changes: 6 additions & 6 deletions client/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ func ConnectLXDHTTPWithContext(ctx context.Context, args *ConnectionArgs, client

// ConnectLXDUnix lets you connect to a remote LXD daemon over a local unix socket.
//
// If the path argument is empty, then $LXD_SOCKET will be used, if
// unset $LXD_DIR/unix.socket will be used and if that one isn't set
// If the path argument is empty, then $INCUS_SOCKET will be used, if
// unset $INCUS_DIR/unix.socket will be used and if that one isn't set
// either, then the path will default to /var/lib/lxd/unix.socket.
func ConnectLXDUnix(path string, args *ConnectionArgs) (InstanceServer, error) {
return ConnectLXDUnixWithContext(context.Background(), path, args)
}

// ConnectLXDUnixWithContext lets you connect to a remote LXD daemon over a local unix socket with context.Context.
//
// If the path argument is empty, then $LXD_SOCKET will be used, if
// unset $LXD_DIR/unix.socket will be used and if that one isn't set
// If the path argument is empty, then $INCUS_SOCKET will be used, if
// unset $INCUS_DIR/unix.socket will be used and if that one isn't set
// either, then the path will default to /var/lib/lxd/unix.socket.
func ConnectLXDUnixWithContext(ctx context.Context, path string, args *ConnectionArgs) (InstanceServer, error) {
logger.Debug("Connecting to a local LXD over a Unix socket")
Expand Down Expand Up @@ -190,9 +190,9 @@ func ConnectLXDUnixWithContext(ctx context.Context, path string, args *Connectio

// Determine the socket path
if path == "" {
path = os.Getenv("LXD_SOCKET")
path = os.Getenv("INCUS_SOCKET")
if path == "" {
lxdDir := os.Getenv("LXD_DIR")
lxdDir := os.Getenv("INCUS_DIR")
if lxdDir == "" {
lxdDir = "/var/lib/lxd"
}
Expand Down
4 changes: 2 additions & 2 deletions client/incus.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (r *ProtocolLXD) DoHTTP(req *http.Request) (*http.Response, error) {

// addClientHeaders sets headers from client settings.
// User-Agent (if r.httpUserAgent is set).
// X-LXD-authenticated (if r.requireAuthenticated is set).
// X-Incus-authenticated (if r.requireAuthenticated is set).
// Bakery authentication header and cookie (if r.bakeryClient is set).
// OIDC Authorization header (if r.oidcClient is set).
func (r *ProtocolLXD) addClientHeaders(req *http.Request) {
Expand All @@ -174,7 +174,7 @@ func (r *ProtocolLXD) addClientHeaders(req *http.Request) {
}

if r.requireAuthenticated {
req.Header.Set("X-LXD-authenticated", "true")
req.Header.Set("X-Incus-authenticated", "true")
}

if r.bakeryClient != nil {
Expand Down
12 changes: 6 additions & 6 deletions client/incus_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r *ProtocolLXD) CreateContainerFromBackup(args ContainerBackupArgs) (Opera
}

req.Header.Set("Content-Type", "application/octet-stream")
req.Header.Set("X-LXD-pool", args.PoolName)
req.Header.Set("X-Incus-pool", args.PoolName)

// Send the request
resp, err := r.DoHTTP(req)
Expand Down Expand Up @@ -864,23 +864,23 @@ func (r *ProtocolLXD) CreateContainerFile(containerName string, path string, arg

// Set the various headers
if args.UID > -1 {
req.Header.Set("X-LXD-uid", fmt.Sprintf("%d", args.UID))
req.Header.Set("X-Incus-uid", fmt.Sprintf("%d", args.UID))
}

if args.GID > -1 {
req.Header.Set("X-LXD-gid", fmt.Sprintf("%d", args.GID))
req.Header.Set("X-Incus-gid", fmt.Sprintf("%d", args.GID))
}

if args.Mode > -1 {
req.Header.Set("X-LXD-mode", fmt.Sprintf("%04o", args.Mode))
req.Header.Set("X-Incus-mode", fmt.Sprintf("%04o", args.Mode))
}

if args.Type != "" {
req.Header.Set("X-LXD-type", args.Type)
req.Header.Set("X-Incus-type", args.Type)
}

if args.WriteMode != "" {
req.Header.Set("X-LXD-write", args.WriteMode)
req.Header.Set("X-Incus-write", args.WriteMode)
}

// Send the request
Expand Down
12 changes: 6 additions & 6 deletions client/incus_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (
// Setup the headers
req.Header.Set("Content-Type", contentType)
if image.Public {
req.Header.Set("X-LXD-public", "true")
req.Header.Set("X-Incus-public", "true")
}

if image.Filename != "" {
req.Header.Set("X-LXD-filename", image.Filename)
req.Header.Set("X-Incus-filename", image.Filename)
}

if len(image.Properties) > 0 {
Expand All @@ -510,7 +510,7 @@ func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (
imgProps.Set(k, v)
}

req.Header.Set("X-LXD-properties", imgProps.Encode())
req.Header.Set("X-Incus-properties", imgProps.Encode())
}

if len(image.Profiles) > 0 {
Expand All @@ -520,16 +520,16 @@ func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (
imgProfiles.Add("profile", v)
}

req.Header.Set("X-LXD-profiles", imgProfiles.Encode())
req.Header.Set("X-Incus-profiles", imgProfiles.Encode())
}

// Set the user agent
if image.Source != nil && image.Source.Fingerprint != "" && image.Source.Secret != "" && image.Source.Mode == "push" {
// Set fingerprint
req.Header.Set("X-LXD-fingerprint", image.Source.Fingerprint)
req.Header.Set("X-Incus-fingerprint", image.Source.Fingerprint)

// Set secret
req.Header.Set("X-LXD-secret", image.Source.Secret)
req.Header.Set("X-Incus-secret", image.Source.Secret)
}

// Send the request
Expand Down
14 changes: 7 additions & 7 deletions client/incus_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ func (r *ProtocolLXD) CreateInstanceFromBackup(args InstanceBackupArgs) (Operati
req.Header.Set("Content-Type", "application/octet-stream")

if args.PoolName != "" {
req.Header.Set("X-LXD-pool", args.PoolName)
req.Header.Set("X-Incus-pool", args.PoolName)
}

if args.Name != "" {
req.Header.Set("X-LXD-name", args.Name)
req.Header.Set("X-Incus-name", args.Name)
}

// Send the request
Expand Down Expand Up @@ -1432,23 +1432,23 @@ func (r *ProtocolLXD) CreateInstanceFile(instanceName string, filePath string, a

// Set the various headers
if args.UID > -1 {
req.Header.Set("X-LXD-uid", fmt.Sprintf("%d", args.UID))
req.Header.Set("X-Incus-uid", fmt.Sprintf("%d", args.UID))
}

if args.GID > -1 {
req.Header.Set("X-LXD-gid", fmt.Sprintf("%d", args.GID))
req.Header.Set("X-Incus-gid", fmt.Sprintf("%d", args.GID))
}

if args.Mode > -1 {
req.Header.Set("X-LXD-mode", fmt.Sprintf("%04o", args.Mode))
req.Header.Set("X-Incus-mode", fmt.Sprintf("%04o", args.Mode))
}

if args.Type != "" {
req.Header.Set("X-LXD-type", args.Type)
req.Header.Set("X-Incus-type", args.Type)
}

if args.WriteMode != "" {
req.Header.Set("X-LXD-write", args.WriteMode)
req.Header.Set("X-Incus-write", args.WriteMode)
}

// Send the request
Expand Down
6 changes: 3 additions & 3 deletions client/incus_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func (o *oidcClient) do(req *http.Request) (*http.Response, error) {
return resp, nil
}

issuer := resp.Header.Get("X-LXD-OIDC-issuer")
clientID := resp.Header.Get("X-LXD-OIDC-clientid")
audience := resp.Header.Get("X-LXD-OIDC-audience")
issuer := resp.Header.Get("X-Incus-OIDC-issuer")
clientID := resp.Header.Get("X-Incus-OIDC-clientid")
audience := resp.Header.Get("X-Incus-OIDC-audience")

err = o.refresh(issuer, clientID)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions client/incus_storage_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,8 @@ func (r *ProtocolLXD) CreateStoragePoolVolumeFromISO(pool string, args StoragePo
}

req.Header.Set("Content-Type", "application/octet-stream")
req.Header.Set("X-LXD-name", args.Name)
req.Header.Set("X-LXD-type", "iso")
req.Header.Set("X-Incus-name", args.Name)
req.Header.Set("X-Incus-type", "iso")

// Send the request.
resp, err := r.DoHTTP(req)
Expand Down Expand Up @@ -1029,7 +1029,7 @@ func (r *ProtocolLXD) CreateStoragePoolVolumeFromBackup(pool string, args Storag
req.Header.Set("Content-Type", "application/octet-stream")

if args.Name != "" {
req.Header.Set("X-LXD-name", args.Name)
req.Header.Set("X-Incus-name", args.Name)
}

// Send the request.
Expand Down
Loading