diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be3f294d858..dee9c59a211 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,7 +58,7 @@ jobs: run: | go mod download - - name: Run LXD build + - name: Run Incus build run: | make @@ -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: @@ -186,7 +186,7 @@ jobs: run: | go mod download - - name: Run LXD build + - name: Run Incus build run: | make @@ -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 @@ -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: @@ -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 "lxd@lists.canonical.com" - localRev=$(git rev-parse HEAD) - go install github.com/canonical/lxd-ci/lxd-snapcraft@latest - git clone -b "${TARGET}" git+ssh://lxdbot@git.launchpad.net/~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 diff --git a/.gitignore b/.gitignore index 872e54c7e20..940c9a22030 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/client/connection.go b/client/connection.go index b869b39631e..d3490baf3a4 100644 --- a/client/connection.go +++ b/client/connection.go @@ -148,8 +148,8 @@ 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) @@ -157,8 +157,8 @@ func ConnectLXDUnix(path string, args *ConnectionArgs) (InstanceServer, error) { // 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") @@ -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" } diff --git a/client/incus.go b/client/incus.go index 3303adbab27..221843f3280 100644 --- a/client/incus.go +++ b/client/incus.go @@ -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) { @@ -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 { diff --git a/client/incus_containers.go b/client/incus_containers.go index 6de317b389e..59a4de8ec57 100644 --- a/client/incus_containers.go +++ b/client/incus_containers.go @@ -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) @@ -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 diff --git a/client/incus_images.go b/client/incus_images.go index 73813ea4ca1..1364fbddcf5 100644 --- a/client/incus_images.go +++ b/client/incus_images.go @@ -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 { @@ -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 { @@ -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 diff --git a/client/incus_instances.go b/client/incus_instances.go index 6005f7e8d56..595a232cda3 100644 --- a/client/incus_instances.go +++ b/client/incus_instances.go @@ -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 @@ -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 diff --git a/client/incus_oidc.go b/client/incus_oidc.go index 5c716537cc5..5ed0ead5bc0 100644 --- a/client/incus_oidc.go +++ b/client/incus_oidc.go @@ -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 { diff --git a/client/incus_storage_volumes.go b/client/incus_storage_volumes.go index 5f0c8072fd8..6fcf9975c05 100644 --- a/client/incus_storage_volumes.go +++ b/client/incus_storage_volumes.go @@ -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) @@ -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. diff --git a/doc/environment.md b/doc/environment.md index 2e5a9b12de0..8064e680467 100644 --- a/doc/environment.md +++ b/doc/environment.md @@ -1,18 +1,14 @@ # Environment variables -The LXD client and daemon respect some environment variables to adapt to +The Incus client and daemon respect some environment variables to adapt to the user's environment and to turn some advanced features on and off. -```{note} -These environment variables are not available if you use the LXD snap. -``` - ## Common Name | Description :--- | :---- -`LXD_DIR` | The LXD data directory -`LXD_INSECURE_TLS` | If set to true, allows all default Go ciphers both for client <-> server communication and server <-> image servers (server <-> server and clustering are not affected) +`INCUS_DIR` | The Incus data directory +`INCUS_INSECURE_TLS` | If set to true, allows all default Go ciphers both for client <-> server communication and server <-> image servers (server <-> server and clustering are not affected) `PATH` | List of paths to look into when resolving binaries `http_proxy` | Proxy server URL for HTTP `https_proxy` | Proxy server URL for HTTPS @@ -24,19 +20,21 @@ Name | Description :--- | :---- `EDITOR` | What text editor to use `VISUAL` | What text editor to use (if `EDITOR` isn't set) -`LXD_CONF` | Path to the LXC configuration directory -`LXD_GLOBAL_CONF` | Path to the global LXC configuration directory -`LXC_REMOTE` | Name of the remote to use (overrides configured default remote) +`INCUS_CONF` | Path to the client configuration directory +`INCUS_GLOBAL_CONF` | Path to the global client configuration directory +`INCUS_REMOTE` | Name of the remote to use (overrides configured default remote) ## Server environment variable Name | Description :--- | :---- -`LXD_EXEC_PATH` | Full path to the LXD binary (used when forking subcommands) -`LXD_LXC_TEMPLATE_CONFIG` | Path to the LXC template configuration directory -`LXD_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off -`LXD_UNPRIVILEGED_ONLY` | If set to `true`, enforces that only unprivileged containers can be created. Note that any privileged containers that have been created before setting LXD_UNPRIVILEGED_ONLY will continue to be privileged. To use this option effectively it should be set when the LXD daemon is first set up. -`LXD_OVMF_PATH` | Path to an OVMF build including `OVMF_CODE.fd` and `OVMF_VARS.ms.fd` -`LXD_SHIFTFS_DISABLE` | Disable `shiftfs` support (useful when testing traditional UID shifting) -`LXD_IDMAPPED_MOUNTS_DISABLE` | Disable idmapped mounts support (useful when testing traditional UID shifting) -`LXD_DEVMONITOR_DIR` | Path to be monitored by the device monitor. This is primarily for testing. +`INCUS_CLUSTER_UPDATE` | Script to call on a cluster update +`INCUS_DEVMONITOR_DIR` | Path to be monitored by the device monitor. This is primarily for testing +`INCUS_EXEC_PATH` | Full path to the Incus binary (used when forking subcommands) +`INCUS_IDMAPPED_MOUNTS_DISABLE` | Disable idmapped mounts support (useful when testing traditional UID shifting) +`INCUS_LXC_TEMPLATE_CONFIG` | Path to the LXC template configuration directory +`INCUS_OVMF_PATH` | Path to an OVMF build including `OVMF_CODE.fd` and `OVMF_VARS.ms.fd` +`INCUS_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off +`INCUS_SHIFTFS_DISABLE` | Disable `shiftfs` support (useful when testing traditional UID shifting) +`INCUS_UI` | Path to the web UI to serve through the web server +`INCUS_UNPRIVILEGED_ONLY` | If set to `true`, enforces that only unprivileged containers can be created. Note that any privileged containers that have been created before setting INCUS_UNPRIVILEGED_ONLY will continue to be privileged. To use this option effectively it should be set when the Incus daemon is first set up. diff --git a/doc/rest-api.yaml b/doc/rest-api.yaml index 3e8f5b21879..83f59ea57fc 100644 --- a/doc/rest-api.yaml +++ b/doc/rest-api.yaml @@ -7315,34 +7315,34 @@ paths: - description: Push secret for server to server communication example: RANDOM-STRING in: header - name: X-LXD-secret + name: X-Incus-secret schema: type: string - description: Expected fingerprint when pushing a raw image in: header - name: X-LXD-fingerprint + name: X-Incus-fingerprint schema: type: string - description: Descriptive properties in: header - name: X-LXD-properties + name: X-Incus-properties schema: additionalProperties: type: string type: object - description: Whether the image is available to unauthenticated users in: header - name: X-LXD-public + name: X-Incus-public schema: type: boolean - description: Original filename of the image in: header - name: X-LXD-filename + name: X-Incus-filename schema: type: string - description: List of profiles to use in: header - name: X-LXD-profiles + name: X-Incus-profiles schema: items: type: string @@ -8901,15 +8901,15 @@ paths: "200": description: Raw file or directory listing headers: - X-LXD-gid: + X-Incus-gid: description: File owner GID - X-LXD-mode: + X-Incus-mode: description: Mode mask - X-LXD-modified: + X-Incus-modified: description: Last modified date - X-LXD-type: + X-Incus-type: description: Type of file (file, symlink or directory) - X-LXD-uid: + X-Incus-uid: description: File owner UID "400": $ref: '#/responses/BadRequest' @@ -8940,15 +8940,15 @@ paths: "200": description: Raw file or directory listing headers: - X-LXD-gid: + X-Incus-gid: description: File owner GID - X-LXD-mode: + X-Incus-mode: description: Mode mask - X-LXD-modified: + X-Incus-modified: description: Last modified date - X-LXD-type: + X-Incus-type: description: Type of file (file, symlink or directory) - X-LXD-uid: + X-Incus-uid: description: File owner UID "400": $ref: '#/responses/BadRequest' @@ -8983,31 +8983,31 @@ paths: - description: File owner UID example: 1000 in: header - name: X-LXD-uid + name: X-Incus-uid schema: type: integer - description: File owner GID example: 1000 in: header - name: X-LXD-gid + name: X-Incus-gid schema: type: integer - description: File mode example: 420 in: header - name: X-LXD-mode + name: X-Incus-mode schema: type: integer - description: Type of file (file, symlink or directory) example: file in: header - name: X-LXD-type + name: X-Incus-type schema: type: string - description: Write mode (overwrite or append) example: overwrite in: header - name: X-LXD-write + name: X-Incus-write schema: type: string produces: diff --git a/inc/config/config.go b/inc/config/config.go index 0c0a5ed646c..807044cb0e6 100644 --- a/inc/config/config.go +++ b/inc/config/config.go @@ -47,8 +47,8 @@ type Config struct { // GlobalConfigPath returns a joined path of the global configuration directory and passed arguments. func (c *Config) GlobalConfigPath(paths ...string) string { configDir := "/etc/lxd" - if os.Getenv("LXD_GLOBAL_CONF") != "" { - configDir = os.Getenv("LXD_GLOBAL_CONF") + if os.Getenv("INCUS_GLOBAL_CONF") != "" { + configDir = os.Getenv("INCUS_GLOBAL_CONF") } path := []string{configDir} diff --git a/inc/config/file.go b/inc/config/file.go index 44146e7571f..0cf2ab4ae26 100644 --- a/inc/config/file.go +++ b/inc/config/file.go @@ -67,7 +67,7 @@ func LoadConfig(path string) (*Config, error) { // If the environment specifies a remote this takes priority over what // is defined in the configuration - envDefaultRemote := os.Getenv("LXC_REMOTE") + envDefaultRemote := os.Getenv("INCUS_REMOTE") if len(envDefaultRemote) > 0 { c.DefaultRemote = envDefaultRemote } else if c.DefaultRemote == "" { diff --git a/inc/main.go b/inc/main.go index 0c79b610757..8c396e083ff 100644 --- a/inc/main.go +++ b/inc/main.go @@ -313,8 +313,8 @@ func (c *cmdGlobal) PreRun(cmd *cobra.Command, args []string) error { // Figure out the config directory and config path var configDir string - if os.Getenv("LXD_CONF") != "" { - configDir = os.Getenv("LXD_CONF") + if os.Getenv("INCUS_CONF") != "" { + configDir = os.Getenv("INCUS_CONF") } else if os.Getenv("HOME") != "" { configDir = path.Join(os.Getenv("HOME"), ".config", "lxc") } else { diff --git a/inc/main_aliases.go b/inc/main_aliases.go index 46a36217bcd..8a7b163bf52 100644 --- a/inc/main_aliases.go +++ b/inc/main_aliases.go @@ -155,14 +155,14 @@ func execIfAliases() error { args := os.Args // Avoid loops - if os.Getenv("LXC_ALIASES") == "1" { + if os.Getenv("INCUS_ALIASES") == "1" { return nil } // Figure out the config directory and config path var configDir string - if os.Getenv("LXD_CONF") != "" { - configDir = os.Getenv("LXD_CONF") + if os.Getenv("INCUS_CONF") != "" { + configDir = os.Getenv("INCUS_CONF") } else if os.Getenv("HOME") != "" { configDir = path.Join(os.Getenv("HOME"), ".config", "lxc") } else { @@ -204,7 +204,7 @@ func execIfAliases() error { // Re-exec environ := getEnviron() - environ = append(environ, "LXC_ALIASES=1") + environ = append(environ, "INCUS_ALIASES=1") ret := doExec(path, newArgs, environ) return fmt.Errorf(i18n.G("Processing aliases failed: %s"), ret) } diff --git a/incus/api.go b/incus/api.go index f23385b4aea..f64323a10de 100644 --- a/incus/api.go +++ b/incus/api.go @@ -68,7 +68,7 @@ func restServer(d *Daemon) *http.Server { mux.SkipClean(true) mux.UseEncodedPath() // Allow encoded values in path segments. - uiPath := os.Getenv("LXD_UI") + uiPath := os.Getenv("INCUS_UI") uiEnabled := uiPath != "" && shared.PathExists(uiPath) if uiEnabled { uiHttpDir := uiHttpDir{http.Dir(uiPath)} diff --git a/incus/api_project.go b/incus/api_project.go index 0320b2b9142..52ad9b996d0 100644 --- a/incus/api_project.go +++ b/incus/api_project.go @@ -354,7 +354,7 @@ func projectCreateDefaultProfile(tx *db.ClusterTx, project string) error { profile := cluster.Profile{} profile.Project = project profile.Name = projecthelpers.Default - profile.Description = fmt.Sprintf("Default LXD profile for project %s", project) + profile.Description = fmt.Sprintf("Default Incus profile for project %s", project) _, err := cluster.CreateProfile(context.TODO(), tx.Tx(), profile) if err != nil { diff --git a/incus/apparmor/apparmor.go b/incus/apparmor/apparmor.go index 31c245507ea..982e5052944 100644 --- a/incus/apparmor/apparmor.go +++ b/incus/apparmor/apparmor.go @@ -249,8 +249,8 @@ func profileName(prefix string, name string) string { } if len(prefix) > 0 { - return fmt.Sprintf("lxd_%s-%s", prefix, name) + return fmt.Sprintf("incus_%s-%s", prefix, name) } - return fmt.Sprintf("lxd-%s", name) + return fmt.Sprintf("incus-%s", name) } diff --git a/incus/apparmor/instance.go b/incus/apparmor/instance.go index ab3fff563a1..5e147fd57ce 100644 --- a/incus/apparmor/instance.go +++ b/incus/apparmor/instance.go @@ -183,8 +183,8 @@ func instanceProfile(sysOS *sys.OS, inst instance) (string, error) { } ovmfPath := "/usr/share/OVMF" - if os.Getenv("LXD_OVMF_PATH") != "" { - ovmfPath = os.Getenv("LXD_OVMF_PATH") + if os.Getenv("INCUS_OVMF_PATH") != "" { + ovmfPath = os.Getenv("INCUS_OVMF_PATH") } ovmfPath, err = filepath.EvalSymlinks(ovmfPath) diff --git a/incus/auth/oidc/oidc.go b/incus/auth/oidc/oidc.go index 6eba9de19b2..4507c9efaf4 100644 --- a/incus/auth/oidc/oidc.go +++ b/incus/auth/oidc/oidc.go @@ -244,9 +244,9 @@ func (o *Verifier) VerifyAccessToken(ctx context.Context, token string) (*oidc.A // WriteHeaders writes the OIDC configuration as HTTP headers so the client can initatiate the device code flow. func (o *Verifier) WriteHeaders(w http.ResponseWriter) error { - w.Header().Set("X-LXD-OIDC-issuer", o.issuer) - w.Header().Set("X-LXD-OIDC-clientid", o.clientID) - w.Header().Set("X-LXD-OIDC-audience", o.audience) + w.Header().Set("X-Incus-OIDC-issuer", o.issuer) + w.Header().Set("X-Incus-OIDC-clientid", o.clientID) + w.Header().Set("X-Incus-OIDC-audience", o.audience) return nil } diff --git a/incus/cluster/upgrade.go b/incus/cluster/upgrade.go index 4e035b7897e..ed8ffe32c10 100644 --- a/incus/cluster/upgrade.go +++ b/incus/cluster/upgrade.go @@ -60,7 +60,7 @@ func NotifyUpgradeCompleted(state *state.State, networkCert *shared.CertInfo, se }) } -// MaybeUpdate Check this node's version and possibly run LXD_CLUSTER_UPDATE. +// MaybeUpdate Check this node's version and possibly run INCUS_CLUSTER_UPDATE. func MaybeUpdate(state *state.State) error { shouldUpdate := false @@ -103,9 +103,9 @@ func MaybeUpdate(state *state.State) error { func triggerUpdate() error { logger.Warn("Member is out-of-date with respect to other cluster members") - updateExecutable := os.Getenv("LXD_CLUSTER_UPDATE") + updateExecutable := os.Getenv("INCUS_CLUSTER_UPDATE") if updateExecutable == "" { - logger.Debug("No LXD_CLUSTER_UPDATE variable set, skipping auto-update") + logger.Debug("No INCUS_CLUSTER_UPDATE variable set, skipping auto-update") return nil } diff --git a/incus/cluster/upgrade_test.go b/incus/cluster/upgrade_test.go index 544307280f4..1990d18065b 100644 --- a/incus/cluster/upgrade_test.go +++ b/incus/cluster/upgrade_test.go @@ -62,7 +62,7 @@ func TestNotifyUpgradeCompleted(t *testing.T) { } // The task function checks if the node is out of date and runs whatever is in -// LXD_CLUSTER_UPDATE if so. +// INCUS_CLUSTER_UPDATE if so. func TestMaybeUpdate_Upgrade(t *testing.T) { dir, err := os.MkdirTemp("", "") require.NoError(t, err) @@ -106,8 +106,8 @@ func TestMaybeUpdate_Upgrade(t *testing.T) { return nil }) - _ = os.Setenv("LXD_CLUSTER_UPDATE", script) - defer func() { _ = os.Unsetenv("LXD_CLUSTER_UPDATE") }() + _ = os.Setenv("INCUS_CLUSTER_UPDATE", script) + defer func() { _ = os.Unsetenv("INCUS_CLUSTER_UPDATE") }() _ = cluster.MaybeUpdate(state) @@ -132,8 +132,8 @@ func TestMaybeUpdate_NothingToDo(t *testing.T) { state, cleanup := state.NewTestState(t) defer cleanup() - _ = os.Setenv("LXD_CLUSTER_UPDATE", script) - defer func() { _ = os.Unsetenv("LXD_CLUSTER_UPDATE") }() + _ = os.Setenv("INCUS_CLUSTER_UPDATE", script) + defer func() { _ = os.Unsetenv("INCUS_CLUSTER_UPDATE") }() _ = cluster.MaybeUpdate(state) diff --git a/incus/daemon.go b/incus/daemon.go index fdfb115f795..2b5ffdbd641 100644 --- a/incus/daemon.go +++ b/incus/daemon.go @@ -315,7 +315,7 @@ func (d *Daemon) Authenticate(w http.ResponseWriter, r *http.Request) (bool, str // Devlxd unix socket credentials on main API. if r.RemoteAddr == "@devlxd" { - return false, "", "", fmt.Errorf("Main API query can't come from /dev/lxd socket") + return false, "", "", fmt.Errorf("Main API query can't come from /dev/incus socket") } // Cluster notification with wrong certificate. @@ -418,7 +418,7 @@ func (d *Daemon) State() *state.State { // UnixSocket returns the full path to the unix.socket file that this daemon is // listening on. Used by tests. func (d *Daemon) UnixSocket() string { - path := os.Getenv("LXD_SOCKET") + path := os.Getenv("INCUS_SOCKET") if path != "" { return path } @@ -567,7 +567,7 @@ func (d *Daemon) createCmd(restAPI *mux.Router, version string, c APIEndpoint) { } r = r.WithContext(ctx) - } else if untrustedOk && r.Header.Get("X-LXD-authenticated") == "" { + } else if untrustedOk && r.Header.Get("X-Incus-authenticated") == "" { logger.Debug(fmt.Sprintf("Allowing untrusted %s", r.Method), logger.Ctx{"url": r.URL.RequestURI(), "ip": r.RemoteAddr}) } else if derr, ok := err.(*bakery.DischargeRequiredError); ok { d.candidVerifier.WriteRequest(r, w, derr) @@ -945,7 +945,7 @@ func (d *Daemon) init() error { } // Detect shiftfs support. - if shared.IsTrue(os.Getenv("LXD_SHIFTFS_DISABLE")) { + if shared.IsTrue(os.Getenv("INCUS_SHIFTFS_DISABLE")) { logger.Info(" - shiftfs support: disabled") } else { if canUseShiftfs() && (util.SupportsFilesystem("shiftfs") || util.LoadModule("shiftfs") == nil) { @@ -957,7 +957,7 @@ func (d *Daemon) init() error { } // Detect idmapped mounts support. - if shared.IsTrue(os.Getenv("LXD_IDMAPPED_MOUNTS_DISABLE")) { + if shared.IsTrue(os.Getenv("INCUS_IDMAPPED_MOUNTS_DISABLE")) { logger.Info(" - idmapped mounts kernel support: disabled") } else if kernelSupportsIdmappedMounts() { d.os.IdmappedMounts = true @@ -1445,7 +1445,7 @@ func (d *Daemon) init() error { // Start the scheduler go deviceEventListener(d.State) - prefixPath := os.Getenv("LXD_DEVMONITOR_DIR") + prefixPath := os.Getenv("INCUS_DEVMONITOR_DIR") if prefixPath == "" { prefixPath = "/dev" } diff --git a/incus/db/cluster/open.go b/incus/db/cluster/open.go index 17a060224d3..cd2aaf8c824 100644 --- a/incus/db/cluster/open.go +++ b/incus/db/cluster/open.go @@ -188,7 +188,7 @@ INSERT INTO nodes(id, name, address, schema, api_extensions, arch, description) // Default project var defaultProjectStmt strings.Builder - _, _ = defaultProjectStmt.WriteString("INSERT INTO projects (name, description) VALUES ('default', 'Default LXD project');") + _, _ = defaultProjectStmt.WriteString("INSERT INTO projects (name, description) VALUES ('default', 'Default Incus project');") // Enable all features for default project. for featureName := range ProjectFeatures { @@ -202,7 +202,7 @@ INSERT INTO nodes(id, name, address, schema, api_extensions, arch, description) // Default profile stmt = ` -INSERT INTO profiles (name, description, project_id) VALUES ('default', 'Default LXD profile', 1) +INSERT INTO profiles (name, description, project_id) VALUES ('default', 'Default Incus profile', 1) ` _, err = tx.Exec(stmt) if err != nil { diff --git a/incus/db/cluster/update.go b/incus/db/cluster/update.go index a1f6c881924..cfa50b68d6b 100644 --- a/incus/db/cluster/update.go +++ b/incus/db/cluster/update.go @@ -3687,7 +3687,7 @@ CREATE VIEW projects_config_ref (name, key, value) AS JOIN projects ON projects.id=projects_config.project_id; -- Insert the default project, with ID 1 -INSERT INTO projects (name, description) VALUES ('default', 'Default LXD project'); +INSERT INTO projects (name, description) VALUES ('default', 'Default Incus project'); INSERT INTO projects_config (project_id, key, value) VALUES (1, 'features.images', 'true'); INSERT INTO projects_config (project_id, key, value) VALUES (1, 'features.profiles', 'true'); diff --git a/incus/db/migration.go b/incus/db/migration.go index a49959297a9..ab79cc7fed0 100644 --- a/incus/db/migration.go +++ b/incus/db/migration.go @@ -123,7 +123,7 @@ func importPreClusteringData(tx *sql.Tx, dump *Dump) error { stmt.WriteString(`INSERT INTO nodes(id, name, address, schema, api_extensions) VALUES(1, 'none', '0.0.0.0', 14, 1);`) // Default project - stmt.WriteString(`INSERT INTO projects (name, description) VALUES ('default', 'Default LXD project');`) + stmt.WriteString(`INSERT INTO projects (name, description) VALUES ('default', 'Default Incus project');`) // Enable all features for default project. for featureName := range cluster.ProjectFeatures { diff --git a/incus/db/migration_test.go b/incus/db/migration_test.go index ae61e0ac17c..be0ab167406 100644 --- a/incus/db/migration_test.go +++ b/incus/db/migration_test.go @@ -195,7 +195,7 @@ func newPreClusteringTx(t *testing.T) *sql.Tx { "INSERT INTO config VALUES(1, 'core.https_address', '1.2.3.4:666')", "INSERT INTO config VALUES(2, 'core.trust_password', 'sekret')", "INSERT INTO config VALUES(3, 'maas.machine', 'mymaas')", - "INSERT INTO profiles VALUES(1, 'default', 'Default LXD profile')", + "INSERT INTO profiles VALUES(1, 'default', 'Default Incus profile')", "INSERT INTO profiles VALUES(2, 'users', '')", "INSERT INTO profiles_config VALUES(2, 2, 'boot.autostart', 'false')", "INSERT INTO profiles_config VALUES(3, 2, 'limits.cpu.allowance', '50%')", diff --git a/incus/dev_incus.go b/incus/dev_incus.go index c8585e9b5b2..4ccfdd2ee72 100644 --- a/incus/dev_incus.go +++ b/incus/dev_incus.go @@ -57,7 +57,7 @@ type devLxdHandler struct { } var devlxdConfigGet = devLxdHandler{"/1.0/config", func(d *Daemon, c instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } @@ -72,7 +72,7 @@ var devlxdConfigGet = devLxdHandler{"/1.0/config", func(d *Daemon, c instance.In }} var devlxdConfigKeyGet = devLxdHandler{"/1.0/config/{key}", func(d *Daemon, c instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } @@ -94,11 +94,11 @@ var devlxdConfigKeyGet = devLxdHandler{"/1.0/config/{key}", func(d *Daemon, c in }} var devlxdImageExport = devLxdHandler{"/1.0/images/{fingerprint}/export", func(d *Daemon, c instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } - if shared.IsFalseOrEmpty(c.ExpandedConfig()["security.devlxd.images"]) { + if shared.IsFalseOrEmpty(c.ExpandedConfig()["security.guestapi.images"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } @@ -116,7 +116,7 @@ var devlxdImageExport = devLxdHandler{"/1.0/images/{fingerprint}/export", func(d }} var devlxdMetadataGet = devLxdHandler{"/1.0/meta-data", func(d *Daemon, inst instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(inst.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(inst.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), inst.Type() == instancetype.VM) } @@ -126,7 +126,7 @@ var devlxdMetadataGet = devLxdHandler{"/1.0/meta-data", func(d *Daemon, inst ins }} var devlxdEventsGet = devLxdHandler{"/1.0/events", func(d *Daemon, c instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } @@ -211,7 +211,7 @@ var devlxdAPIHandler = devLxdHandler{"/1.0", func(d *Daemon, c instance.Instance return response.DevLxdResponse(http.StatusOK, api.DevLXDGet{APIVersion: version.APIVersion, Location: location, InstanceType: c.Type().String(), DevLXDPut: api.DevLXDPut{State: state.String()}}, "json", c.Type() == instancetype.VM) } else if r.Method == "PATCH" { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } @@ -245,7 +245,7 @@ var devlxdAPIHandler = devLxdHandler{"/1.0", func(d *Daemon, c instance.Instance }} var devlxdDevicesGet = devLxdHandler{"/1.0/devices", func(d *Daemon, c instance.Instance, w http.ResponseWriter, r *http.Request) response.Response { - if shared.IsFalse(c.ExpandedConfig()["security.devlxd"]) { + if shared.IsFalse(c.ExpandedConfig()["security.guestapi"]) { return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM) } diff --git a/incus/dev_incus_test.go b/incus/dev_incus_test.go index f53954eb85f..7720967c436 100644 --- a/incus/dev_incus_test.go +++ b/incus/dev_incus_test.go @@ -57,7 +57,7 @@ func setupDir() error { _ = os.MkdirAll(fmt.Sprintf("%s/devlxd", testDir), 0755) - return os.Setenv("LXD_DIR", testDir) + return os.Setenv("INCUS_DIR", testDir) } func setupSocket() (*net.UnixListener, error) { diff --git a/incus/device/device_common.go b/incus/device/device_common.go index aa94816585b..3816ebd6de2 100644 --- a/incus/device/device_common.go +++ b/incus/device/device_common.go @@ -99,7 +99,7 @@ func (d *deviceCommon) Remove() error { // instances.nic.host_name setting. // Accepts prefix argument to use with random interface generation. // Accepts optional hwaddr MAC address to use for generating the interface name in mac mode. -// In mac mode the interface prefix is always "lxd". +// In mac mode the interface prefix is always "inc". func (d *deviceCommon) generateHostName(prefix string, hwaddr string) (string, error) { hostNameMode := d.state.GlobalConfig.InstancesNICHostname() diff --git a/incus/device/nic_ipvlan.go b/incus/device/nic_ipvlan.go index 5f93c0d5e52..505453cf330 100644 --- a/incus/device/nic_ipvlan.go +++ b/incus/device/nic_ipvlan.go @@ -233,7 +233,7 @@ func (d *nicIPVLAN) Start() (*deviceConfig.RunConfig, error) { // Record a random host name to use to detach the ipvlan interface back onto the host at stop time so we // can remove it and not have to rely on the kernel to do it when the namespace is destroyed, as this is // not always reliable. - saveData["host_name"], err = d.generateHostName("lxd", d.config["hwaddr"]) + saveData["host_name"], err = d.generateHostName("inc", d.config["hwaddr"]) if err != nil { return nil, err } diff --git a/incus/firewall/drivers/drivers_nftables.go b/incus/firewall/drivers/drivers_nftables.go index c81f576cf3a..b953d669c0b 100644 --- a/incus/firewall/drivers/drivers_nftables.go +++ b/incus/firewall/drivers/drivers_nftables.go @@ -19,7 +19,7 @@ import ( "github.com/cyphar/incus/shared/version" ) -const nftablesNamespace = "lxd" +const nftablesNamespace = "incus" const nftablesContentTemplate = "nftablesContent" // nftablesChainSeparator The "." character is specifically chosen here so as to prevent the ability for collisions @@ -30,7 +30,7 @@ const nftablesChainSeparator = "." // nftablesMinVersion We need at least 0.9.1 as this was when the arp ether saddr filters were added. const nftablesMinVersion = "0.9.1" -// Nftables is an implmentation of LXD firewall using nftables. +// Nftables is an implmentation of Incus firewall using nftables. type Nftables struct{} // String returns the driver name. @@ -97,7 +97,7 @@ func (d Nftables) Compat() (bool, error) { } // Check that nftables works at all (some kernels let you list ruleset despite missing support). - testTable := fmt.Sprintf("lxd_test_%s", uuid.New()) + testTable := fmt.Sprintf("incus_test_%s", uuid.New()) _, err = shared.RunCommandCLocale("nft", "create", "table", testTable) if err != nil { @@ -126,7 +126,7 @@ func (d Nftables) Compat() (bool, error) { // nftGenericItem represents some common fields amongst the different nftables types. type nftGenericItem struct { - ItemType string `json:"-"` // Type of item (table, chain or rule). Populated by LXD. + ItemType string `json:"-"` // Type of item (table, chain or rule). Populated by Incus. Family string `json:"family"` // Family of item (ip, ip6, bridge etc). Table string `json:"table"` // Table the item belongs to (for chains and rules). Chain string `json:"chain"` // Chain the item belongs to (for rules). @@ -365,7 +365,7 @@ func (d Nftables) NetworkSetup(networkName string, opts Opts) error { return nil } -// NetworkClear removes the LXD network related chains. +// NetworkClear removes the Incus network related chains. // The delete and ipeVersions arguments have no effect for nftables driver. func (d Nftables) NetworkClear(networkName string, _ bool, _ []uint) error { removeChains := []string{ diff --git a/incus/firewall/drivers/drivers_nftables_templates.go b/incus/firewall/drivers/drivers_nftables_templates.go index 365ebb7fdc0..77cb6b68f5d 100644 --- a/incus/firewall/drivers/drivers_nftables_templates.go +++ b/incus/firewall/drivers/drivers_nftables_templates.go @@ -122,29 +122,29 @@ flush chain {{.family}} {{.namespace}} aclfwd{{.chainSeparator}}{{.networkName}} table {{.family}} {{.namespace}} { chain aclin{{.chainSeparator}}{{.networkName}} { - # Allow DNS to LXD host. + # Allow DNS to Incus host. iifname "{{.networkName}}" tcp dport 53 accept iifname "{{.networkName}}" udp dport 53 accept - # Allow DHCPv6 to LXD host. + # Allow DHCPv6 to Incus host. iifname "{{$.networkName}}" udp dport 67 accept iifname "{{$.networkName}}" udp dport 547 accept - # Allow core ICMPv4 to LXD host. + # Allow core ICMPv4 to Incus host. iifname "{{$.networkName}}" icmp type {3, 11, 12} accept - # Allow core ICMPv6 to LXD host. + # Allow core ICMPv6 to Incus host. iifname "{{$.networkName}}" icmpv6 type {1, 2, 3, 4, 133, 135, 136, 143} accept iifname {{.networkName}} jump acl{{.chainSeparator}}{{.networkName}} } chain aclout{{.chainSeparator}}{{.networkName}} { - # Allow DHCPv6 from LXD host. + # Allow DHCPv6 from Incus host. oifname "{{$.networkName}}" udp sport 67 accept oifname "{{$.networkName}}" udp sport 547 accept - # Allow core ICMPv4 from LXD host. + # Allow core ICMPv4 from Incus host. oifname "{{$.networkName}}" icmp type {3, 11, 12} accept # Allow ICMPv6 ping from host into network as dnsmasq uses this to probe IP allocations. @@ -177,7 +177,7 @@ table {{.family}} {{.namespace}} { // nftablesInstanceBridgeFilter defines the rules needed for MAC, IPv4 and IPv6 bridge security filtering. // To prevent instances from using IPs that are different from their assigned IPs we use ARP and NDP filtering // to prevent neighbour advertisements that are not allowed. However in order for DHCPv4 & DHCPv6 to work back to -// the LXD host we need to allow DHCPv4 inbound and for IPv6 we need to allow IPv6 Router Solicitation and DHPCv6. +// the Incus host we need to allow DHCPv4 inbound and for IPv6 we need to allow IPv6 Router Solicitation and DHPCv6. // Nftables doesn't support the equivalent of "arp saddr" and "arp saddr ether" at this time so in order to filter // NDP advertisements that come from the genuine Ethernet MAC address but have a spoofed NDP source MAC/IP adddress // we need to use manual header offset extraction. This also drops IPv6 router advertisements from instance. diff --git a/incus/firewall/drivers/drivers_xtables.go b/incus/firewall/drivers/drivers_xtables.go index bded76e5e15..9f38941c819 100644 --- a/incus/firewall/drivers/drivers_xtables.go +++ b/incus/firewall/drivers/drivers_xtables.go @@ -18,10 +18,10 @@ import ( ) // iptablesChainNICFilterPrefix chain prefix used for NIC specific filtering rules. -const iptablesChainNICFilterPrefix = "lxd_nic" +const iptablesChainNICFilterPrefix = "incus_nic" // iptablesChainACLFilterPrefix chain used for ACL specific filtering rules. -const iptablesChainACLFilterPrefix = "lxd_acl" +const iptablesChainACLFilterPrefix = "incus_acl" // iptablesCommentPrefix is used to prefix the rule comment. const iptablesCommentPrefix = "generated for" @@ -30,7 +30,7 @@ const iptablesCommentPrefix = "generated for" // As its own locking mechanism isn't always available. var ebtablesMu sync.Mutex -// Xtables is an implmentation of LXD firewall using {ip, ip6, eb}tables. +// Xtables is an implmentation of Incus firewall using {ip, ip6, eb}tables. type Xtables struct{} // String returns the driver name. @@ -159,12 +159,12 @@ func (d Xtables) ebtablesInUse() bool { // networkIPTablesComment returns the iptables comment that is added to each network related rule. func (d Xtables) networkIPTablesComment(networkName string) string { - return fmt.Sprintf("LXD network %s", networkName) + return fmt.Sprintf("Incus network %s", networkName) } // networkForwardIPTablesComment returns the iptables comment that is added to each network forward related rule. func (d Xtables) networkForwardIPTablesComment(networkName string) string { - return fmt.Sprintf("LXD network-forward %s", networkName) + return fmt.Sprintf("Incus network-forward %s", networkName) } // networkSetupNICFilteringChain creates the NIC filtering chain if it doesn't exist, and adds the jump rules to @@ -236,7 +236,7 @@ func (d Xtables) networkSetupACLFilteringChains(networkName string) error { // point it becomes indistinguishable from FORWARD traffic. So unlike OVN an ACL rule cannot be // used to block baseline service traffic. - // Allow DNS to LXD host. + // Allow DNS to Incus host. err = d.iptablesPrepend(ipVersion, comment, "filter", "INPUT", "-i", networkName, "-p", "tcp", "--dport", "53", "-j", "ACCEPT") if err != nil { return err @@ -248,7 +248,7 @@ func (d Xtables) networkSetupACLFilteringChains(networkName string) error { } if ipVersion == 4 { - // Allow DHCPv4 to/from LXD host. + // Allow DHCPv4 to/from Incus host. err = d.iptablesPrepend(ipVersion, comment, "filter", "INPUT", "-i", networkName, "-p", "udp", "--sport", "68", "--dport", "67", "-j", "ACCEPT") if err != nil { return err @@ -259,7 +259,7 @@ func (d Xtables) networkSetupACLFilteringChains(networkName string) error { return err } - // Allow core ICMPv4 to/from LXD host. + // Allow core ICMPv4 to/from Incus host. for _, icmpType := range []int{3, 11, 12} { err = d.iptablesPrepend(ipVersion, comment, "filter", "INPUT", "-i", networkName, "-p", "icmp", "-m", "icmp", "--icmp-type", fmt.Sprintf("%d", icmpType), "-j", "ACCEPT") if err != nil { @@ -274,7 +274,7 @@ func (d Xtables) networkSetupACLFilteringChains(networkName string) error { } if ipVersion == 6 { - // Allow DHCPv6 to/from LXD host. + // Allow DHCPv6 to/from Incus host. err = d.iptablesPrepend(ipVersion, comment, "filter", "INPUT", "-i", networkName, "-p", "udp", "--sport", "546", "--dport", "547", "-j", "ACCEPT") if err != nil { return err @@ -285,7 +285,7 @@ func (d Xtables) networkSetupACLFilteringChains(networkName string) error { return err } - // Allow core ICMPv6 to/from LXD host. + // Allow core ICMPv6 to/from Incus host. for _, icmpType := range []int{1, 2, 3, 4, 133, 135, 136, 143} { err = d.iptablesPrepend(ipVersion, comment, "filter", "INPUT", "-i", networkName, "-p", "icmpv6", "-m", "icmp6", "--icmpv6-type", fmt.Sprintf("%d", icmpType), "-j", "ACCEPT") if err != nil { @@ -390,7 +390,7 @@ func (d Xtables) networkSetupICMPDHCPDNSAccess(networkName string, ipVersion uin {"4", networkName, "filter", "OUTPUT", "-o", networkName, "-p", "udp", "--sport", "53", "-j", "ACCEPT"}, {"4", networkName, "filter", "OUTPUT", "-o", networkName, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}} - // Allow core ICMPv4 to/from LXD host. + // Allow core ICMPv4 to/from Incus host. for _, icmpType := range []int{3, 11, 12} { rules = append(rules, []string{"4", networkName, "filter", "INPUT", "-i", networkName, "-p", "icmp", "-m", "icmp", "--icmp-type", fmt.Sprintf("%d", icmpType), "-j", "ACCEPT"}) rules = append(rules, []string{"4", networkName, "filter", "OUTPUT", "-o", networkName, "-p", "icmp", "-m", "icmp", "--icmp-type", fmt.Sprintf("%d", icmpType), "-j", "ACCEPT"}) @@ -404,7 +404,7 @@ func (d Xtables) networkSetupICMPDHCPDNSAccess(networkName string, ipVersion uin {"6", networkName, "filter", "OUTPUT", "-o", networkName, "-p", "udp", "--sport", "53", "-j", "ACCEPT"}, {"6", networkName, "filter", "OUTPUT", "-o", networkName, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}} - // Allow core ICMPv6 to/from LXD host. + // Allow core ICMPv6 to/from Incus host. for _, icmpType := range []int{1, 2, 3, 4, 133, 135, 136, 143} { rules = append(rules, []string{"6", networkName, "filter", "INPUT", "-i", networkName, "-p", "icmpv6", "-m", "icmp6", "--icmpv6-type", fmt.Sprintf("%d", icmpType), "-j", "ACCEPT"}) } @@ -801,11 +801,11 @@ func (d Xtables) NetworkClear(networkName string, delete bool, ipVersions []uint // instanceDeviceIPTablesComment returns the iptables comment that is added to each instance device related rule. func (d Xtables) instanceDeviceIPTablesComment(projectName string, instanceName string, deviceName string) string { - return fmt.Sprintf("LXD container %s (%s)", project.Instance(projectName, instanceName), deviceName) + return fmt.Sprintf("Incus container %s (%s)", project.Instance(projectName, instanceName), deviceName) } // InstanceSetupBridgeFilter sets up the filter rules to apply bridged device IP filtering. -// If the parent bridge is managed by LXD then parentManaged argument should be true so that the rules added can +// If the parent bridge is managed by Incus then parentManaged argument should be true so that the rules added can // use the iptablesChainACLFilterPrefix chain. If not they are added to the main filter chains directly (which only // works for unmanaged bridges because those don't support ACLs). func (d Xtables) InstanceSetupBridgeFilter(projectName string, instanceName string, deviceName string, parentName string, hostName string, hwAddr string, IPv4Nets []*net.IPNet, IPv6Nets []*net.IPNet, parentManaged bool) error { @@ -860,7 +860,7 @@ func (d Xtables) InstanceClearBridgeFilter(projectName string, instanceName stri } errs := []error{} - // Iterate through each active rule on the host and try and match it to one the LXD rules. + // Iterate through each active rule on the host and try and match it to one the Incus rules. for _, line := range strings.Split(out, "\n") { line = strings.TrimSpace(line) fields := strings.Fields(line) @@ -877,7 +877,7 @@ func (d Xtables) InstanceClearBridgeFilter(projectName string, instanceName stri continue } - // If we get this far, then the current host rule matches one of our LXD + // If we get this far, then the current host rule matches one of our Incus // rules, so we should run the modified command to delete it. _, err = shared.RunCommand(fields[0], fields[1:]...) if err != nil { diff --git a/incus/firewall/firewall_interface.go b/incus/firewall/firewall_interface.go index 8bfa2e2e91f..7b6611372a7 100644 --- a/incus/firewall/firewall_interface.go +++ b/incus/firewall/firewall_interface.go @@ -6,7 +6,7 @@ import ( drivers "github.com/cyphar/incus/incus/firewall/drivers" ) -// Firewall represents a LXD firewall. +// Firewall represents a Incus firewall. type Firewall interface { String() string Compat() (bool, error) diff --git a/incus/firewall/firewall_load.go b/incus/firewall/firewall_load.go index 89faf8fd0bc..77af91de625 100644 --- a/incus/firewall/firewall_load.go +++ b/incus/firewall/firewall_load.go @@ -35,10 +35,10 @@ func New() Firewall { } // If neither nftables nor xtables are compatible, we fallback to xtables. - // This continues the existing behaviour of allowing LXD to start with potentially an incomplete firewall + // This continues the existing behaviour of allowing Incus to start with potentially an incomplete firewall // backend, so that only networks and instances using those features may fail to function properly. // The most common scenario for this is when xtables is using nft shim commands but the nft command itself - // is not installed. In this case LXD will use the xtables shim commands but with the potential of problems + // is not installed. In this case Incus will use the xtables shim commands but with the potential of problems // due to differences between the original xtables commands and the shim commands provided by nft. if nftablesCompatErr != nil && xtablesCompatErr != nil { logger.Warnf(`Firewall failed to detect any compatible driver, falling back to "xtables" (but some features may not work as expected due to: %v)`, xtablesCompatErr) diff --git a/incus/images.go b/incus/images.go index ebe91ae44be..2d3ded7ecd2 100644 --- a/incus/images.go +++ b/incus/images.go @@ -547,9 +547,9 @@ func getImgPostInfo(s *state.State, r *http.Request, builddir string, project st var imageMeta *api.ImageMetadata l := logger.AddContext(logger.Ctx{"function": "getImgPostInfo"}) - info.Public = shared.IsTrue(r.Header.Get("X-LXD-public")) - propHeaders := r.Header[http.CanonicalHeaderKey("X-LXD-properties")] - profilesHeaders := r.Header.Get("X-LXD-profiles") + info.Public = shared.IsTrue(r.Header.Get("X-Incus-public")) + propHeaders := r.Header[http.CanonicalHeaderKey("X-Incus-properties")] + profilesHeaders := r.Header.Get("X-Incus-profiles") ctype, ctypeParams, err := mime.ParseMediaType(r.Header.Get("Content-Type")) if err != nil { ctype = "application/octet-stream" @@ -630,7 +630,7 @@ func getImgPostInfo(s *state.State, r *http.Request, builddir string, project st info.Filename = part.FileName() info.Fingerprint = fmt.Sprintf("%x", sha256.Sum(nil)) - expectedFingerprint := r.Header.Get("X-LXD-fingerprint") + expectedFingerprint := r.Header.Get("X-Incus-fingerprint") if expectedFingerprint != "" && info.Fingerprint != expectedFingerprint { err = fmt.Errorf("fingerprints don't match, got %s expected %s", info.Fingerprint, expectedFingerprint) return nil, err @@ -675,10 +675,10 @@ func getImgPostInfo(s *state.State, r *http.Request, builddir string, project st info.Size = size - info.Filename = r.Header.Get("X-LXD-filename") + info.Filename = r.Header.Get("X-Incus-filename") info.Fingerprint = fmt.Sprintf("%x", sha256.Sum(nil)) - expectedFingerprint := r.Header.Get("X-LXD-fingerprint") + expectedFingerprint := r.Header.Get("X-Incus-fingerprint") if expectedFingerprint != "" && info.Fingerprint != expectedFingerprint { l.Error("Fingerprints don't match", logger.Ctx{ "got": info.Fingerprint, @@ -869,35 +869,35 @@ func imageCreateInPool(s *state.State, info *api.Image, storagePool string) erro // description: Raw image file // required: false // - in: header -// name: X-LXD-secret +// name: X-Incus-secret // description: Push secret for server to server communication // schema: // type: string // example: RANDOM-STRING // - in: header -// name: X-LXD-fingerprint +// name: X-Incus-fingerprint // description: Expected fingerprint when pushing a raw image // schema: // type: string // - in: header -// name: X-LXD-properties +// name: X-Incus-properties // description: Descriptive properties // schema: // type: object // additionalProperties: // type: string // - in: header -// name: X-LXD-public +// name: X-Incus-public // description: Whether the image is available to unauthenticated users // schema: // type: boolean // - in: header -// name: X-LXD-filename +// name: X-Incus-filename // description: Original filename of the image // schema: // type: string // - in: header -// name: X-LXD-profiles +// name: X-Incus-profiles // description: List of profiles to use // schema: // type: array @@ -917,8 +917,8 @@ func imagesPost(d *Daemon, r *http.Request) response.Response { trusted := d.checkTrustedClient(r) == nil && allowProjectPermission("images", "manage-images")(d, r) == response.EmptySyncResponse - secret := r.Header.Get("X-LXD-secret") - fingerprint := r.Header.Get("X-LXD-fingerprint") + secret := r.Header.Get("X-Incus-secret") + fingerprint := r.Header.Get("X-Incus-fingerprint") projectName := projectParam(r) var imageMetadata map[string]any diff --git a/incus/instance/drivers/driver_lxc.go b/incus/instance/drivers/driver_lxc.go index ab3552c9d1c..8651a5fa214 100644 --- a/incus/instance/drivers/driver_lxc.go +++ b/incus/instance/drivers/driver_lxc.go @@ -827,7 +827,7 @@ func (d *lxc) initLXC(config bool) (*liblxc.Container, error) { } // For lxcfs - templateConfDir := os.Getenv("LXD_LXC_TEMPLATE_CONFIG") + templateConfDir := os.Getenv("INCUS_LXC_TEMPLATE_CONFIG") if templateConfDir == "" { templateConfDir = "/usr/share/lxc/config" } @@ -947,8 +947,8 @@ func (d *lxc) initLXC(config bool) (*liblxc.Container, error) { } // Setup devlxd - if shared.IsTrueOrEmpty(d.expandedConfig["security.devlxd"]) { - err = lxcSetConfigItem(cc, "lxc.mount.entry", fmt.Sprintf("%s dev/lxd none bind,create=dir 0 0", shared.VarPath("devlxd"))) + if shared.IsTrueOrEmpty(d.expandedConfig["security.guestapi"]) { + err = lxcSetConfigItem(cc, "lxc.mount.entry", fmt.Sprintf("%s dev/incus none bind,create=dir 0 0", shared.VarPath("devlxd"))) if err != nil { return nil, err } @@ -1036,7 +1036,7 @@ func (d *lxc) initLXC(config bool) (*liblxc.Container, error) { // Setup NVIDIA runtime if shared.IsTrue(d.expandedConfig["nvidia.runtime"]) { - hookDir := os.Getenv("LXD_LXC_HOOK") + hookDir := os.Getenv("INCUS_LXC_HOOK") if hookDir == "" { hookDir = "/usr/share/lxc/hooks" } @@ -1283,9 +1283,9 @@ func (d *lxc) initLXC(config bool) (*liblxc.Container, error) { // Setup shmounts if d.state.OS.LXCFeatures["mount_injection_file"] { - err = lxcSetConfigItem(cc, "lxc.mount.auto", fmt.Sprintf("shmounts:%s:/dev/.lxd-mounts", d.ShmountsPath())) + err = lxcSetConfigItem(cc, "lxc.mount.auto", fmt.Sprintf("shmounts:%s:/dev/.incus-mounts", d.ShmountsPath())) } else { - err = lxcSetConfigItem(cc, "lxc.mount.entry", fmt.Sprintf("%s dev/.lxd-mounts none bind,create=dir 0 0", d.ShmountsPath())) + err = lxcSetConfigItem(cc, "lxc.mount.entry", fmt.Sprintf("%s dev/.incus-mounts none bind,create=dir 0 0", d.ShmountsPath())) } if err != nil { @@ -4333,9 +4333,9 @@ func (d *lxc) Update(args db.InstanceArgs, userRequested bool) error { if err != nil { return err } - } else if key == "security.devlxd" { + } else if key == "security.guestapi" { if shared.IsTrueOrEmpty(value) { - err = d.insertMount(shared.VarPath("devlxd"), "/dev/lxd", "none", unix.MS_BIND, idmap.IdmapStorageNone) + err = d.insertMount(shared.VarPath("devlxd"), "/dev/incus", "none", unix.MS_BIND, idmap.IdmapStorageNone) if err != nil { return err } @@ -4348,14 +4348,14 @@ func (d *lxc) Update(args db.InstanceArgs, userRequested bool) error { defer func() { _ = files.Close() }() - _, err = files.Lstat("/dev/lxd") + _, err = files.Lstat("/dev/incus") if err == nil { - err = d.removeMount("/dev/lxd") + err = d.removeMount("/dev/incus") if err != nil { return err } - err = files.Remove("/dev/lxd") + err = files.Remove("/dev/incus") if err != nil { return err } @@ -7459,7 +7459,7 @@ func (d *lxc) insertMountLXD(source, target, fstype string, flags int, mntnsPID } // Move the mount inside the container - mntsrc := filepath.Join("/dev/.lxd-mounts", filepath.Base(tmpMount)) + mntsrc := filepath.Join("/dev/.incus-mounts", filepath.Base(tmpMount)) pidStr := fmt.Sprintf("%d", pid) pidFdNr, pidFd := seccomp.MakePidFd(pid, d.state) diff --git a/incus/instance/drivers/driver_qemu.go b/incus/instance/drivers/driver_qemu.go index c4490d6f430..1980819f3bb 100644 --- a/incus/instance/drivers/driver_qemu.go +++ b/incus/instance/drivers/driver_qemu.go @@ -776,8 +776,8 @@ func (d *qemu) Rebuild(img *api.Image, op *operations.Operation) error { } func (d *qemu) ovmfPath() string { - if os.Getenv("LXD_OVMF_PATH") != "" { - return os.Getenv("LXD_OVMF_PATH") + if os.Getenv("INCUS_OVMF_PATH") != "" { + return os.Getenv("INCUS_OVMF_PATH") } return "/usr/share/OVMF" @@ -1858,7 +1858,7 @@ func (d *qemu) getAgentConnectionInfo() (*agentAPI.API10Put, error) { req := agentAPI.API10Put{ Certificate: string(d.state.Endpoints.NetworkCert().PublicKey()), - Devlxd: shared.IsTrueOrEmpty(d.expandedConfig["security.devlxd"]), + Devlxd: shared.IsTrueOrEmpty(d.expandedConfig["security.guestapi"]), CID: vsock.Host, // Always tell lxd-agent to connect to LXD using Host Context ID to support nesting. Port: vsockaddr.Port, } @@ -5115,7 +5115,7 @@ func (d *qemu) Update(args db.InstanceArgs, userRequested bool) error { "limits.memory", "security.agent.metrics", "security.csm", - "security.devlxd", + "security.guestapi", "security.secureboot", } @@ -5199,7 +5199,7 @@ func (d *qemu) Update(args db.InstanceArgs, userRequested bool) error { } else if key == "security.secureboot" { // Defer rebuilding nvram until next start. d.localConfig["volatile.apply_nvram"] = "true" - } else if key == "security.devlxd" { + } else if key == "security.guestapi" { err = d.advertiseVsockAddress() if err != nil { return err diff --git a/incus/instance/instance_utils.go b/incus/instance/instance_utils.go index 2f8336537c8..4c089e043b4 100644 --- a/incus/instance/instance_utils.go +++ b/incus/instance/instance_utils.go @@ -131,7 +131,7 @@ func ValidConfig(sysOS *sys.OS, config map[string]string, expanded bool, instanc return fmt.Errorf("LXD doesn't have a uid/gid allocation. In this mode, only privileged containers are supported") } - unprivOnly := os.Getenv("LXD_UNPRIVILEGED_ONLY") + unprivOnly := os.Getenv("INCUS_UNPRIVILEGED_ONLY") if shared.IsTrue(unprivOnly) { if config["raw.idmap"] != "" { err := AllowedUnprivilegedOnlyMap(config["raw.idmap"]) @@ -216,7 +216,7 @@ func lxcValidConfig(rawLxc string) error { continue } - unprivOnly := os.Getenv("LXD_UNPRIVILEGED_ONLY") + unprivOnly := os.Getenv("INCUS_UNPRIVILEGED_ONLY") if shared.IsTrue(unprivOnly) { if key == "lxc.idmap" || key == "lxc.id_map" || key == "lxc.include" { return fmt.Errorf("%s can't be set in raw.lxc as LXD was configured to only allow unprivileged containers", key) diff --git a/incus/instance_file.go b/incus/instance_file.go index 4d4cb73f802..93b507a026f 100644 --- a/incus/instance_file.go +++ b/incus/instance_file.go @@ -107,23 +107,23 @@ func instanceFileHandler(d *Daemon, r *http.Request) response.Response { // "200": // description: Raw file or directory listing // headers: -// X-LXD-uid: +// X-Incus-uid: // description: File owner UID // schema: // type: integer -// X-LXD-gid: +// X-Incus-gid: // description: File owner GID // schema: // type: integer -// X-LXD-mode: +// X-Incus-mode: // description: Mode mask // schema: // type: integer -// X-LXD-modified: +// X-Incus-modified: // description: Last modified date // schema: // type: string -// X-LXD-type: +// X-Incus-type: // description: Type of file (file, symlink or directory) // schema: // type: string @@ -179,11 +179,11 @@ func instanceFileGet(s *state.State, inst instance.Instance, path string, r *htt // Prepare the response. headers := map[string]string{ - "X-LXD-uid": fmt.Sprintf("%d", fs.UID), - "X-LXD-gid": fmt.Sprintf("%d", fs.GID), - "X-LXD-mode": fmt.Sprintf("%04o", stat.Mode().Perm()), - "X-LXD-modified": stat.ModTime().UTC().String(), - "X-LXD-type": fileType, + "X-Incus-uid": fmt.Sprintf("%d", fs.UID), + "X-Incus-gid": fmt.Sprintf("%d", fs.GID), + "X-Incus-mode": fmt.Sprintf("%04o", stat.Mode().Perm()), + "X-Incus-modified": stat.ModTime().UTC().String(), + "X-Incus-type": fileType, } if fileType == "file" { @@ -285,23 +285,23 @@ func instanceFileGet(s *state.State, inst instance.Instance, path string, r *htt // "200": // description: Raw file or directory listing // headers: -// X-LXD-uid: +// X-Incus-uid: // description: File owner UID // schema: // type: integer -// X-LXD-gid: +// X-Incus-gid: // description: File owner GID // schema: // type: integer -// X-LXD-mode: +// X-Incus-mode: // description: Mode mask // schema: // type: integer -// X-LXD-modified: +// X-Incus-modified: // description: Last modified date // schema: // type: string -// X-LXD-type: +// X-Incus-type: // description: Type of file (file, symlink or directory) // schema: // type: string @@ -342,11 +342,11 @@ func instanceFileHead(s *state.State, inst instance.Instance, path string, r *ht // Prepare the response. headers := map[string]string{ - "X-LXD-uid": fmt.Sprintf("%d", fs.UID), - "X-LXD-gid": fmt.Sprintf("%d", fs.GID), - "X-LXD-mode": fmt.Sprintf("%04o", stat.Mode().Perm()), - "X-LXD-modified": stat.ModTime().UTC().String(), - "X-LXD-type": fileType, + "X-Incus-uid": fmt.Sprintf("%d", fs.UID), + "X-Incus-gid": fmt.Sprintf("%d", fs.GID), + "X-Incus-mode": fmt.Sprintf("%04o", stat.Mode().Perm()), + "X-Incus-modified": stat.ModTime().UTC().String(), + "X-Incus-type": fileType, } // Return an empty body (per RFC for HEAD). @@ -388,31 +388,31 @@ func instanceFileHead(s *state.State, inst instance.Instance, path string, r *ht // name: raw_file // description: Raw file content // - in: header -// name: X-LXD-uid +// name: X-Incus-uid // description: File owner UID // schema: // type: integer // example: 1000 // - in: header -// name: X-LXD-gid +// name: X-Incus-gid // description: File owner GID // schema: // type: integer // example: 1000 // - in: header -// name: X-LXD-mode +// name: X-Incus-mode // description: File mode // schema: // type: integer // example: 0644 // - in: header -// name: X-LXD-type +// name: X-Incus-type // description: Type of file (file, symlink or directory) // schema: // type: string // example: file // - in: header -// name: X-LXD-write +// name: X-Incus-write // description: Write mode (overwrite or append) // schema: // type: string diff --git a/incus/instances_post.go b/incus/instances_post.go index fa8cea018d2..998a55791fd 100644 --- a/incus/instances_post.go +++ b/incus/instances_post.go @@ -812,7 +812,7 @@ func instancesPost(d *Daemon, r *http.Request) response.Response { // If we're getting binary content, process separately if r.Header.Get("Content-Type") == "application/octet-stream" { - return createFromBackup(s, r, targetProjectName, r.Body, r.Header.Get("X-LXD-pool"), r.Header.Get("X-LXD-name")) + return createFromBackup(s, r, targetProjectName, r.Body, r.Header.Get("X-Incus-pool"), r.Header.Get("X-Incus-name")) } // Parse the request diff --git a/incus/main_callhook.go b/incus/main_callhook.go index ae2c9dc4570..8fd66db493d 100644 --- a/incus/main_callhook.go +++ b/incus/main_callhook.go @@ -67,7 +67,7 @@ func (c *cmdCallhook) Run(cmd *cobra.Command, args []string) error { } // Connect to LXD. - socket := os.Getenv("LXD_SOCKET") + socket := os.Getenv("INCUS_SOCKET") if socket == "" { socket = filepath.Join(path, "unix.socket") } diff --git a/incus/main_test.go b/incus/main_test.go index ef20607748d..f608ad8283f 100644 --- a/incus/main_test.go +++ b/incus/main_test.go @@ -58,9 +58,9 @@ func (suite *lxdTestSuite) SetupTest() { suite.tmpdir = tmpdir - err = os.Setenv("LXD_DIR", suite.tmpdir) + err = os.Setenv("INCUS_DIR", suite.tmpdir) if err != nil { - suite.T().Errorf("failed to set LXD_DIR: %v", err) + suite.T().Errorf("failed to set INCUS_DIR: %v", err) } suite.d, err = mockStartDaemon() diff --git a/incus/network/acl/acl_ovn.go b/incus/network/acl/acl_ovn.go index 32b9e80bd5a..aa91ada017a 100644 --- a/incus/network/acl/acl_ovn.go +++ b/incus/network/acl/acl_ovn.go @@ -33,7 +33,7 @@ const ovnACLPriorityPortGroupReject = 400 const ovnACLPriorityPortGroupDrop = 500 // ovnACLPortGroupPrefix prefix used when naming ACL related port groups in OVN. -const ovnACLPortGroupPrefix = "lxd_acl" +const ovnACLPortGroupPrefix = "incus_acl" // OVNACLPortGroupName returns the port group name for a Network ACL ID. func OVNACLPortGroupName(networkACLID int64) openvswitch.OVNPortGroup { @@ -51,7 +51,7 @@ func OVNACLNetworkPortGroupName(networkACLID int64, networkID int64) openvswitch // OVNIntSwitchPortGroupName returns the port group name for a Network ID. func OVNIntSwitchPortGroupName(networkID int64) openvswitch.OVNPortGroup { - return openvswitch.OVNPortGroup(fmt.Sprintf("lxd_net%d", networkID)) + return openvswitch.OVNPortGroup(fmt.Sprintf("incus_net%d", networkID)) } // OVNIntSwitchPortGroupAddressSetPrefix returns the internal switch routes address set prefix for a Network ID. @@ -61,7 +61,7 @@ func OVNIntSwitchPortGroupAddressSetPrefix(networkID int64) openvswitch.OVNAddre // OVNNetworkPrefix returns the prefix used for OVN entities related to a Network ID. func OVNNetworkPrefix(networkID int64) string { - return fmt.Sprintf("lxd-net%d", networkID) + return fmt.Sprintf("incus-net%d", networkID) } // OVNIntSwitchName returns the internal logical switch name for a Network ID. diff --git a/incus/network/acl/driver_common.go b/incus/network/acl/driver_common.go index 7ad3e4490d1..8fd14caf2fb 100644 --- a/incus/network/acl/driver_common.go +++ b/incus/network/acl/driver_common.go @@ -748,7 +748,7 @@ func (d *common) GetLog(clientType request.ClientType) (string, error) { logEntries := []string{} scanner := bufio.NewScanner(logFile) for scanner.Scan() { - logEntry := ovnParseLogEntry(scanner.Text(), fmt.Sprintf("lxd_acl%d-", d.id)) + logEntry := ovnParseLogEntry(scanner.Text(), fmt.Sprintf("incus_acl%d-", d.id)) if logEntry == "" { continue } diff --git a/incus/network/driver_bridge.go b/incus/network/driver_bridge.go index 12ae2ec1892..917c524b4ac 100644 --- a/incus/network/driver_bridge.go +++ b/incus/network/driver_bridge.go @@ -1551,7 +1551,7 @@ func (n *bridge) setup(oldConfig map[string]string) error { // Setup the dnsmasq domain. dnsDomain := n.config["dns.domain"] if dnsDomain == "" { - dnsDomain = "lxd" + dnsDomain = "incus" } if n.config["dns.mode"] != "none" { @@ -1916,7 +1916,7 @@ func (n *bridge) spawnForkDNS(listenAddress string) error { // Setup the dnsmasq domain dnsDomain := n.config["dns.domain"] if dnsDomain == "" { - dnsDomain = "lxd" + dnsDomain = "incus" } // Spawn the daemon using subprocess diff --git a/incus/network/driver_ovn.go b/incus/network/driver_ovn.go index c955ac75bb9..d865457640b 100644 --- a/incus/network/driver_ovn.go +++ b/incus/network/driver_ovn.go @@ -802,7 +802,7 @@ func (n *ovn) getDomainName() string { return n.config["dns.domain"] } - return "lxd" + return "incus" } // getDNSSearchList returns OVN DHCP DNS search list. If no search list set returns getDomainName() as list. @@ -1162,7 +1162,7 @@ func (n *ovn) uplinkOperationLockName(uplinkNet Network) string { // uplinkPortBridgeVars returns the uplink port bridge variables needed for port start/stop. func (n *ovn) uplinkPortBridgeVars(uplinkNet Network) *ovnUplinkPortBridgeVars { - ovsBridge := fmt.Sprintf("lxdovn%d", uplinkNet.ID()) + ovsBridge := fmt.Sprintf("incusovn%d", uplinkNet.ID()) return &ovnUplinkPortBridgeVars{ ovsBridge: ovsBridge, diff --git a/incus/network/network_utils.go b/incus/network/network_utils.go index 9906613994d..56af86be300 100644 --- a/incus/network/network_utils.go +++ b/incus/network/network_utils.go @@ -66,10 +66,10 @@ func RandomDevName(prefix string) string { return iface } -// MACDevName returns interface name with prefix 'lxd' and MAC without leading 2 digits. +// MACDevName returns interface name with prefix 'inc' and MAC without leading 2 digits. func MACDevName(mac net.HardwareAddr) string { devName := strings.Join(strings.Split(mac.String(), ":"), "") - return fmt.Sprintf("lxd%s", devName[2:]) + return fmt.Sprintf("inc%s", devName[2:]) } // UsedByInstanceDevices looks for instance NIC devices using the network and runs the supplied usageFunc for each. diff --git a/incus/network/openvswitch/ovn.go b/incus/network/openvswitch/ovn.go index 364df8811fb..85500f72a76 100644 --- a/incus/network/openvswitch/ovn.go +++ b/incus/network/openvswitch/ovn.go @@ -67,11 +67,11 @@ const OVNIPv6AddressModeDHCPStateful OVNIPv6AddressMode = "dhcpv6_stateful" const OVNIPv6AddressModeDHCPStateless OVNIPv6AddressMode = "dhcpv6_stateless" // OVN External ID names used by LXD. -const ovnExtIDLXDSwitch = "lxd_switch" -const ovnExtIDLXDSwitchPort = "lxd_switch_port" -const ovnExtIDLXDProjectID = "lxd_project_id" -const ovnExtIDLXDPortGroup = "lxd_port_group" -const ovnExtIDLXDLocation = "lxd_location" +const ovnExtIDLXDSwitch = "incus_switch" +const ovnExtIDLXDSwitchPort = "incus_switch_port" +const ovnExtIDLXDProjectID = "incus_project_id" +const ovnExtIDLXDPortGroup = "incus_port_group" +const ovnExtIDLXDLocation = "incus_location" // OVNIPv6RAOpts IPv6 router advertisements options that can be applied to a router. type OVNIPv6RAOpts struct { @@ -1070,7 +1070,7 @@ func (o *OVN) LogicalSwitchPorts(switchName OVNSwitch) (map[OVNSwitchPort]OVNSwi ports := make(map[OVNSwitchPort]OVNSwitchPortUUID, len(lines)) for _, line := range lines { - // E.g. "c709c4a8-ef3f-4ffe-a45a-c75295eb2698 (lxd-net3-instance-fc933d65-0900-46b0-b5f2-4d323342e755-eth0)" + // E.g. "c709c4a8-ef3f-4ffe-a45a-c75295eb2698 (incus-net3-instance-fc933d65-0900-46b0-b5f2-4d323342e755-eth0)" fields := strings.Fields(line) if len(fields) != 2 { diff --git a/incus/project/permissions.go b/incus/project/permissions.go index d50c37229d8..c35398459a0 100644 --- a/incus/project/permissions.go +++ b/incus/project/permissions.go @@ -834,7 +834,7 @@ func isContainerLowLevelOptionForbidden(key string) bool { "raw.idmap", "raw.lxc", "raw.seccomp", - "security.devlxd.images", + "security.guestapi.images", "security.idmap.base", "security.idmap.size", }) { diff --git a/incus/request/const.go b/incus/request/const.go index bce87ffbf98..6008c8711db 100644 --- a/incus/request/const.go +++ b/incus/request/const.go @@ -33,11 +33,11 @@ const ( // Headers. const ( // HeaderForwardedAddress is the forwarded address field in request header. - HeaderForwardedAddress = "X-LXD-forwarded-address" + HeaderForwardedAddress = "X-Incus-forwarded-address" // HeaderForwardedUsername is the forwarded username field in request header. - HeaderForwardedUsername = "X-LXD-forwarded-username" + HeaderForwardedUsername = "X-Incus-forwarded-username" // HeaderForwardedProtocol is the forwarded protocol field in request header. - HeaderForwardedProtocol = "X-LXD-forwarded-protocol" + HeaderForwardedProtocol = "X-Incus-forwarded-protocol" ) diff --git a/incus/storage/drivers/driver_dir.go b/incus/storage/drivers/driver_dir.go index 840910de76d..a616e0d9bd9 100644 --- a/incus/storage/drivers/driver_dir.go +++ b/incus/storage/drivers/driver_dir.go @@ -72,7 +72,7 @@ func (d *dir) Create() error { return fmt.Errorf("Source path '%s' doesn't exist", sourcePath) } - // Check that if within LXD_DIR, we're at our expected spot. + // Check that if within INCUS_DIR, we're at our expected spot. cleanSource := filepath.Clean(sourcePath) if strings.HasPrefix(cleanSource, shared.VarPath()) && cleanSource != GetPoolMountPath(d.name) { return fmt.Errorf("Source path '%s' is within the LXD directory", cleanSource) diff --git a/incus/storage/drivers/utils.go b/incus/storage/drivers/utils.go index 8cb94a75a60..46a4bbf01ed 100644 --- a/incus/storage/drivers/utils.go +++ b/incus/storage/drivers/utils.go @@ -232,7 +232,7 @@ func fsProbe(path string) (string, error) { } // GetPoolMountPath returns the mountpoint of the given pool. -// {LXD_DIR}/storage-pools/. +// {INCUS_DIR}/storage-pools/. func GetPoolMountPath(poolName string) string { return shared.VarPath("storage-pools", poolName) } @@ -820,7 +820,7 @@ func loopFileSizeDefault() (uint64, error) { func loopDeviceSetup(sourcePath string) (string, error) { out, err := shared.RunCommand("losetup", "--find", "--nooverlap", "--direct-io=on", "--show", sourcePath) if err != nil { - if strings.Contains(err.Error(), "direct io") { + if strings.Contains(err.Error(), "direct io") || strings.Contains(err.Error(), "Invalid argument") { out, err = shared.RunCommand("losetup", "--find", "--nooverlap", "--show", sourcePath) if err != nil { return "", err diff --git a/incus/storage/storage.go b/incus/storage/storage.go index 3fc9b1f6811..94011debfb9 100644 --- a/incus/storage/storage.go +++ b/incus/storage/storage.go @@ -50,26 +50,26 @@ func InstanceImportingFilePath(instanceType instancetype.Type, poolName, project } // GetStoragePoolMountPoint returns the mountpoint of the given pool. -// {LXD_DIR}/storage-pools/ +// {INCUS_DIR}/storage-pools/ // Deprecated, use GetPoolMountPath in storage/drivers package. func GetStoragePoolMountPoint(poolName string) string { return shared.VarPath("storage-pools", poolName) } // GetSnapshotMountPoint returns the mountpoint of the given container snapshot. -// ${LXD_DIR}/storage-pools//containers-snapshots/. +// ${INCUS_DIR}/storage-pools//containers-snapshots/. func GetSnapshotMountPoint(projectName, poolName string, snapshotName string) string { return shared.VarPath("storage-pools", poolName, "containers-snapshots", project.Instance(projectName, snapshotName)) } // GetImageMountPoint returns the mountpoint of the given image. -// ${LXD_DIR}/storage-pools//images/. +// ${INCUS_DIR}/storage-pools//images/. func GetImageMountPoint(poolName string, fingerprint string) string { return shared.VarPath("storage-pools", poolName, "images", fingerprint) } // GetStoragePoolVolumeSnapshotMountPoint returns the mountpoint of the given pool volume snapshot. -// ${LXD_DIR}/storage-pools//custom-snapshots//. +// ${INCUS_DIR}/storage-pools//custom-snapshots//. func GetStoragePoolVolumeSnapshotMountPoint(poolName string, snapshotName string) string { return shared.VarPath("storage-pools", poolName, "custom-snapshots", snapshotName) } diff --git a/incus/storage_volumes.go b/incus/storage_volumes.go index 09843f3afff..7703e1ffe6a 100644 --- a/incus/storage_volumes.go +++ b/incus/storage_volumes.go @@ -553,11 +553,11 @@ func storagePoolVolumesTypePost(d *Daemon, r *http.Request) response.Response { // If we're getting binary content, process separately. if r.Header.Get("Content-Type") == "application/octet-stream" { - if r.Header.Get("X-LXD-type") == "iso" { - return createStoragePoolVolumeFromISO(s, r, projectParam(r), projectName, r.Body, poolName, r.Header.Get("X-LXD-name")) + if r.Header.Get("X-Incus-type") == "iso" { + return createStoragePoolVolumeFromISO(s, r, projectParam(r), projectName, r.Body, poolName, r.Header.Get("X-Incus-name")) } - return createStoragePoolVolumeFromBackup(s, r, projectParam(r), projectName, r.Body, poolName, r.Header.Get("X-LXD-name")) + return createStoragePoolVolumeFromBackup(s, r, projectParam(r), projectName, r.Body, poolName, r.Header.Get("X-Incus-name")) } req := api.StorageVolumesPost{} diff --git a/incus/sys/apparmor.go b/incus/sys/apparmor.go index 52b7073ac5f..054b0a1ad67 100644 --- a/incus/sys/apparmor.go +++ b/incus/sys/apparmor.go @@ -23,7 +23,7 @@ func (s *OS) initAppArmor() []cluster.Warning { /* Detect AppArmor availability */ _, err := exec.LookPath("apparmor_parser") - if shared.IsFalse(os.Getenv("LXD_SECURITY_APPARMOR")) { + if shared.IsFalse(os.Getenv("INCUS_SECURITY_APPARMOR")) { logger.Warnf("AppArmor support has been manually disabled") dbWarnings = append(dbWarnings, cluster.Warning{ TypeCode: warningtype.AppArmorNotAvailable, diff --git a/incus/sys/os.go b/incus/sys/os.go index 50fb249ae21..132870fd1da 100644 --- a/incus/sys/os.go +++ b/incus/sys/os.go @@ -48,11 +48,11 @@ type OS struct { // Daemon environment Architectures []int // Cache of detected system architectures - BackingFS string // Backing filesystem of $LXD_DIR/containers + BackingFS string // Backing filesystem of $INCUS_DIR/containers ExecPath string // Absolute path to the LXD executable IdmapSet *idmap.IdmapSet // Information about user/group ID mapping InotifyWatch InotifyInfo - LxcPath string // Path to the $LXD_DIR/containers directory + LxcPath string // Path to the $INCUS_DIR/containers directory MockMode bool // If true some APIs will be mocked (for testing) Nodev bool RunningInUserNS bool diff --git a/incus/util/sys.go b/incus/util/sys.go index 6c8e1ffd665..608948d19fb 100644 --- a/incus/util/sys.go +++ b/incus/util/sys.go @@ -39,7 +39,7 @@ func GetArchitectures() ([]int, error) { // GetExecPath returns the path to the current binary. func GetExecPath() string { - execPath := os.Getenv("LXD_EXEC_PATH") + execPath := os.Getenv("INCUS_EXEC_PATH") if execPath != "" { return execPath } diff --git a/scripts/bash/inc b/scripts/bash/inc index c6908260939..d71f0eb8d12 100644 --- a/scripts/bash/inc +++ b/scripts/bash/inc @@ -65,7 +65,7 @@ _have lxc && { fi if [ -n "${SNAP_COMMON:-""}" ]; then - export LXD_DIR=${LXD_DIR:-"${SNAP_COMMON}/lxd/"} + export INCUS_DIR=${INCUS_DIR:-"${SNAP_COMMON}/lxd/"} fi lxc_cmds="alias cluster config console copy delete exec export file \ @@ -104,7 +104,7 @@ _have lxc && { nvidia.driver.capabilities nvidia.require.cuda nvidia.require.driver \ migration.incremental.memory.iterations raw.apparmor raw.idmap raw.qemu \ raw.qemu.conf raw.lxc raw.seccomp security.idmap.base security.idmap.isolated \ - security.idmap.size security.devlxd security.devlxd.images \ + security.idmap.size security.guestapi security.guestapi.images \ security.nesting security.privileged security.protection.delete \ security.protection.shift security.secureboot security.csm \ security.syscalls.allow \ diff --git a/shared/instance.go b/shared/instance.go index 89fa5905b90..e850416e6b5 100644 --- a/shared/instance.go +++ b/shared/instance.go @@ -126,7 +126,7 @@ var InstanceConfigKeysAny = map[string]func(value string) error{ "raw.apparmor": validate.IsAny, "raw.idmap": validate.IsAny, - "security.devlxd": validate.Optional(validate.IsBool), + "security.guestapi": validate.Optional(validate.IsBool), "security.protection.delete": validate.Optional(validate.IsBool), "snapshots.schedule": validate.Optional(validate.IsCron([]string{"@hourly", "@daily", "@midnight", "@weekly", "@monthly", "@annually", "@yearly", "@startup", "@never"})), @@ -211,7 +211,7 @@ var InstanceConfigKeysContainer = map[string]func(value string) error{ "raw.lxc": validate.IsAny, "raw.seccomp": validate.IsAny, - "security.devlxd.images": validate.Optional(validate.IsBool), + "security.guestapi.images": validate.Optional(validate.IsBool), "security.idmap.base": validate.Optional(validate.IsUint32), "security.idmap.isolated": validate.Optional(validate.IsBool), diff --git a/shared/network.go b/shared/network.go index 773f13d8e7d..7f9e49f177d 100644 --- a/shared/network.go +++ b/shared/network.go @@ -61,8 +61,8 @@ func IsConnectionError(err error) bool { func InitTLSConfig() *tls.Config { config := &tls.Config{} - // Restrict to TLS 1.3 unless LXD_INSECURE_TLS is set. - if IsFalseOrEmpty(os.Getenv("LXD_INSECURE_TLS")) { + // Restrict to TLS 1.3 unless INCUS_INSECURE_TLS is set. + if IsFalseOrEmpty(os.Getenv("INCUS_INSECURE_TLS")) { config.MinVersion = tls.VersionTLS13 } else { config.MinVersion = tls.VersionTLS12 diff --git a/shared/subprocess/proc.go b/shared/subprocess/proc.go index b8fa804edcb..d174108858a 100644 --- a/shared/subprocess/proc.go +++ b/shared/subprocess/proc.go @@ -41,7 +41,7 @@ type Process struct { } func (p *Process) hasApparmor() bool { - if shared.IsFalse(os.Getenv("LXD_SECURITY_APPARMOR")) { + if shared.IsFalse(os.Getenv("INCUS_SECURITY_APPARMOR")) { return false } diff --git a/shared/util.go b/shared/util.go index 3eba4cd9a38..be3a5c74f37 100644 --- a/shared/util.go +++ b/shared/util.go @@ -217,9 +217,9 @@ func HostPath(path string) string { } // VarPath returns the provided path elements joined by a slash and -// appended to the end of $LXD_DIR, which defaults to /var/lib/lxd. +// appended to the end of $INCUS_DIR, which defaults to /var/lib/lxd. func VarPath(path ...string) string { - varDir := os.Getenv("LXD_DIR") + varDir := os.Getenv("INCUS_DIR") if varDir == "" { varDir = "/var/lib/lxd" } @@ -229,10 +229,10 @@ func VarPath(path ...string) string { return filepath.Join(items...) } -// CachePath returns the directory that LXD should its cache under. If LXD_DIR is -// set, this path is $LXD_DIR/cache, otherwise it is /var/cache/lxd. +// CachePath returns the directory that LXD should its cache under. If INCUS_DIR is +// set, this path is $INCUS_DIR/cache, otherwise it is /var/cache/lxd. func CachePath(path ...string) string { - varDir := os.Getenv("LXD_DIR") + varDir := os.Getenv("INCUS_DIR") logDir := "/var/cache/lxd" if varDir != "" { logDir = filepath.Join(varDir, "cache") @@ -243,10 +243,10 @@ func CachePath(path ...string) string { return filepath.Join(items...) } -// LogPath returns the directory that LXD should put logs under. If LXD_DIR is -// set, this path is $LXD_DIR/logs, otherwise it is /var/log/lxd. +// LogPath returns the directory that LXD should put logs under. If INCUS_DIR is +// set, this path is $INCUS_DIR/logs, otherwise it is /var/log/lxd. func LogPath(path ...string) string { - varDir := os.Getenv("LXD_DIR") + varDir := os.Getenv("INCUS_DIR") logDir := "/var/log/lxd" if varDir != "" { logDir = filepath.Join(varDir, "logs") @@ -258,27 +258,27 @@ func LogPath(path ...string) string { } func ParseLXDFileHeaders(headers http.Header) (uid int64, gid int64, mode int, type_ string, write string) { - uid, err := strconv.ParseInt(headers.Get("X-LXD-uid"), 10, 64) + uid, err := strconv.ParseInt(headers.Get("X-Incus-uid"), 10, 64) if err != nil { uid = -1 } - gid, err = strconv.ParseInt(headers.Get("X-LXD-gid"), 10, 64) + gid, err = strconv.ParseInt(headers.Get("X-Incus-gid"), 10, 64) if err != nil { gid = -1 } - mode, err = strconv.Atoi(headers.Get("X-LXD-mode")) + mode, err = strconv.Atoi(headers.Get("X-Incus-mode")) if err != nil { mode = -1 } else { - rawMode, err := strconv.ParseInt(headers.Get("X-LXD-mode"), 0, 0) + rawMode, err := strconv.ParseInt(headers.Get("X-Incus-mode"), 0, 0) if err == nil { mode = int(os.FileMode(rawMode) & os.ModePerm) } } - type_ = headers.Get("X-LXD-type") + type_ = headers.Get("X-Incus-type") /* backwards compat: before "type" was introduced, we could only * manipulate files */ @@ -286,7 +286,7 @@ func ParseLXDFileHeaders(headers http.Header) (uid int64, gid int64, mode int, t type_ = "file" } - write = headers.Get("X-LXD-write") + write = headers.Get("X-Incus-write") /* backwards compat: before "write" was introduced, we could only * overwrite files */ diff --git a/shared/version/api.go b/shared/version/api.go index 497b77fb4f7..3d9cca4eb54 100644 --- a/shared/version/api.go +++ b/shared/version/api.go @@ -388,7 +388,7 @@ func APIExtensionsCount() int { // to believe that we have an API extensions count greater than we // actually have. It's used by integration tests to exercise the // cluster upgrade process. - artificialBump := os.Getenv("LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS") + artificialBump := os.Getenv("INCUS_ARTIFICIALLY_BUMP_API_EXTENSIONS") if artificialBump != "" { n, err := strconv.Atoi(artificialBump) if err == nil { diff --git a/test/README.md b/test/README.md index 7e487765116..bc5747a078c 100644 --- a/test/README.md +++ b/test/README.md @@ -10,22 +10,23 @@ To run only the integration tests, run from the test directory: # Environment variables -Name | Default | Description -:-- | :--- | :---------- -`LXD_BACKEND` | dir | What backend to test against (btrfs, ceph, dir, lvm, zfs, or random) -`LXD_CEPH_CLUSTER` | ceph | The name of the ceph cluster to create osd pools in -`LXD_CEPH_CEPHFS` | "" | Enables the CephFS tests using the specified cephfs filesystem for `cephfs` pools -`LXD_CEPH_CEPHOBJECT_RADOSGW` | "" | Enables the Ceph Object tests using the specified radosgw HTTP endpoint for `cephobject` pools -`LXD_CONCURRENT` | 0 | Run concurrency tests, very CPU intensive -`LXD_DEBUG` | 0 | Run lxd, lxc and the shell in debug mode (very verbose) -`LXD_INSPECT` | 0 | Don't teardown the test environment on failure -`LXD_LOGS ` | "" | Path to a directory to copy all the LXD logs to -`LXD_OFFLINE` | 0 | Skip anything that requires network access -`LXD_SKIP_TESTS` | "" | Space-delimited list of test names to skip -`LXD_TEST_IMAGE` | "" (busybox test image) | Path to an image tarball to use instead of the default busybox image -`LXD_TMPFS` | 0 | Sets up a tmpfs for the whole testsuite to run on (fast but needs memory) -`LXD_NIC_SRIOV_PARENT` | "" | Enables SR-IOV NIC tests using the specified parent device -`LXD_IB_PHYSICAL_PARENT` | "" | Enables Infiniband physical tests using the specified parent device -`LXD_IB_SRIOV_PARENT` | "" | Enables Infiniband SR-IOV tests using the specified parent device -`LXD_NIC_BRIDGED_DRIVER` | "" | Specifies bridged NIC driver for tests (either native or openvswitch, defaults to native) -`LXD_REQUIRED_TESTS` | "" | Space-delimited list of test names that must not be skipped if their prerequisites are not met +Name | Default | Description +:-- | :--- | :---------- +`INCUS_BACKEND` | dir | What backend to test against (btrfs, ceph, dir, lvm, zfs, or random) +`INCUS_CEPH_CLUSTER` | ceph | The name of the ceph cluster to create osd pools in +`INCUS_CEPH_CEPHFS` | "" | Enables the CephFS tests using the specified cephfs filesystem for `cephfs` pools +`INCUS_CEPH_CEPHOBJECT_RADOSGW` | "" | Enables the Ceph Object tests using the specified radosgw HTTP endpoint for `cephobject` pools +`INCUS_CONCURRENT` | 0 | Run concurrency tests, very CPU intensive +`INCUS_DEBUG` | 0 | Run incus, inc and the shell in debug mode (very verbose) +`INCUS_INSPECT` | 0 | Don't teardown the test environment on failure +`INCUS_LOGS ` | "" | Path to a directory to copy all the Incus logs to +`INCUS_OFFLINE` | 0 | Skip anything that requires network access +`INCUS_SKIP_TESTS` | "" | Space-delimited list of test names to skip +`INCUS_TEST_IMAGE` | "" (busybox test image) | Path to an image tarball to use instead of the default busybox image +`INCUS_TMPFS` | 0 | Sets up a tmpfs for the whole testsuite to run on (fast but needs memory) +`INCUS_NIC_SRIOV_PARENT` | "" | Enables SR-IOV NIC tests using the specified parent device +`INCUS_IB_PHYSICAL_PARENT` | "" | Enables Infiniband physical tests using the specified parent device +`INCUS_IB_SRIOV_PARENT` | "" | Enables Infiniband SR-IOV tests using the specified parent device +`INCUS_NIC_BRIDGED_DRIVER` | "" | Specifies bridged NIC driver for tests (either native or openvswitch, defaults to native) +`INCUS_REQUIRED_TESTS` | "" | Space-delimited list of test names that must not be skipped if their prerequisites are not met +`INCUS_VERBOSE` | 0 | Run incus, inc and the shell in verbose mode diff --git a/test/backends/btrfs.sh b/test/backends/btrfs.sh index bbc40e61a13..9ab0bcdfdd4 100644 --- a/test/backends/btrfs.sh +++ b/test/backends/btrfs.sh @@ -1,29 +1,29 @@ btrfs_setup() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Setting up btrfs backend in ${LXD_DIR}" + echo "==> Setting up btrfs backend in ${INCUS_DIR}" } btrfs_configure() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")" btrfs size=1GiB - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")" + inc storage create "incustest-$(basename "${INCUS_DIR}")" btrfs size=1GiB + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")" - echo "==> Configuring btrfs backend in ${LXD_DIR}" + echo "==> Configuring btrfs backend in ${INCUS_DIR}" } btrfs_teardown() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Tearing down btrfs backend in ${LXD_DIR}" + echo "==> Tearing down btrfs backend in ${INCUS_DIR}" } diff --git a/test/backends/ceph.sh b/test/backends/ceph.sh index 189566be106..6e04dc4fd57 100644 --- a/test/backends/ceph.sh +++ b/test/backends/ceph.sh @@ -1,29 +1,29 @@ ceph_setup() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Setting up CEPH backend in ${LXD_DIR}" + echo "==> Setting up CEPH backend in ${INCUS_DIR}" } ceph_configure() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Configuring CEPH backend in ${LXD_DIR}" + echo "==> Configuring CEPH backend in ${INCUS_DIR}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")" ceph volume.size=25MiB ceph.osd.pg_num=16 - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")" + inc storage create "incustest-$(basename "${INCUS_DIR}")" ceph volume.size=25MiB ceph.osd.pg_num=16 + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")" } ceph_teardown() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Tearing down CEPH backend in ${LXD_DIR}" + echo "==> Tearing down CEPH backend in ${INCUS_DIR}" } diff --git a/test/backends/dir.sh b/test/backends/dir.sh index 4a8dfffe256..4a0cb6b079c 100644 --- a/test/backends/dir.sh +++ b/test/backends/dir.sh @@ -5,31 +5,31 @@ # Any necessary backend-specific setup dir_setup() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Setting up directory backend in ${LXD_DIR}" + echo "==> Setting up directory backend in ${INCUS_DIR}" } -# Do the API voodoo necessary to configure LXD to use this backend +# Do the API voodoo necessary to configure Incus to use this backend dir_configure() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Configuring directory backend in ${LXD_DIR}" + echo "==> Configuring directory backend in ${INCUS_DIR}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")" dir - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")" + inc storage create "incustest-$(basename "${INCUS_DIR}")" dir + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")" } dir_teardown() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Tearing down directory backend in ${LXD_DIR}" + echo "==> Tearing down directory backend in ${INCUS_DIR}" } diff --git a/test/backends/lvm.sh b/test/backends/lvm.sh index 9ff4231855c..c76acf07c7c 100644 --- a/test/backends/lvm.sh +++ b/test/backends/lvm.sh @@ -1,29 +1,29 @@ lvm_setup() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Setting up lvm backend in ${LXD_DIR}" + echo "==> Setting up lvm backend in ${INCUS_DIR}" } lvm_configure() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Configuring lvm backend in ${LXD_DIR}" + echo "==> Configuring lvm backend in ${INCUS_DIR}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")" lvm volume.size=25MiB size=1GiB - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")" + inc storage create "incustest-$(basename "${INCUS_DIR}")" lvm volume.size=25MiB size=1GiB + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")" } lvm_teardown() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Tearing down lvm backend in ${LXD_DIR}" + echo "==> Tearing down lvm backend in ${INCUS_DIR}" } diff --git a/test/backends/zfs.sh b/test/backends/zfs.sh index 5e55f0160c1..3207df6bba7 100644 --- a/test/backends/zfs.sh +++ b/test/backends/zfs.sh @@ -1,29 +1,29 @@ zfs_setup() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Setting up ZFS backend in ${LXD_DIR}" + echo "==> Setting up ZFS backend in ${INCUS_DIR}" } zfs_configure() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Configuring ZFS backend in ${LXD_DIR}" + echo "==> Configuring ZFS backend in ${INCUS_DIR}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")" zfs size=1GiB - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")" + inc storage create "incustest-$(basename "${INCUS_DIR}")" zfs size=1GiB + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")" } zfs_teardown() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_DIR=$1 + INCUS_DIR=$1 - echo "==> Tearing down ZFS backend in ${LXD_DIR}" + echo "==> Tearing down ZFS backend in ${INCUS_DIR}" } diff --git a/test/deps/import-busybox b/test/deps/import-busybox index 5a0fcfce019..3c72e87cec6 100755 --- a/test/deps/import-busybox +++ b/test/deps/import-busybox @@ -50,11 +50,11 @@ class UnixHTTPConnection(http.client.HTTPConnection): self.sock = sock -class LXD(object): +class Incus(object): workdir = None def __init__(self, path, project="default"): - self.lxd = UnixHTTPConnection(path) + self.incus = UnixHTTPConnection(path) self.project = project # Create our workdir @@ -68,15 +68,15 @@ class LXD(object): def rest_call(self, path, data=None, method="GET", headers={}): if method == "GET" and data: data["project"] = self.project - self.lxd.request( + self.incus.request( method, "%s?%s" % "&".join(["%s=%s" % (key, value) for key, value in data.items()]), headers) else: path += "?project=%s" % self.project - self.lxd.request(method, path, data, headers) + self.incus.request(method, path, data, headers) - r = self.lxd.getresponse() + r = self.incus.getresponse() d = json.loads(r.read().decode("utf-8")) return r.status, d @@ -114,7 +114,7 @@ class LXD(object): def images_upload(self, path, public, filename=None): headers = {} if public: - headers['X-LXD-public'] = "1" + headers['X-Incus-public'] = "1" if isinstance(path, str): headers['Content-Type'] = "application/octet-stream" @@ -311,22 +311,22 @@ user.foo: {{ config_get("user.foo", "_unset_") }} if __name__ == "__main__": - if "LXD_DIR" in os.environ: - lxd_socket = os.path.join(os.environ['LXD_DIR'], "unix.socket") + if "INCUS_DIR" in os.environ: + incus_socket = os.path.join(os.environ['INCUS_DIR'], "unix.socket") else: - lxd_socket = "/var/lib/lxd/unix.socket" + incus_socket = "/var/lib/incus/unix.socket" - if not os.path.exists(lxd_socket): - print("LXD isn't running.") + if not os.path.exists(incus_socket): + print("Incus isn't running.") sys.exit(1) def setup_alias(aliases, fingerprint): - existing = lxd.aliases_list() + existing = incus.aliases_list() for alias in aliases: if alias in existing: - lxd.aliases_remove(alias) - lxd.aliases_create(alias, fingerprint) + incus.aliases_remove(alias) + incus.aliases_create(alias, fingerprint) print("Setup alias: %s" % alias) def import_busybox(parser, args): @@ -342,14 +342,14 @@ if __name__ == "__main__": fingerprint = hashlib.sha256(meta_fd.read() + rootfs_fd.read()).hexdigest() - if fingerprint in lxd.images_list(): + if fingerprint in incus.images_list(): parser.exit(1, "This image is already in the store.\n") if args.filename: - r = lxd.images_upload((meta_path, rootfs_path), args.public, - meta_path.split("/")[-1]) + r = incus.images_upload((meta_path, rootfs_path), args.public, + meta_path.split("/")[-1]) else: - r = lxd.images_upload((meta_path, rootfs_path), args.public) + r = incus.images_upload((meta_path, rootfs_path), args.public) print("Image imported as: %s" % r['fingerprint']) else: path = busybox.create_tarball(template=args.template.split(",")) @@ -357,10 +357,10 @@ if __name__ == "__main__": with open(path, "rb") as fd: fingerprint = hashlib.sha256(fd.read()).hexdigest() - if fingerprint in lxd.images_list(): + if fingerprint in incus.images_list(): parser.exit(1, "This image is already in the store.\n") - r = lxd.images_upload(path, args.public) + r = incus.images_upload(path, args.public) print("Image imported as: %s" % r['fingerprint']) setup_alias(args.alias, fingerprint) @@ -383,7 +383,7 @@ if __name__ == "__main__": # Call the function args = parser.parse_args() - lxd = LXD(lxd_socket, project=args.project) + incus = Incus(incus_socket, project=args.project) try: args.func(parser, args) diff --git a/test/dev_incus-client/dev_incus_client.go b/test/dev_incus-client/dev_incus_client.go index 42f1c837728..fd181edb162 100644 --- a/test/dev_incus-client/dev_incus_client.go +++ b/test/dev_incus-client/dev_incus_client.go @@ -1,7 +1,7 @@ package main /* - * An example of how to use lxd's golang /dev/lxd client. This is intended to + * An example of how to use incus's golang /dev/incus client. This is intended to * be run from inside a container. */ @@ -24,11 +24,11 @@ import ( "github.com/cyphar/incus/shared/api" ) -type devLxdDialer struct { +type devIncusDialer struct { Path string } -func (d devLxdDialer) devLxdDial(ctx context.Context, network, path string) (net.Conn, error) { +func (d devIncusDialer) devIncusDial(ctx context.Context, network, path string) (net.Conn, error) { addr, err := net.ResolveUnixAddr("unix", d.Path) if err != nil { return nil, err @@ -42,15 +42,15 @@ func (d devLxdDialer) devLxdDial(ctx context.Context, network, path string) (net return conn, err } -var devLxdTransport = &http.Transport{ - DialContext: devLxdDialer{"/dev/lxd/sock"}.devLxdDial, +var devIncusTransport = &http.Transport{ + DialContext: devIncusDialer{"/dev/incus/sock"}.devIncusDial, } -func devlxdMonitorStream() { +func devIncusMonitorStream() { client := http.Client{ Transport: &http.Transport{ DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { - return net.Dial("unix", "/dev/lxd/sock") + return net.Dial("unix", "/dev/incus/sock") }, }, } @@ -80,9 +80,9 @@ func devlxdMonitorStream() { } } -func devlxdMonitorWebsocket(c http.Client) { +func devIncusMonitorWebsocket(c http.Client) { dialer := websocket.Dialer{ - NetDialContext: devLxdTransport.DialContext, + NetDialContext: devIncusTransport.DialContext, HandshakeTimeout: time.Second * 5, } @@ -114,11 +114,11 @@ func devlxdMonitorWebsocket(c http.Client) { } } -func devlxdState(ready bool) { +func devIncusState(ready bool) { client := http.Client{ Transport: &http.Transport{ DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { - return net.Dial("unix", "/dev/lxd/sock") + return net.Dial("unix", "/dev/incus/sock") }, }, } @@ -153,7 +153,7 @@ func devlxdState(ready bool) { } func main() { - c := http.Client{Transport: devLxdTransport} + c := http.Client{Transport: devIncusTransport} raw, err := c.Get("http://meshuggah-rocks/") if err != nil { fmt.Println(err) @@ -184,12 +184,12 @@ func main() { if len(os.Args) > 1 { if os.Args[1] == "monitor-websocket" { - devlxdMonitorWebsocket(c) + devIncusMonitorWebsocket(c) os.Exit(0) } if os.Args[1] == "monitor-stream" { - devlxdMonitorStream() + devIncusMonitorStream() os.Exit(0) } @@ -200,7 +200,7 @@ func main() { os.Exit(1) } - devlxdState(ready) + devIncusState(ready) os.Exit(0) } @@ -225,6 +225,6 @@ func main() { fmt.Println(string(value)) } else { - fmt.Println("/dev/lxd ok") + fmt.Println("/dev/incus ok") } } diff --git a/test/extras/speedtest_create.sh b/test/extras/speedtest_create.sh index cb1aea7d275..9d78f00ae2f 100755 --- a/test/extras/speedtest_create.sh +++ b/test/extras/speedtest_create.sh @@ -19,7 +19,7 @@ fi PIDS="" for c in $(seq "$count"); do - lxc init busybox "${CNAME}${c}" 2>&1 & + inc init busybox "${CNAME}${c}" 2>&1 & PIDS="$PIDS $!" done @@ -27,12 +27,12 @@ for pid in $PIDS; do wait "$pid" done -echo -e "\nlxc list: All shutdown" -time lxc list 1>/dev/null +echo -e "\ninc list: All shutdown" +time inc list 1>/dev/null PIDS="" for c in $(seq "$count"); do - lxc start "${CNAME}${c}" 2>&1 & + inc start "${CNAME}${c}" 2>&1 & PIDS="$PIDS $!" done @@ -40,7 +40,7 @@ for pid in $PIDS; do wait "$pid" done -echo -e "\nlxc list: All started" -time lxc list 1>/dev/null +echo -e "\ninc list: All started" +time inc list 1>/dev/null echo -e "\nRun completed" diff --git a/test/extras/speedtest_delete.sh b/test/extras/speedtest_delete.sh index 8c452e42b49..6c4dff10aa5 100755 --- a/test/extras/speedtest_delete.sh +++ b/test/extras/speedtest_delete.sh @@ -16,7 +16,7 @@ fi PIDS="" for c in $(seq "$count"); do - lxc delete "${CNAME}${c}" 2>&1 & + inc delete "${CNAME}${c}" 2>&1 & PIDS="$PIDS $!" done diff --git a/test/extras/stresstest.sh b/test/extras/stresstest.sh index fe357b2119c..3074c8409b2 100755 --- a/test/extras/stresstest.sh +++ b/test/extras/stresstest.sh @@ -4,26 +4,26 @@ export PATH="$GOPATH/bin:$PATH" # /tmp isn't moutned exec on most systems, so we can't actually start # containers that are created there. SRC_DIR="$(pwd)" -LXD_DIR="$(mktemp -d -p "$(pwd)")" -chmod 777 "${LXD_DIR}" -LXD_CONF="$(mktemp -d)" -export SRC_DIR LXD_DIR LXD_CONF -export LXD_FUIDMAP_DIR="${LXD_DIR}/fuidmap" -mkdir -p "${LXD_FUIDMAP_DIR}" +INCUS_DIR="$(mktemp -d -p "$(pwd)")" +chmod 777 "${INCUS_DIR}" +INCUS_CONF="$(mktemp -d)" +export SRC_DIR INCUS_DIR INCUS_CONF +export INCUS_FUIDMAP_DIR="${INCUS_DIR}/fuidmap" +mkdir -p "${INCUS_FUIDMAP_DIR}" BASEURL=https://127.0.0.1:18443 RESULT=failure set -e -if [ -n "$LXD_DEBUG" ]; then +if [ -n "$INCUS_DEBUG" ]; then set -x debug=--debug fi -echo "==> Running the LXD testsuite" +echo "==> Running the Incus testsuite" BASEURL=https://127.0.0.1:18443 my_curl() { - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" "${@}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" "${@}" } wait_for() { @@ -31,9 +31,9 @@ wait_for() { my_curl "$BASEURL$op/wait" } -lxc() { +inc() { INJECTED=0 - CMD="$(command -v lxc)" + CMD="$(command -v inc)" for arg in "${@}"; do if [ "$arg" = "--" ]; then INJECTED=1 @@ -60,19 +60,19 @@ cleanup() { wait_for my_curl -X PUT "$BASEURL$line/state" -d "{\"action\":\"stop\",\"force\":true}" done - # kill the lxds which share our pgrp as parent + # kill the daemons which share our pgrp as parent mygrp="$(awk '{ print $5 }' /proc/self/stat)" - for p in $(pidof lxd); do + for p in $(pidof incus); do pgrp="$(awk '{ print $5 }' "/proc/$p/stat")" if [ "$pgrp" = "$mygrp" ]; then - do_kill_lxd "$p" + do_kill_incus "$p" fi done # Apparently we need to wait a while for everything to die sleep 3 - rm -Rf "${LXD_DIR}" - rm -Rf "${LXD_CONF}" + rm -Rf "${INCUS_DIR}" + rm -Rf "${INCUS_CONF}" echo "" echo "" @@ -81,43 +81,43 @@ cleanup() { trap cleanup EXIT HUP INT TERM -if ! command -v lxc > /dev/null; then - echo "==> Couldn't find lxc" && false +if ! command -v inc > /dev/null; then + echo "==> Couldn't find inc" && false fi -spawn_lxd() { - # LXD_DIR is local here because since `lxc` is actually a function, it - # overwrites the environment and we would lose LXD_DIR's value otherwise. - local LXD_DIR +spawn_incus() { + # INCUS_DIR is local here because since `inc` is actually a function, it + # overwrites the environment and we would lose INCUS_DIR's value otherwise. + local INCUS_DIR addr=$1 - lxddir=$2 + incusdir=$2 shift shift - echo "==> Spawning lxd on $addr in $lxddir" - LXD_DIR="$lxddir" lxd "${debug}" "${@}" > "$lxddir/lxd.log" 2>&1 & + echo "==> Spawning incus on $addr in $incusdir" + INCUS_DIR="$incusdir" incus "${debug}" "${@}" > "$incusdir/incus.log" 2>&1 & - echo "==> Confirming lxd on $addr is responsive" - LXD_DIR="$lxddir" lxd waitready + echo "==> Confirming incus on $addr is responsive" + INCUS_DIR="$incusdir" incus waitready echo "==> Binding to network" - LXD_DIR="$lxddir" lxc config set core.https_address "$addr" + INCUS_DIR="$incusdir" inc config set core.https_address "$addr" echo "==> Setting trust password" - LXD_DIR="$lxddir" lxc config set core.trust_password foo + INCUS_DIR="$incusdir" inc config set core.trust_password foo } -spawn_lxd 127.0.0.1:18443 "$LXD_DIR" +spawn_incus 127.0.0.1:18443 "$INCUS_DIR" ## tests go here -if [ ! -e "$LXD_TEST_IMAGE" ]; then - echo "Please define LXD_TEST_IMAGE" +if [ ! -e "$INCUS_TEST_IMAGE" ]; then + echo "Please define INCUS_TEST_IMAGE" false fi -lxc image import "$LXD_TEST_IMAGE" --alias busybox +inc image import "$INCUS_TEST_IMAGE" --alias busybox -lxc image list -lxc list +inc image list +inc list NUMCREATES=5 createthread() { @@ -126,21 +126,21 @@ createthread() { echo "createthread: starting loop $i out of $NUMCREATES" declare -a pids for j in $(seq 20); do - lxc launch busybox "b.$i.$j" & - pids[$j]=$! + inc launch busybox "b.$i.$j" & + pids[j]=$! done for j in $(seq 20); do # ignore errors if the task has already exited - wait ${pids[$j]} 2>/dev/null || true + wait "${pids[j]}" 2>/dev/null || true done echo "createthread: deleting..." for j in $(seq 20); do - lxc delete "b.$i.$j" & - pids[$j]=$! + inc delete "b.$i.$j" & + pids[j]=$! done for j in $(seq 20); do # ignore errors if the task has already exited - wait ${pids[$j]} 2>/dev/null || true + wait "${pids[j]}" 2>/dev/null || true done done exit 0 @@ -149,7 +149,7 @@ createthread() { listthread() { echo "listthread: I am $$" while true; do - lxc list + inc list sleep 2s done exit 0 @@ -158,9 +158,9 @@ listthread() { configthread() { echo "configthread: I am $$" for i in $(seq 20); do - lxc profile create "p$i" - lxc profile set "p$i" limits.memory 100MiB - lxc profile delete "p$i" + inc profile create "p$i" + inc profile set "p$i" limits.memory 100MiB + inc profile delete "p$i" done exit 0 } @@ -168,31 +168,31 @@ configthread() { disturbthread() { echo "disturbthread: I am $$" while true; do - lxc profile create empty - lxc init busybox disturb1 - lxc profile assign disturb1 empty - lxc start disturb1 - lxc exec disturb1 -- ps -ef - lxc stop disturb1 --force - lxc delete disturb1 - lxc profile delete empty + inc profile create empty + inc init busybox disturb1 + inc profile assign disturb1 empty + inc start disturb1 + inc exec disturb1 -- ps -ef + inc stop disturb1 --force + inc delete disturb1 + inc profile delete empty done exit 0 } echo "Starting create thread" -createthread 2>&1 | tee "$LXD_DIR/createthread.out" & +createthread 2>&1 | tee "$INCUS_DIR/createthread.out" & p1=$! echo "starting the disturb thread" -disturbthread 2>&1 | tee "$LXD_DIR/disturbthread.out" & +disturbthread 2>&1 | tee "$INCUS_DIR/disturbthread.out" & pdisturb=$! echo "Starting list thread" -listthread 2>&1 | tee "$LXD_DIR/listthread.out" & +listthread 2>&1 | tee "$INCUS_DIR/listthread.out" & p2=$! echo "Starting config thread" -configthread 2>&1 | tee "$LXD_DIR/configthread.out" & +configthread 2>&1 | tee "$INCUS_DIR/configthread.out" & p3=$! # wait for listthread to finish diff --git a/test/includes/clustering.sh b/test/includes/clustering.sh index 527abde24eb..74ef6a27f0b 100644 --- a/test/includes/clustering.sh +++ b/test/includes/clustering.sh @@ -28,7 +28,7 @@ setup_clustering_netns() { id="${1}" shift - prefix="lxd$$" + prefix="inc$$" ns="${prefix}${id}" echo "==> Setup clustering netns ${ns}" @@ -87,7 +87,7 @@ EOF } teardown_clustering_netns() { - prefix="lxd$$" + prefix="inc$$" nsbridge="br$$" [ ! -d "${TEST_DIR}/ns/" ] && return @@ -109,14 +109,14 @@ teardown_clustering_netns() { done } -spawn_lxd_and_bootstrap_cluster() { +spawn_incus_and_bootstrap_cluster() { # shellcheck disable=2039,3043 - local LXD_NETNS + local INCUS_NETNS set -e ns="${1}" bridge="${2}" - LXD_DIR="${3}" + INCUS_DIR="${3}" driver="dir" port="" if [ "$#" -ge "4" ]; then @@ -128,56 +128,56 @@ spawn_lxd_and_bootstrap_cluster() { echo "==> Spawn bootstrap cluster node in ${ns} with storage driver ${driver}" - LXD_NETNS="${ns}" spawn_lxd "${LXD_DIR}" false + INCUS_NETNS="${ns}" spawn_incus "${INCUS_DIR}" false ( set -e - cat > "${LXD_DIR}/preseed.yaml" < "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" < Spawn additional cluster node in ${ns} with storage driver ${driver}" - secret="${LXD_SECRET:-"sekret"}" + secret="${INCUS_SECRET:-"sekret"}" - LXD_NETNS="${ns}" spawn_lxd "${LXD_DIR}" false + INCUS_NETNS="${ns}" spawn_incus "${INCUS_DIR}" false ( set -e # If a custom cluster port was given, we need to first set the REST # API address. if [ "${port}" != "8443" ]; then - lxc config set core.https_address "10.1.1.10${index}:8443" + inc config set core.https_address "10.1.1.10${index}:8443" fi - cat > "${LXD_DIR}/preseed.yaml" < "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <> "${LXD_DIR}/preseed.yaml" <> "${INCUS_DIR}/preseed.yaml" <&2 exit 1 fi # setup storage - "$lxd_backend"_setup "${lxddir}" - echo "$lxd_backend" > "${lxddir}/lxd.backend" + "$incus_backend"_setup "${incusdir}" + echo "$incus_backend" > "${incusdir}/incus.backend" - echo "==> Spawning lxd in ${lxddir}" + echo "==> Spawning incus in ${incusdir}" # shellcheck disable=SC2086 - if [ "${LXD_NETNS}" = "" ]; then - LXD_DIR="${lxddir}" lxd --logfile "${lxddir}/lxd.log" "${DEBUG-}" "$@" 2>&1 & + if [ "${INCUS_NETNS}" = "" ]; then + INCUS_DIR="${incusdir}" incus --logfile "${incusdir}/incus.log" "${DEBUG-}" "$@" 2>&1 & else # shellcheck disable=SC2153 - pid="$(cat "${TEST_DIR}/ns/${LXD_NETNS}/PID")" - LXD_DIR="${lxddir}" nsenter -n -m -t "${pid}" lxd --logfile "${lxddir}/lxd.log" "${DEBUG-}" "$@" 2>&1 & + pid="$(cat "${TEST_DIR}/ns/${INCUS_NETNS}/PID")" + INCUS_DIR="${incusdir}" nsenter -n -m -t "${pid}" incus --logfile "${incusdir}/incus.log" "${DEBUG-}" "$@" 2>&1 & fi - LXD_PID=$! - echo "${LXD_PID}" > "${lxddir}/lxd.pid" + INCUS_PID=$! + echo "${INCUS_PID}" > "${incusdir}/incus.pid" # shellcheck disable=SC2153 - echo "${lxddir}" >> "${TEST_DIR}/daemons" - echo "==> Spawned LXD (PID is ${LXD_PID})" + echo "${incusdir}" >> "${TEST_DIR}/daemons" + echo "==> Spawned Incus (PID is ${INCUS_PID})" - echo "==> Confirming lxd is responsive (PID is ${LXD_PID})" - LXD_DIR="${lxddir}" lxd waitready --timeout=300 || (echo "Killing PID ${LXD_PID}" ; kill -9 "${LXD_PID}" ; false) + echo "==> Confirming incus is responsive (PID is ${INCUS_PID})" + INCUS_DIR="${incusdir}" incus waitready --timeout=300 || (echo "Killing PID ${INCUS_PID}" ; kill -9 "${INCUS_PID}" ; false) - if [ "${LXD_NETNS}" = "" ]; then + if [ "${INCUS_NETNS}" = "" ]; then echo "==> Binding to network" for _ in $(seq 10); do addr="127.0.0.1:$(local_tcp_port)" - LXD_DIR="${lxddir}" lxc config set core.https_address "${addr}" || continue - echo "${addr}" > "${lxddir}/lxd.addr" + INCUS_DIR="${incusdir}" inc config set core.https_address "${addr}" || continue + echo "${addr}" > "${incusdir}/incus.addr" echo "==> Bound to ${addr}" break done fi echo "==> Setting trust password" - LXD_DIR="${lxddir}" lxc config set core.trust_password foo + INCUS_DIR="${incusdir}" inc config set core.trust_password foo if [ -n "${DEBUG:-}" ]; then set -x fi - if [ "${LXD_NETNS}" = "" ]; then + if [ "${INCUS_NETNS}" = "" ]; then echo "==> Setting up networking" - LXD_DIR="${lxddir}" lxc profile device add default eth0 nic nictype=p2p name=eth0 + INCUS_DIR="${incusdir}" inc profile device add default eth0 nic nictype=p2p name=eth0 fi if [ "${storage}" = true ]; then echo "==> Configuring storage backend" - "$lxd_backend"_configure "${lxddir}" + "$incus_backend"_configure "${incusdir}" fi } -respawn_lxd() { +respawn_incus() { set +x - # LXD_DIR is local here because since $(lxc) is actually a function, it - # overwrites the environment and we would lose LXD_DIR's value otherwise. + # INCUS_DIR is local here because since $(inc) is actually a function, it + # overwrites the environment and we would lose INCUS_DIR's value otherwise. # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - lxddir=${1} + incusdir=${1} shift wait=${1} shift - echo "==> Spawning lxd in ${lxddir}" + echo "==> Spawning incus in ${incusdir}" # shellcheck disable=SC2086 - if [ "${LXD_NETNS}" = "" ]; then - LXD_DIR="${lxddir}" lxd --logfile "${lxddir}/lxd.log" "${DEBUG-}" "$@" 2>&1 & + if [ "${INCUS_NETNS}" = "" ]; then + INCUS_DIR="${incusdir}" incus --logfile "${incusdir}/incus.log" "${DEBUG-}" "$@" 2>&1 & else - pid="$(cat "${TEST_DIR}/ns/${LXD_NETNS}/PID")" - LXD_DIR="${lxddir}" nsenter -n -m -t "${pid}" lxd --logfile "${lxddir}/lxd.log" "${DEBUG-}" "$@" 2>&1 & + pid="$(cat "${TEST_DIR}/ns/${INCUS_NETNS}/PID")" + INCUS_DIR="${incusdir}" nsenter -n -m -t "${pid}" incus --logfile "${incusdir}/incus.log" "${DEBUG-}" "$@" 2>&1 & fi - LXD_PID=$! - echo "${LXD_PID}" > "${lxddir}/lxd.pid" - echo "==> Spawned LXD (PID is ${LXD_PID})" + INCUS_PID=$! + echo "${INCUS_PID}" > "${incusdir}/incus.pid" + echo "==> Spawned Incus (PID is ${INCUS_PID})" if [ "${wait}" = true ]; then - echo "==> Confirming lxd is responsive (PID is ${LXD_PID})" - LXD_DIR="${lxddir}" lxd waitready --timeout=300 || (echo "Killing PID ${LXD_PID}" ; kill -9 "${LXD_PID}" ; false) + echo "==> Confirming incus is responsive (PID is ${INCUS_PID})" + INCUS_DIR="${incusdir}" incus waitready --timeout=300 || (echo "Killing PID ${INCUS_PID}" ; kill -9 "${INCUS_PID}" ; false) fi if [ -n "${DEBUG:-}" ]; then @@ -113,72 +113,72 @@ respawn_lxd() { fi } -kill_lxd() { - # LXD_DIR is local here because since $(lxc) is actually a function, it - # overwrites the environment and we would lose LXD_DIR's value otherwise. +kill_incus() { + # INCUS_DIR is local here because since $(inc) is actually a function, it + # overwrites the environment and we would lose INCUS_DIR's value otherwise. # shellcheck disable=2039,3043 - local LXD_DIR daemon_dir daemon_pid check_leftovers lxd_backend + local INCUS_DIR daemon_dir daemon_pid check_leftovers incus_backend daemon_dir=${1} - LXD_DIR=${daemon_dir} + INCUS_DIR=${daemon_dir} # Check if already killed - if [ ! -f "${daemon_dir}/lxd.pid" ]; then + if [ ! -f "${daemon_dir}/incus.pid" ]; then return fi - daemon_pid=$(cat "${daemon_dir}/lxd.pid") + daemon_pid=$(cat "${daemon_dir}/incus.pid") check_leftovers="false" - lxd_backend=$(storage_backend "$daemon_dir") - echo "==> Killing LXD at ${daemon_dir} (${daemon_pid})" + incus_backend=$(storage_backend "$daemon_dir") + echo "==> Killing Incus at ${daemon_dir} (${daemon_pid})" if [ -e "${daemon_dir}/unix.socket" ]; then # Delete all containers echo "==> Deleting all containers" - for container in $(timeout -k 2 2 lxc list --force-local --format csv --columns n); do - timeout -k 10 10 lxc delete "${container}" --force-local -f || true + for container in $(timeout -k 2 2 inc list --force-local --format csv --columns n); do + timeout -k 10 10 inc delete "${container}" --force-local -f || true done # Delete all images echo "==> Deleting all images" - for image in $(timeout -k 2 2 lxc image list --force-local --format csv --columns f); do - timeout -k 10 10 lxc image delete "${image}" --force-local || true + for image in $(timeout -k 2 2 inc image list --force-local --format csv --columns f); do + timeout -k 10 10 inc image delete "${image}" --force-local || true done # Delete all profiles echo "==> Deleting all profiles" - for profile in $(timeout -k 2 2 lxc profile list --force-local --format csv | cut -d, -f1); do - timeout -k 10 10 lxc profile delete "${profile}" --force-local || true + for profile in $(timeout -k 2 2 inc profile list --force-local --format csv | cut -d, -f1); do + timeout -k 10 10 inc profile delete "${profile}" --force-local || true done # Delete all networks echo "==> Deleting all managed networks" - for network in $(timeout -k 2 2 lxc network list --force-local --format csv | awk -F, '{if ($3 == "YES") {print $1}}'); do - timeout -k 10 10 lxc network delete "${network}" --force-local || true + for network in $(timeout -k 2 2 inc network list --force-local --format csv | awk -F, '{if ($3 == "YES") {print $1}}'); do + timeout -k 10 10 inc network delete "${network}" --force-local || true done # Clear config of the default profile since the profile itself cannot # be deleted. echo "==> Clearing config of default profile" - printf 'config: {}\ndevices: {}' | timeout -k 5 5 lxc profile edit default + printf 'config: {}\ndevices: {}' | timeout -k 5 5 inc profile edit default echo "==> Deleting all storage pools" - for storage_pool in $(lxc query "/1.0/storage-pools?recursion=1" | jq .[].name -r); do + for storage_pool in $(inc query "/1.0/storage-pools?recursion=1" | jq .[].name -r); do # Delete the storage volumes. - for volume in $(lxc query "/1.0/storage-pools/${storage_pool}/volumes/custom?recursion=1" | jq .[].name -r); do + for volume in $(inc query "/1.0/storage-pools/${storage_pool}/volumes/custom?recursion=1" | jq .[].name -r); do echo "==> Deleting storage volume ${volume} on ${storage_pool}" - timeout -k 20 20 lxc storage volume delete "${storage_pool}" "${volume}" --force-local || true + timeout -k 20 20 inc storage volume delete "${storage_pool}" "${volume}" --force-local || true done # Delete the storage buckets. - for bucket in $(lxc query "/1.0/storage-pools/${storage_pool}/buckets?recursion=1" | jq .[].name -r); do + for bucket in $(inc query "/1.0/storage-pools/${storage_pool}/buckets?recursion=1" | jq .[].name -r); do echo "==> Deleting storage bucket ${bucket} on ${storage_pool}" - timeout -k 20 20 lxc storage bucket delete "${storage_pool}" "${bucket}" --force-local || true + timeout -k 20 20 inc storage bucket delete "${storage_pool}" "${bucket}" --force-local || true done ## Delete the storage pool. - timeout -k 20 20 lxc storage delete "${storage_pool}" --force-local || true + timeout -k 20 20 inc storage delete "${storage_pool}" --force-local || true done echo "==> Checking for locked DB tables" @@ -187,22 +187,22 @@ kill_lxd() { done # Kill the daemon - timeout -k 30 30 lxd shutdown || kill -9 "${daemon_pid}" 2>/dev/null || true + timeout -k 30 30 incus shutdown || kill -9 "${daemon_pid}" 2>/dev/null || true sleep 2 # Cleanup shmounts (needed due to the forceful kill) find "${daemon_dir}" -name shmounts -exec "umount" "-l" "{}" \; >/dev/null 2>&1 || true - find "${daemon_dir}" -name devlxd -exec "umount" "-l" "{}" \; >/dev/null 2>&1 || true + find "${daemon_dir}" -name dev_incus -exec "umount" "-l" "{}" \; >/dev/null 2>&1 || true check_leftovers="true" fi - if [ -n "${LXD_LOGS:-}" ]; then + if [ -n "${INCUS_LOGS:-}" ]; then echo "==> Copying the logs" - mkdir -p "${LXD_LOGS}/${daemon_pid}" - cp -R "${daemon_dir}/logs/" "${LXD_LOGS}/${daemon_pid}/" - cp "${daemon_dir}/lxd.log" "${LXD_LOGS}/${daemon_pid}/" + mkdir -p "${INCUS_LOGS}/${daemon_pid}" + cp -R "${daemon_dir}/logs/" "${INCUS_LOGS}/${daemon_pid}/" + cp "${daemon_dir}/incus.log" "${INCUS_LOGS}/${daemon_pid}/" fi if [ "${check_leftovers}" = "true" ]; then @@ -252,7 +252,7 @@ kill_lxd() { fi # teardown storage - "$lxd_backend"_teardown "${daemon_dir}" + "$incus_backend"_teardown "${daemon_dir}" # Wipe the daemon directory wipe "${daemon_dir}" @@ -261,21 +261,21 @@ kill_lxd() { sed "\\|^${daemon_dir}|d" -i "${TEST_DIR}/daemons" } -shutdown_lxd() { - # LXD_DIR is local here because since $(lxc) is actually a function, it - # overwrites the environment and we would lose LXD_DIR's value otherwise. +shutdown_incus() { + # INCUS_DIR is local here because since $(inc) is actually a function, it + # overwrites the environment and we would lose INCUS_DIR's value otherwise. # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR daemon_dir=${1} # shellcheck disable=2034 - LXD_DIR=${daemon_dir} - daemon_pid=$(cat "${daemon_dir}/lxd.pid") - echo "==> Shutting down LXD at ${daemon_dir} (${daemon_pid})" + INCUS_DIR=${daemon_dir} + daemon_pid=$(cat "${daemon_dir}/incus.pid") + echo "==> Shutting down Incus at ${daemon_dir} (${daemon_pid})" # Shutting down the daemon - lxd shutdown || kill -9 "${daemon_pid}" 2>/dev/null || true + incus shutdown || kill -9 "${daemon_pid}" 2>/dev/null || true # Wait for any cleanup activity that might be happening right # after the websocket is closed. @@ -314,24 +314,24 @@ wipe() { rm -Rf "${1}" } -# Kill and cleanup LXD instances and related resources -cleanup_lxds() { +# Kill and cleanup Incus instances and related resources +cleanup_incus() { # shellcheck disable=SC2039,3043 local test_dir daemon_dir test_dir="$1" - # Kill all LXD instances + # Kill all Incus instances while read -r daemon_dir; do - kill_lxd "${daemon_dir}" + kill_incus "${daemon_dir}" done < "${test_dir}/daemons" # Cleanup leftover networks # shellcheck disable=SC2009 - ps aux | grep "interface=lxdt$$ " | grep -v grep | awk '{print $2}' | while read -r line; do + ps aux | grep "interface=inct$$ " | grep -v grep | awk '{print $2}' | while read -r line; do kill -9 "${line}" done - if [ -e "/sys/class/net/lxdt$$" ]; then - ip link del lxdt$$ + if [ -e "/sys/class/net/inct$$" ]; then + ip link del inct$$ fi # Cleanup clustering networking, if any diff --git a/test/includes/lxc.sh b/test/includes/lxc.sh index e3f063b48ec..7f50dd44754 100644 --- a/test/includes/lxc.sh +++ b/test/includes/lxc.sh @@ -1,24 +1,24 @@ -# lxc CLI related test helpers. +# inc CLI related test helpers. -lxc() { - LXC_LOCAL=1 lxc_remote "$@" +inc() { + INC_LOCAL=1 inc_remote "$@" } -lxc_remote() { +inc_remote() { set +x # shellcheck disable=SC2039,3043 local injected cmd arg injected=0 - # find the path to lxc binary, not the shell wrapper function - cmd=$(unset -f lxc; command -v lxc) + # find the path to inc binary, not the shell wrapper function + cmd=$(unset -f inc; command -v inc) # shellcheck disable=SC2048,SC2068 for arg in "$@"; do if [ "${arg}" = "--" ]; then injected=1 cmd="${cmd} ${DEBUG:-}" - [ -n "${LXC_LOCAL}" ] && cmd="${cmd} --force-local" + [ -n "${INC_LOCAL}" ] && cmd="${cmd} --force-local" cmd="${cmd} --" elif [ "${arg}" = "--force-local" ]; then continue @@ -37,17 +37,17 @@ lxc_remote() { } gen_cert() { - # Temporarily move the existing cert to trick LXC into generating a - # second cert. LXC will only generate a cert when adding a remote + # Temporarily move the existing cert to trick inc into generating a + # second cert. inc will only generate a cert when adding a remote # server with a HTTPS scheme. The remote server URL just needs to # be syntactically correct to get past initial checks; in fact, we # don't want it to succeed, that way we don't have to delete it later. - [ -f "${LXD_CONF}/${1}.crt" ] && return - mv "${LXD_CONF}/client.crt" "${LXD_CONF}/client.crt.bak" - mv "${LXD_CONF}/client.key" "${LXD_CONF}/client.key.bak" - echo y | lxc_remote remote add "remote-placeholder-$$" https://0.0.0.0 || true - mv "${LXD_CONF}/client.crt" "${LXD_CONF}/${1}.crt" - mv "${LXD_CONF}/client.key" "${LXD_CONF}/${1}.key" - mv "${LXD_CONF}/client.crt.bak" "${LXD_CONF}/client.crt" - mv "${LXD_CONF}/client.key.bak" "${LXD_CONF}/client.key" + [ -f "${INCUS_CONF}/${1}.crt" ] && return + mv "${INCUS_CONF}/client.crt" "${INCUS_CONF}/client.crt.bak" + mv "${INCUS_CONF}/client.key" "${INCUS_CONF}/client.key.bak" + echo y | inc_remote remote add "remote-placeholder-$$" https://0.0.0.0 || true + mv "${INCUS_CONF}/client.crt" "${INCUS_CONF}/${1}.crt" + mv "${INCUS_CONF}/client.key" "${INCUS_CONF}/${1}.key" + mv "${INCUS_CONF}/client.crt.bak" "${INCUS_CONF}/client.crt" + mv "${INCUS_CONF}/client.key.bak" "${INCUS_CONF}/client.key" } diff --git a/test/includes/net.sh b/test/includes/net.sh index 270daa5a543..7b103cd4b84 100644 --- a/test/includes/net.sh +++ b/test/includes/net.sh @@ -29,7 +29,7 @@ EOF # Certificate-aware curl wrapper my_curl() { - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" "$@" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" "$@" } # Wait for duplicate address detection to complete. @@ -37,7 +37,7 @@ my_curl() { wait_for_dad() { cmd="ip -6 a show dev $1" if [ "$#" -eq 2 ]; then - cmd="lxc exec $1 -- ip -6 a show dev $2" + cmd="inc exec $1 -- ip -6 a show dev $2" fi # Ensure the command succeeds (else the while loop will break for the wrong reason). diff --git a/test/includes/setup.sh b/test/includes/setup.sh index e3430e5b58c..8c78c82d9c9 100644 --- a/test/includes/setup.sh +++ b/test/includes/setup.sh @@ -3,18 +3,18 @@ ensure_has_localhost_remote() { # shellcheck disable=SC2039,3043 local addr="${1}" - if ! lxc remote list | grep -q "localhost"; then - lxc remote add localhost "https://${addr}" --accept-certificate --password foo + if ! inc remote list | grep -q "localhost"; then + inc remote add localhost "https://${addr}" --accept-certificate --password foo fi } ensure_import_testimage() { - if ! lxc image alias list | grep -q "^| testimage\\s*|.*$"; then - if [ -e "${LXD_TEST_IMAGE:-}" ]; then - lxc image import "${LXD_TEST_IMAGE}" --alias testimage + if ! inc image alias list | grep -q "^| testimage\\s*|.*$"; then + if [ -e "${INCUS_TEST_IMAGE:-}" ]; then + inc image import "${INCUS_TEST_IMAGE}" --alias testimage else if [ ! -e "/bin/busybox" ]; then - echo "Please install busybox (busybox-static) or set LXD_TEST_IMAGE" + echo "Please install busybox (busybox-static) or set INCUS_TEST_IMAGE" exit 1 fi @@ -23,7 +23,7 @@ ensure_import_testimage() { exit 1 fi - project="$(lxc project list | awk '/(current)/ {print $2}')" + project="$(inc project list | awk '/(current)/ {print $2}')" deps/import-busybox --alias testimage --project "$project" fi fi diff --git a/test/includes/storage.sh b/test/includes/storage.sh index 5189223c1d5..4e53fbf022e 100644 --- a/test/includes/storage.sh +++ b/test/includes/storage.sh @@ -8,7 +8,7 @@ storage_backend_available() { if [ "${backends#*"$1"}" != "$backends" ]; then true return - elif [ "${1}" = "cephfs" ] && [ "${backends#*"ceph"}" != "$backends" ] && [ -n "${LXD_CEPH_CEPHFS:-}" ]; then + elif [ "${1}" = "cephfs" ] && [ "${backends#*"ceph"}" != "$backends" ] && [ -n "${INCUS_CEPH_CEPHFS:-}" ]; then true return fi @@ -16,15 +16,15 @@ storage_backend_available() { false } -# Choose a random available backend, excluding LXD_BACKEND +# Choose a random available backend, excluding INCUS_BACKEND random_storage_backend() { # shellcheck disable=2046 shuf -e $(available_storage_backends) | head -n 1 } -# Return the storage backend being used by a LXD instance +# Return the storage backend being used by an incus instance storage_backend() { - cat "$1/lxd.backend" + cat "$1/incus.backend" } # Return a list of available storage backends @@ -35,7 +35,7 @@ available_storage_backends() { backends="dir" # always available storage_backends="btrfs lvm zfs" - if [ -n "${LXD_CEPH_CLUSTER:-}" ]; then + if [ -n "${INCUS_CEPH_CLUSTER:-}" ]; then storage_backends="${storage_backends} ceph" fi diff --git a/test/lint/client-imports.sh b/test/lint/client-imports.sh index 70b4f4b60b0..0ef58740db5 100755 --- a/test/lint/client-imports.sh +++ b/test/lint/client-imports.sh @@ -2,7 +2,7 @@ echo "Checking for imports that have been added to client or shared..." -OUT=$(go list -f '{{ join .Imports "\n" }}' ./client ./shared/api ./lxc/config | grep -F . | sort -u | diff -u test/godeps.list - || true) +OUT=$(go list -f '{{ join .Imports "\n" }}' ./client ./shared/api ./inc/config | grep -F . | sort -u | diff -u test/godeps.list - || true) if [ -n "${OUT}" ]; then echo "ERROR: you added a new dependency to the client or shared; please make sure this is what you want" echo "${OUT}" diff --git a/test/lint/i18n-up-to-date.sh b/test/lint/i18n-up-to-date.sh index 4af412c953d..1e10c5ae06d 100755 --- a/test/lint/i18n-up-to-date.sh +++ b/test/lint/i18n-up-to-date.sh @@ -1,17 +1,17 @@ #!/bin/sh -eu safe_pot_hash() { - sed -e "/Project-Id-Version/,/Content-Transfer-Encoding/d" -e "/^#/d" "po/lxd.pot" | md5sum | cut -f1 -d" " + sed -e "/Project-Id-Version/,/Content-Transfer-Encoding/d" -e "/^#/d" "po/inc.pot" | md5sum | cut -f1 -d" " } echo "Checking that the .pot files are up to date..." # make sure the .pot is updated hash1=$(safe_pot_hash) -mv "po/lxd.pot" "po/lxd.pot.bak" +mv "po/inc.pot" "po/inc.pot.bak" make i18n -s hash2=$(safe_pot_hash) -mv "po/lxd.pot.bak" "po/lxd.pot" +mv "po/inc.pot.bak" "po/inc.pot" git checkout -- po/*.po if [ "${hash1}" != "${hash2}" ]; then echo "==> Please update the .pot file in your commit (make i18n)" diff --git a/test/main.sh b/test/main.sh index 457bcbfd355..72e3447797d 100755 --- a/test/main.sh +++ b/test/main.sh @@ -1,18 +1,18 @@ #!/bin/sh -eu [ -n "${GOPATH:-}" ] && export "PATH=${GOPATH}/bin:${PATH}" -# Don't translate lxc output for parsing in it in tests. +# Don't translate inc output for parsing in it in tests. export LC_ALL="C" # Force UTC for consistency export TZ="UTC" export DEBUG="" -if [ -n "${LXD_VERBOSE:-}" ]; then +if [ -n "${INCUS_VERBOSE:-}" ]; then DEBUG="--verbose" fi -if [ -n "${LXD_DEBUG:-}" ]; then +if [ -n "${INCUS_DEBUG:-}" ]; then DEBUG="--debug" fi @@ -20,12 +20,12 @@ if [ -n "${DEBUG:-}" ]; then set -x fi -if [ -z "${LXD_BACKEND:-}" ]; then - LXD_BACKEND="dir" +if [ -z "${INCUS_BACKEND:-}" ]; then + INCUS_BACKEND="dir" fi # shellcheck disable=SC2034 -LXD_NETNS="" +INCUS_NETNS="" import_subdir_files() { test "$1" @@ -40,28 +40,28 @@ import_subdir_files() { import_subdir_files includes echo "==> Checking for dependencies" -check_dependencies lxd lxc curl dnsmasq jq git xgettext sqlite3 msgmerge msgfmt shuf setfacl socat dig +check_dependencies incus inc curl dnsmasq jq git xgettext sqlite3 msgmerge msgfmt shuf setfacl socat dig if [ "${USER:-'root'}" != "root" ]; then echo "The testsuite must be run as root." >&2 exit 1 fi -if [ -n "${LXD_LOGS:-}" ] && [ ! -d "${LXD_LOGS}" ]; then - echo "Your LXD_LOGS path doesn't exist: ${LXD_LOGS}" +if [ -n "${INCUS_LOGS:-}" ] && [ ! -d "${INCUS_LOGS}" ]; then + echo "Your INCUS_LOGS path doesn't exist: ${INCUS_LOGS}" exit 1 fi echo "==> Available storage backends: $(available_storage_backends | sort)" -if [ "$LXD_BACKEND" != "random" ] && ! storage_backend_available "$LXD_BACKEND"; then - if [ "${LXD_BACKEND}" = "ceph" ] && [ -z "${LXD_CEPH_CLUSTER:-}" ]; then - echo "Ceph storage backend requires that \"LXD_CEPH_CLUSTER\" be set." +if [ "$INCUS_BACKEND" != "random" ] && ! storage_backend_available "$INCUS_BACKEND"; then + if [ "${INCUS_BACKEND}" = "ceph" ] && [ -z "${INCUS_CEPH_CLUSTER:-}" ]; then + echo "Ceph storage backend requires that \"INCUS_CEPH_CLUSTER\" be set." exit 1 fi - echo "Storage backend \"$LXD_BACKEND\" is not available" + echo "Storage backend \"$INCUS_BACKEND\" is not available" exit 1 fi -echo "==> Using storage backend ${LXD_BACKEND}" +echo "==> Using storage backend ${INCUS_BACKEND}" import_storage_backends @@ -71,14 +71,14 @@ cleanup() { DEBUG= # Allow for inspection - if [ -n "${LXD_INSPECT:-}" ]; then + if [ -n "${INCUS_INSPECT:-}" ]; then if [ "${TEST_RESULT}" != "success" ]; then echo "==> TEST DONE: ${TEST_CURRENT_DESCRIPTION}" fi echo "==> Test result: ${TEST_RESULT}" # shellcheck disable=SC2086 - printf "To poke around, use:\\n LXD_DIR=%s LXD_CONF=%s sudo -E %s/bin/lxc COMMAND\\n" "${LXD_DIR}" "${LXD_CONF}" ${GOPATH:-} + printf "To poke around, use:\\n INCUS_DIR=%s INCUS_CONF=%s sudo -E %s/bin/inc COMMAND\\n" "${INCUS_DIR}" "${INCUS_CONF}" ${GOPATH:-} echo "Tests Completed (${TEST_RESULT}): hit enter to continue" read -r _ fi @@ -90,7 +90,7 @@ cleanup() { umount -l "${TEST_DIR}/dev" kill_external_auth_daemon "$TEST_DIR" - cleanup_lxds "$TEST_DIR" + cleanup_incus "$TEST_DIR" fi echo "" @@ -116,25 +116,25 @@ import_subdir_files suites TEST_DIR=$(mktemp -d -p "$(pwd)" tmp.XXX) chmod +x "${TEST_DIR}" -if [ -n "${LXD_TMPFS:-}" ]; then +if [ -n "${INCUS_TMPFS:-}" ]; then mount -t tmpfs tmpfs "${TEST_DIR}" -o mode=0751 -o size=6G fi mkdir -p "${TEST_DIR}/dev" mount -t tmpfs none "${TEST_DIR}"/dev -export LXD_DEVMONITOR_DIR="${TEST_DIR}/dev" +export INCUS_DEVMONITOR_DIR="${TEST_DIR}/dev" -LXD_CONF=$(mktemp -d -p "${TEST_DIR}" XXX) -export LXD_CONF +INCUS_CONF=$(mktemp -d -p "${TEST_DIR}" XXX) +export INCUS_CONF -LXD_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) -export LXD_DIR -chmod +x "${LXD_DIR}" -spawn_lxd "${LXD_DIR}" true -LXD_ADDR=$(cat "${LXD_DIR}/lxd.addr") -export LXD_ADDR +INCUS_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) +export INCUS_DIR +chmod +x "${INCUS_DIR}" +spawn_incus "${INCUS_DIR}" true +INCUS_ADDR=$(cat "${INCUS_DIR}/incus.addr") +export INCUS_ADDR -start_external_auth_daemon "${LXD_DIR}" +start_external_auth_daemon "${INCUS_DIR}" run_test() { TEST_CURRENT=${1} @@ -148,10 +148,10 @@ run_test() { local skip=false # Skip test if requested. - if [ -n "${LXD_SKIP_TESTS:-}" ]; then - for testName in ${LXD_SKIP_TESTS}; do + if [ -n "${INCUS_SKIP_TESTS:-}" ]; then + for testName in ${INCUS_SKIP_TESTS}; do if [ "test_${testName}" = "${TEST_CURRENT}" ]; then - echo "==> SKIP: ${TEST_CURRENT} as specified in LXD_SKIP_TESTS" + echo "==> SKIP: ${TEST_CURRENT} as specified in INCUS_SKIP_TESTS" skip=true break fi @@ -164,8 +164,8 @@ run_test() { # Check whether test was skipped due to unmet requirements, and if so check if the test is required and fail. if [ -n "${TEST_UNMET_REQUIREMENT}" ]; then - if [ -n "${LXD_REQUIRED_TESTS:-}" ]; then - for testName in ${LXD_REQUIRED_TESTS}; do + if [ -n "${INCUS_REQUIRED_TESTS:-}" ]; then + for testName in ${INCUS_REQUIRED_TESTS}; do if [ "test_${testName}" = "${TEST_CURRENT}" ]; then echo "==> REQUIRED: ${TEST_CURRENT} ${TEST_UNMET_REQUIREMENT}" false @@ -196,7 +196,7 @@ if [ "${1:-"all"}" != "cluster" ]; then run_test test_check_deps "checking dependencies" run_test test_database_restore "database restore" run_test test_database_no_disk_space "database out of disk space" - run_test test_sql "lxd sql" + run_test test_sql "SQL" run_test test_tls_restrictions "TLS restrictions" run_test test_certificate_edit "Certificate edit" run_test test_basic_usage "basic usage" @@ -308,16 +308,16 @@ if [ "${1:-"all"}" != "cluster" ]; then run_test test_idmap "id mapping" run_test test_template "file templating" run_test test_pki "PKI mode" - run_test test_devlxd "/dev/lxd" + run_test test_dev_incus "/dev/incus" run_test test_fuidshift "fuidshift" run_test test_migration "migration" - run_test test_lxc_to_lxd "LXC to LXD" + run_test test_lxc_to_incus "LXC to Incus" run_test test_fdleak "fd leak" run_test test_storage "storage" run_test test_storage_volume_snapshots "storage volume snapshots" - run_test test_init_auto "lxd init auto" - run_test test_init_interactive "lxd init interactive" - run_test test_init_preseed "lxd init preseed" + run_test test_init_auto "incus init auto" + run_test test_init_interactive "incus init interactive" + run_test test_init_preseed "incus init preseed" run_test test_storage_profiles "storage profiles" run_test test_container_recover "container recover" run_test test_bucket_recover "bucket recover" @@ -340,7 +340,7 @@ if [ "${1:-"all"}" != "cluster" ]; then run_test test_backup_volume_export "backup volume export" run_test test_backup_volume_rename_delete "backup volume rename and delete" run_test test_backup_different_instance_uuid "backup instance and check instance UUIDs" - run_test "test_backup_volume_expiry" "backup volume expiry" + run_test test_backup_volume_expiry "backup volume expiry" run_test test_container_local_cross_pool_handling "container local cross pool handling" run_test test_incremental_copy "incremental container copy" run_test test_profiles_project_default "profiles in default project" diff --git a/test/perf.sh b/test/perf.sh index 2aaa4764a92..d50dc0d231a 100755 --- a/test/perf.sh +++ b/test/perf.sh @@ -8,7 +8,7 @@ PERF_LOG_CSV="perf.csv" # shellcheck disable=SC2034 -LXD_NETNS="" +INCUS_NETNS="" import_subdir_files() { test "$1" @@ -34,7 +34,7 @@ run_benchmark() { shift 2 log_message "Benchmark start: $label - $description" - lxd-benchmark "$@" --report-file "$PERF_LOG_CSV" --report-label "$label" + incus-benchmark "$@" --report-file "$PERF_LOG_CSV" --report-label "$label" log_message "Benchmark completed: $label" } @@ -42,9 +42,9 @@ cleanup() { if [ "$TEST_RESULT" != "success" ]; then rm -f "$PERF_LOG_CSV" fi - lxd-benchmark delete # ensure all test containers have been deleted - kill_lxd "$LXD_DIR" - cleanup_lxds "$TEST_DIR" + incus-benchmark delete # ensure all test containers have been deleted + kill_incus "$INCUS_DIR" + cleanup_incus "$TEST_DIR" log_message "Performance tests result: $TEST_RESULT" } @@ -53,31 +53,31 @@ trap cleanup EXIT HUP INT TERM # Setup test directories TEST_DIR=$(mktemp -d -p "$(pwd)" tmp.XXX) -if [ -n "${LXD_TMPFS:-}" ]; then +if [ -n "${INCUS_TMPFS:-}" ]; then mount -t tmpfs tmpfs "${TEST_DIR}" -o mode=0751 -o size=6G fi -LXD_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) -export LXD_DIR -chmod +x "${TEST_DIR}" "${LXD_DIR}" +INCUS_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) +export INCUS_DIR +chmod +x "${TEST_DIR}" "${INCUS_DIR}" -if [ -z "${LXD_BACKEND:-}" ]; then - LXD_BACKEND="dir" +if [ -z "${INCUS_BACKEND:-}" ]; then + INCUS_BACKEND="dir" fi import_storage_backends -spawn_lxd "${LXD_DIR}" true +spawn_incus "${INCUS_DIR}" true ensure_import_testimage # shellcheck disable=SC2034 TEST_RESULT=failure -run_benchmark "create-one" "create 1 container" init --count 1 "${LXD_TEST_IMAGE:-"testimage"}" +run_benchmark "create-one" "create 1 container" init --count 1 "${INCUS_TEST_IMAGE:-"testimage"}" run_benchmark "start-one" "start 1 container" start run_benchmark "stop-one" "stop 1 container" stop run_benchmark "delete-one" "delete 1 container" delete -run_benchmark "create-128" "create 128 containers" init --count 128 "${LXD_TEST_IMAGE:-"testimage"}" +run_benchmark "create-128" "create 128 containers" init --count 128 "${INCUS_TEST_IMAGE:-"testimage"}" run_benchmark "start-128" "start 128 containers" start run_benchmark "delete-128" "delete 128 containers" delete diff --git a/test/suites/backup.sh b/test/suites/backup.sh index 75c2f706d73..f9a84dd3793 100644 --- a/test/suites/backup.sh +++ b/test/suites/backup.sh @@ -1,246 +1,246 @@ test_storage_volume_recover() { - LXD_IMPORT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_IMPORT_DIR}" - spawn_lxd "${LXD_IMPORT_DIR}" true + INCUS_IMPORT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_IMPORT_DIR}" + spawn_incus "${INCUS_IMPORT_DIR}" true - poolName=$(lxc profile device get default root pool) - poolDriver=$(lxc storage show "${poolName}" | awk '/^driver:/ {print $2}') + poolName=$(inc profile device get default root pool) + poolDriver=$(inc storage show "${poolName}" | awk '/^driver:/ {print $2}') # Create custom block volume. - lxc storage volume create "${poolName}" vol1 --type=block + inc storage volume create "${poolName}" vol1 --type=block # Import ISO. truncate -s 25MiB foo.iso - lxc storage volume import "${poolName}" ./foo.iso vol2 --type=iso + inc storage volume import "${poolName}" ./foo.iso vol2 --type=iso # Delete database entry of the created custom block volume. - lxd sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol1'" - lxd sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol2'" + incus sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol1'" + incus sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol2'" # Ensure the custom block volume is no longer listed. - ! lxc storage volume show "${poolName}" vol1 || false - ! lxc storage volume show "${poolName}" vol2 || false + ! inc storage volume show "${poolName}" vol1 || false + ! inc storage volume show "${poolName}" vol2 || false if [ "$poolDriver" = "zfs" ]; then # Create filesystem volume. - lxc storage volume create "${poolName}" vol3 + inc storage volume create "${poolName}" vol3 # Create block_mode enabled volume. - lxc storage volume create "${poolName}" vol4 zfs.block_mode=true size=200MiB + inc storage volume create "${poolName}" vol4 zfs.block_mode=true size=200MiB # Delete database entries of the created custom volumes. - lxd sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol3'" - lxd sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol4'" + incus sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol3'" + incus sql global "PRAGMA foreign_keys=ON; DELETE FROM storage_volumes WHERE name='vol4'" # Ensure the custom volumes are no longer listed. - ! lxc storage volume show "${poolName}" vol3 || false - ! lxc storage volume show "${poolName}" vol4 || false + ! inc storage volume show "${poolName}" vol3 || false + ! inc storage volume show "${poolName}" vol4 || false fi # Recover custom block volume. - cat </dev/null 2>&1; then + echo "==> SKIP: Skip bucket recovery test due to missing minio" + return + fi + ( set -e - poolName=$(lxc profile device get default root pool) - poolDriver=$(lxc storage show "${poolName}" | awk '/^driver:/ {print $2}') + poolName=$(inc profile device get default root pool) + poolDriver=$(inc storage show "${poolName}" | awk '/^driver:/ {print $2}') bucketName="bucket123" # Skip ceph driver - ceph does not support storage buckets @@ -293,37 +298,37 @@ test_bucket_recover() { fi # Create storage bucket - lxc storage bucket create "${poolName}" "${bucketName}" + inc storage bucket create "${poolName}" "${bucketName}" # Create storage bucket keys - key1=$(lxc storage bucket key create "${poolName}" "${bucketName}" key1 --role admin) - key2=$(lxc storage bucket key create "${poolName}" "${bucketName}" key2 --role read-only) + key1=$(inc storage bucket key create "${poolName}" "${bucketName}" key1 --role admin) + key2=$(inc storage bucket key create "${poolName}" "${bucketName}" key2 --role read-only) key1_accessKey=$(echo "$key1" | awk '/^Access key/ { print $3 }') key1_secretKey=$(echo "$key1" | awk '/^Secret key/ { print $3 }') key2_accessKey=$(echo "$key2" | awk '/^Access key/ { print $3 }') key2_secretKey=$(echo "$key2" | awk '/^Secret key/ { print $3 }') # Remove bucket from global DB - lxd sql global "delete from storage_buckets where name = '${bucketName}'" + incus sql global "delete from storage_buckets where name = '${bucketName}'" # Recover bucket - cat <&1 | grep -q "Error: Instance not found" ; then + if ! inc query -X POST /1.0/containers/c1/backups/backupmissing -d '{\"name\": \"backupnewname\"}' --wait 2>&1 | grep -q "Error: Instance not found" ; then echo "invalid rename response for missing container" false fi - lxc init testimage c1 + inc init testimage c1 - if ! lxc query -X POST /1.0/containers/c1/backups/backupmissing -d '{\"name\": \"backupnewname\"}' --wait 2>&1 | grep -q "Error: Load backup from database: Instance backup not found" ; then + if ! inc query -X POST /1.0/containers/c1/backups/backupmissing -d '{\"name\": \"backupnewname\"}' --wait 2>&1 | grep -q "Error: Load backup from database: Instance backup not found" ; then echo "invalid rename response for missing backup" false fi # Create backup - lxc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/instances/c1/backups + inc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/instances/c1/backups # All backups should be listed - lxc query /1.0/instances/c1/backups | jq .'[0]' | grep instances/c1/backups/foo + inc query /1.0/instances/c1/backups | jq .'[0]' | grep instances/c1/backups/foo # The specific backup should exist - lxc query /1.0/instances/c1/backups/foo + inc query /1.0/instances/c1/backups/foo # Rename the container which should rename the backup(s) as well - lxc mv c1 c2 + inc mv c1 c2 # All backups should be listed - lxc query /1.0/instances/c2/backups | jq .'[0]' | grep instances/c2/backups/foo + inc query /1.0/instances/c2/backups | jq .'[0]' | grep instances/c2/backups/foo # The specific backup should exist - lxc query /1.0/instances/c2/backups/foo + inc query /1.0/instances/c2/backups/foo # The old backup should not exist - ! lxc query /1.0/instances/c1/backups/foo || false + ! inc query /1.0/instances/c1/backups/foo || false - lxc delete --force c2 + inc delete --force c2 } test_backup_volume_export() { - test_backup_volume_export_with_project default "lxdtest-$(basename "${LXD_DIR}")" - test_backup_volume_export_with_project fooproject "lxdtest-$(basename "${LXD_DIR}")" + test_backup_volume_export_with_project default "incustest-$(basename "${INCUS_DIR}")" + test_backup_volume_export_with_project fooproject "incustest-$(basename "${INCUS_DIR}")" - if [ "$lxd_backend" = "ceph" ] && [ -n "${LXD_CEPH_CEPHFS:-}" ]; then - custom_vol_pool="lxdtest-$(basename "${LXD_DIR}")-cephfs" - lxc storage create "${custom_vol_pool}" cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")-cephfs" + if [ "$incus_backend" = "ceph" ] && [ -n "${INCUS_CEPH_CEPHFS:-}" ]; then + custom_vol_pool="incustest-$(basename "${INCUS_DIR}")-cephfs" + inc storage create "${custom_vol_pool}" cephfs source="${INCUS_CEPH_CEPHFS}/$(basename "${INCUS_DIR}")-cephfs" test_backup_volume_export_with_project default "${custom_vol_pool}" test_backup_volume_export_with_project fooproject "${custom_vol_pool}" - lxc storage rm "${custom_vol_pool}" + inc storage rm "${custom_vol_pool}" fi } test_backup_volume_export_with_project() { - pool="lxdtest-$(basename "${LXD_DIR}")" + pool="incustest-$(basename "${INCUS_DIR}")" project="$1" custom_vol_pool="$2" if [ "${project}" != "default" ]; then # Create a project. - lxc project create "$project" - lxc project create "$project-b" - lxc project switch "$project" + inc project create "$project" + inc project create "$project-b" + inc project switch "$project" deps/import-busybox --project "$project" --alias testimage deps/import-busybox --project "$project-b" --alias testimage # Add a root device to the default profile of the project. - lxc profile device add default root disk path="/" pool="${pool}" + inc profile device add default root disk path="/" pool="${pool}" fi ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - mkdir "${LXD_DIR}/optimized" "${LXD_DIR}/non-optimized" - lxd_backend=$(storage_backend "$LXD_DIR") + mkdir "${INCUS_DIR}/optimized" "${INCUS_DIR}/non-optimized" + incus_backend=$(storage_backend "$INCUS_DIR") # Create test container. - lxc init testimage c1 + inc init testimage c1 # Create custom storage volume. - lxc storage volume create "${custom_vol_pool}" testvol + inc storage volume create "${custom_vol_pool}" testvol # Attach storage volume to the test container and start. - lxc storage volume attach "${custom_vol_pool}" testvol c1 /mnt - lxc start c1 + inc storage volume attach "${custom_vol_pool}" testvol c1 /mnt + inc start c1 # Create file on the custom volume. - echo foo | lxc file push - c1/mnt/test + echo foo | inc file push - c1/mnt/test # Snapshot the custom volume. - lxc storage volume set "${custom_vol_pool}" testvol user.foo=test-snap0 - lxc storage volume snapshot "${custom_vol_pool}" testvol test-snap0 + inc storage volume set "${custom_vol_pool}" testvol user.foo=test-snap0 + inc storage volume snapshot "${custom_vol_pool}" testvol test-snap0 # Change the content (the snapshot will contain the old value). - echo bar | lxc file push - c1/mnt/test + echo bar | inc file push - c1/mnt/test - lxc storage volume set "${custom_vol_pool}" testvol user.foo=test-snap1 - lxc storage volume snapshot "${custom_vol_pool}" testvol test-snap1 - lxc storage volume set "${custom_vol_pool}" testvol user.foo=post-test-snap1 + inc storage volume set "${custom_vol_pool}" testvol user.foo=test-snap1 + inc storage volume snapshot "${custom_vol_pool}" testvol test-snap1 + inc storage volume set "${custom_vol_pool}" testvol user.foo=post-test-snap1 - if [ "$lxd_backend" = "btrfs" ] || [ "$lxd_backend" = "zfs" ]; then + if [ "$incus_backend" = "btrfs" ] || [ "$incus_backend" = "zfs" ]; then # Create optimized backup without snapshots. - lxc storage volume export "${custom_vol_pool}" testvol "${LXD_DIR}/testvol-optimized.tar.gz" --volume-only --optimized-storage + inc storage volume export "${custom_vol_pool}" testvol "${INCUS_DIR}/testvol-optimized.tar.gz" --volume-only --optimized-storage - [ -f "${LXD_DIR}/testvol-optimized.tar.gz" ] + [ -f "${INCUS_DIR}/testvol-optimized.tar.gz" ] # Extract backup tarball. - tar -xzf "${LXD_DIR}/testvol-optimized.tar.gz" -C "${LXD_DIR}/optimized" + tar -xzf "${INCUS_DIR}/testvol-optimized.tar.gz" -C "${INCUS_DIR}/optimized" - [ -f "${LXD_DIR}/optimized/backup/index.yaml" ] - [ -f "${LXD_DIR}/optimized/backup/volume.bin" ] - [ ! -d "${LXD_DIR}/optimized/backup/volume-snapshots" ] + [ -f "${INCUS_DIR}/optimized/backup/index.yaml" ] + [ -f "${INCUS_DIR}/optimized/backup/volume.bin" ] + [ ! -d "${INCUS_DIR}/optimized/backup/volume-snapshots" ] fi # Create non-optimized backup without snapshots. - lxc storage volume export "${custom_vol_pool}" testvol "${LXD_DIR}/testvol.tar.gz" --volume-only + inc storage volume export "${custom_vol_pool}" testvol "${INCUS_DIR}/testvol.tar.gz" --volume-only - [ -f "${LXD_DIR}/testvol.tar.gz" ] + [ -f "${INCUS_DIR}/testvol.tar.gz" ] # Extract non-optimized backup tarball. - tar -xzf "${LXD_DIR}/testvol.tar.gz" -C "${LXD_DIR}/non-optimized" + tar -xzf "${INCUS_DIR}/testvol.tar.gz" -C "${INCUS_DIR}/non-optimized" # Check tarball content. - [ -f "${LXD_DIR}/non-optimized/backup/index.yaml" ] - [ -d "${LXD_DIR}/non-optimized/backup/volume" ] - [ "$(cat "${LXD_DIR}/non-optimized/backup/volume/test")" = "bar" ] - [ ! -d "${LXD_DIR}/non-optimized/backup/volume-snapshots" ] + [ -f "${INCUS_DIR}/non-optimized/backup/index.yaml" ] + [ -d "${INCUS_DIR}/non-optimized/backup/volume" ] + [ "$(cat "${INCUS_DIR}/non-optimized/backup/volume/test")" = "bar" ] + [ ! -d "${INCUS_DIR}/non-optimized/backup/volume-snapshots" ] - ! grep -q -- '- test-snap0' "${LXD_DIR}/non-optimized/backup/index.yaml" || false + ! grep -q -- '- test-snap0' "${INCUS_DIR}/non-optimized/backup/index.yaml" || false - rm -rf "${LXD_DIR}/non-optimized/"* - rm "${LXD_DIR}/testvol.tar.gz" + rm -rf "${INCUS_DIR}/non-optimized/"* + rm "${INCUS_DIR}/testvol.tar.gz" - if [ "$lxd_backend" = "btrfs" ] || [ "$lxd_backend" = "zfs" ]; then + if [ "$incus_backend" = "btrfs" ] || [ "$incus_backend" = "zfs" ]; then # Create optimized backup with snapshots. - lxc storage volume export "${custom_vol_pool}" testvol "${LXD_DIR}/testvol-optimized.tar.gz" --optimized-storage + inc storage volume export "${custom_vol_pool}" testvol "${INCUS_DIR}/testvol-optimized.tar.gz" --optimized-storage - [ -f "${LXD_DIR}/testvol-optimized.tar.gz" ] + [ -f "${INCUS_DIR}/testvol-optimized.tar.gz" ] # Extract backup tarball. - tar -xzf "${LXD_DIR}/testvol-optimized.tar.gz" -C "${LXD_DIR}/optimized" + tar -xzf "${INCUS_DIR}/testvol-optimized.tar.gz" -C "${INCUS_DIR}/optimized" - [ -f "${LXD_DIR}/optimized/backup/index.yaml" ] - [ -f "${LXD_DIR}/optimized/backup/volume.bin" ] - [ -f "${LXD_DIR}/optimized/backup/volume-snapshots/test-snap0.bin" ] + [ -f "${INCUS_DIR}/optimized/backup/index.yaml" ] + [ -f "${INCUS_DIR}/optimized/backup/volume.bin" ] + [ -f "${INCUS_DIR}/optimized/backup/volume-snapshots/test-snap0.bin" ] fi # Create non-optimized backup with snapshots. - lxc storage volume export "${custom_vol_pool}" testvol "${LXD_DIR}/testvol.tar.gz" + inc storage volume export "${custom_vol_pool}" testvol "${INCUS_DIR}/testvol.tar.gz" - [ -f "${LXD_DIR}/testvol.tar.gz" ] + [ -f "${INCUS_DIR}/testvol.tar.gz" ] # Extract backup tarball. - tar -xzf "${LXD_DIR}/testvol.tar.gz" -C "${LXD_DIR}/non-optimized" + tar -xzf "${INCUS_DIR}/testvol.tar.gz" -C "${INCUS_DIR}/non-optimized" # Check tarball content. - [ -f "${LXD_DIR}/non-optimized/backup/index.yaml" ] - [ -d "${LXD_DIR}/non-optimized/backup/volume" ] - [ "$(cat "${LXD_DIR}/non-optimized/backup/volume/test")" = "bar" ] - [ -d "${LXD_DIR}/non-optimized/backup/volume-snapshots/test-snap0" ] - [ "$(cat "${LXD_DIR}/non-optimized/backup/volume-snapshots/test-snap0/test")" = "foo" ] + [ -f "${INCUS_DIR}/non-optimized/backup/index.yaml" ] + [ -d "${INCUS_DIR}/non-optimized/backup/volume" ] + [ "$(cat "${INCUS_DIR}/non-optimized/backup/volume/test")" = "bar" ] + [ -d "${INCUS_DIR}/non-optimized/backup/volume-snapshots/test-snap0" ] + [ "$(cat "${INCUS_DIR}/non-optimized/backup/volume-snapshots/test-snap0/test")" = "foo" ] - grep -q -- '- test-snap0' "${LXD_DIR}/non-optimized/backup/index.yaml" + grep -q -- '- test-snap0' "${INCUS_DIR}/non-optimized/backup/index.yaml" - rm -rf "${LXD_DIR}/non-optimized/"* + rm -rf "${INCUS_DIR}/non-optimized/"* # Test non-optimized import. - lxc stop -f c1 - lxc storage volume detach "${custom_vol_pool}" testvol c1 - lxc storage volume delete "${custom_vol_pool}" testvol - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol.tar.gz" - lxc storage volume ls "${custom_vol_pool}" - lxc storage volume get "${custom_vol_pool}" testvol user.foo | grep -Fx "post-test-snap1" - lxc storage volume show "${custom_vol_pool}" testvol/test-snap0 - lxc storage volume get "${custom_vol_pool}" testvol/test-snap0 user.foo | grep -Fx "test-snap0" - lxc storage volume get "${custom_vol_pool}" testvol/test-snap1 user.foo | grep -Fx "test-snap1" - - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol.tar.gz" testvol2 - lxc storage volume attach "${custom_vol_pool}" testvol c1 /mnt - lxc storage volume attach "${custom_vol_pool}" testvol2 c1 /mnt2 - lxc start c1 - lxc exec c1 --project "$project" -- stat /mnt/test - lxc exec c1 --project "$project" -- stat /mnt2/test - lxc stop -f c1 + inc stop -f c1 + inc storage volume detach "${custom_vol_pool}" testvol c1 + inc storage volume delete "${custom_vol_pool}" testvol + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol.tar.gz" + inc storage volume ls "${custom_vol_pool}" + inc storage volume get "${custom_vol_pool}" testvol user.foo | grep -Fx "post-test-snap1" + inc storage volume show "${custom_vol_pool}" testvol/test-snap0 + inc storage volume get "${custom_vol_pool}" testvol/test-snap0 user.foo | grep -Fx "test-snap0" + inc storage volume get "${custom_vol_pool}" testvol/test-snap1 user.foo | grep -Fx "test-snap1" + + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol.tar.gz" testvol2 + inc storage volume attach "${custom_vol_pool}" testvol c1 /mnt + inc storage volume attach "${custom_vol_pool}" testvol2 c1 /mnt2 + inc start c1 + inc exec c1 --project "$project" -- stat /mnt/test + inc exec c1 --project "$project" -- stat /mnt2/test + inc stop -f c1 if [ "${project}" != "default" ]; then # Import into different project (before deleting earlier import). - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol.tar.gz" --project "$project-b" - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol.tar.gz" --project "$project-b" testvol2 - lxc storage volume delete "${custom_vol_pool}" testvol --project "$project-b" - lxc storage volume delete "${custom_vol_pool}" testvol2 --project "$project-b" + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol.tar.gz" --project "$project-b" + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol.tar.gz" --project "$project-b" testvol2 + inc storage volume delete "${custom_vol_pool}" testvol --project "$project-b" + inc storage volume delete "${custom_vol_pool}" testvol2 --project "$project-b" fi # Test optimized import. - if [ "$lxd_backend" = "btrfs" ] || [ "$lxd_backend" = "zfs" ]; then - lxc storage volume detach "${custom_vol_pool}" testvol c1 - lxc storage volume detach "${custom_vol_pool}" testvol2 c1 - lxc storage volume delete "${custom_vol_pool}" testvol - lxc storage volume delete "${custom_vol_pool}" testvol2 - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol-optimized.tar.gz" - lxc storage volume ls "${custom_vol_pool}" - lxc storage volume get "${custom_vol_pool}" testvol user.foo | grep -Fx "post-test-snap1" - lxc storage volume get "${custom_vol_pool}" testvol/test-snap0 user.foo | grep -Fx "test-snap0" - lxc storage volume get "${custom_vol_pool}" testvol/test-snap1 user.foo | grep -Fx "test-snap1" - - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol-optimized.tar.gz" testvol2 - lxc storage volume attach "${custom_vol_pool}" testvol c1 /mnt - lxc storage volume attach "${custom_vol_pool}" testvol2 c1 /mnt2 - lxc start c1 - lxc exec c1 --project "$project" -- stat /mnt/test - lxc exec c1 --project "$project" -- stat /mnt2/test - lxc stop -f c1 + if [ "$incus_backend" = "btrfs" ] || [ "$incus_backend" = "zfs" ]; then + inc storage volume detach "${custom_vol_pool}" testvol c1 + inc storage volume detach "${custom_vol_pool}" testvol2 c1 + inc storage volume delete "${custom_vol_pool}" testvol + inc storage volume delete "${custom_vol_pool}" testvol2 + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol-optimized.tar.gz" + inc storage volume ls "${custom_vol_pool}" + inc storage volume get "${custom_vol_pool}" testvol user.foo | grep -Fx "post-test-snap1" + inc storage volume get "${custom_vol_pool}" testvol/test-snap0 user.foo | grep -Fx "test-snap0" + inc storage volume get "${custom_vol_pool}" testvol/test-snap1 user.foo | grep -Fx "test-snap1" + + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol-optimized.tar.gz" testvol2 + inc storage volume attach "${custom_vol_pool}" testvol c1 /mnt + inc storage volume attach "${custom_vol_pool}" testvol2 c1 /mnt2 + inc start c1 + inc exec c1 --project "$project" -- stat /mnt/test + inc exec c1 --project "$project" -- stat /mnt2/test + inc stop -f c1 if [ "${project}" != "default" ]; then # Import into different project (before deleting earlier import). - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol-optimized.tar.gz" --project "$project-b" - lxc storage volume import "${custom_vol_pool}" "${LXD_DIR}/testvol-optimized.tar.gz" --project "$project-b" testvol2 - lxc storage volume delete "${custom_vol_pool}" testvol --project "$project-b" - lxc storage volume delete "${custom_vol_pool}" testvol2 --project "$project-b" + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol-optimized.tar.gz" --project "$project-b" + inc storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol-optimized.tar.gz" --project "$project-b" testvol2 + inc storage volume delete "${custom_vol_pool}" testvol --project "$project-b" + inc storage volume delete "${custom_vol_pool}" testvol2 --project "$project-b" fi fi # Clean up. - rm -rf "${LXD_DIR}/non-optimized/"* "${LXD_DIR}/optimized/"* - lxc storage volume detach "${custom_vol_pool}" testvol c1 - lxc storage volume detach "${custom_vol_pool}" testvol2 c1 - lxc storage volume rm "${custom_vol_pool}" testvol - lxc storage volume rm "${custom_vol_pool}" testvol2 - lxc rm -f c1 - rmdir "${LXD_DIR}/optimized" - rmdir "${LXD_DIR}/non-optimized" + rm -rf "${INCUS_DIR}/non-optimized/"* "${INCUS_DIR}/optimized/"* + inc storage volume detach "${custom_vol_pool}" testvol c1 + inc storage volume detach "${custom_vol_pool}" testvol2 c1 + inc storage volume rm "${custom_vol_pool}" testvol + inc storage volume rm "${custom_vol_pool}" testvol2 + inc rm -f c1 + rmdir "${INCUS_DIR}/optimized" + rmdir "${INCUS_DIR}/non-optimized" if [ "${project}" != "default" ]; then - lxc project switch default - lxc image rm testimage --project "$project" - lxc image rm testimage --project "$project-b" - lxc project delete "$project" - lxc project delete "$project-b" + inc project switch default + inc image rm testimage --project "$project" + inc image rm testimage --project "$project-b" + inc project delete "$project" + inc project delete "$project-b" fi } test_backup_volume_rename_delete() { - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - pool="lxdtest-$(basename "${LXD_DIR}")" + pool="incustest-$(basename "${INCUS_DIR}")" # Create test volume. - lxc storage volume create "${pool}" vol1 + inc storage volume create "${pool}" vol1 - if ! lxc query -X POST /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/backupmissing -d '{\"name\": \"backupnewname\"}' --wait 2>&1 | grep -q "Error: Storage volume backup not found" ; then + if ! inc query -X POST /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/backupmissing -d '{\"name\": \"backupnewname\"}' --wait 2>&1 | grep -q "Error: Storage volume backup not found" ; then echo "invalid rename response for missing storage volume" false fi # Create backup. - lxc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups + inc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups # All backups should be listed. - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol1/backups/foo + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol1/backups/foo # The specific backup should exist. - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo - stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol1/foo + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo + stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol1/foo # Delete backup and check it is removed from DB and disk. - lxc query -X DELETE --wait /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo - ! lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo || false - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol1/foo || false - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol1 || false + inc query -X DELETE --wait /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo + ! inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo || false + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol1/foo || false + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol1 || false # Create backup again to test rename. - lxc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups + inc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups # Rename the container which should rename the backup(s) as well. - lxc storage volume rename "${pool}" vol1 vol2 + inc storage volume rename "${pool}" vol1 vol2 # All backups should be listed. - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol2/backups/foo + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol2/backups/foo # The specific backup should exist. - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups/foo - stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol2/foo + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups/foo + stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol2/foo # The old backup should not exist. - ! lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo || false - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol1/foo || false - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol1 || false + ! inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol1/backups/foo || false + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol1/foo || false + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol1 || false # Rename backup itself and check its renamed in DB and on disk. - lxc query -X POST --wait -d '{\"name\":\"foo2\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups/foo - lxc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol2/backups/foo2 - stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol2/foo2 - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol2/foo || false + inc query -X POST --wait -d '{\"name\":\"foo2\"}' /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups/foo + inc query /1.0/storage-pools/"${pool}"/volumes/custom/vol2/backups | jq .'[0]' | grep storage-pools/"${pool}"/volumes/custom/vol2/backups/foo2 + stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol2/foo2 + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol2/foo || false # Remove volume and check the backups are removed too. - lxc storage volume rm "${pool}" vol2 - ! stat "${LXD_DIR}"/backups/custom/"${pool}"/default_vol2 || false + inc storage volume rm "${pool}" vol2 + ! stat "${INCUS_DIR}"/backups/custom/"${pool}"/default_vol2 || false } test_backup_different_instance_uuid() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" echo "==> Checking instances UUID during backup operation" - lxc launch testimage c1 - initialUUID=$(lxc config get c1 volatile.uuid) - initialGenerationID=$(lxc config get c1 volatile.uuid.generation) + inc launch testimage c1 + initialUUID=$(inc config get c1 volatile.uuid) + initialGenerationID=$(inc config get c1 volatile.uuid.generation) # export and import to trigger new UUID generation - lxc export c1 "${LXD_DIR}/c1.tar.gz" - lxc delete -f c1 - lxc import "${LXD_DIR}/c1.tar.gz" + inc export c1 "${INCUS_DIR}/c1.tar.gz" + inc delete -f c1 + inc import "${INCUS_DIR}/c1.tar.gz" - newUUID=$(lxc config get c1 volatile.uuid) - newGenerationID=$(lxc config get c1 volatile.uuid.generation) + newUUID=$(inc config get c1 volatile.uuid) + newGenerationID=$(inc config get c1 volatile.uuid.generation) if [ "${initialGenerationID}" != "${newGenerationID}" ] || [ "${initialUUID}" != "${newUUID}" ]; then echo "==> UUID of the instance should remain the same after importing the backup file" false fi - lxc delete -f c1 + inc delete -f c1 } test_backup_volume_expiry() { - poolName=$(lxc profile device get default root pool) + poolName=$(inc profile device get default root pool) # Create custom volume. - lxc storage volume create "${poolName}" vol1 + inc storage volume create "${poolName}" vol1 # Create storage volume backups using the API directly. # The first one is created with an expiry date, the second one never expires. - lxc query -X POST -d '{\"expires_at\":\"2023-07-17T00:00:00Z\"}' /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups - lxc query -X POST -d '{}' /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups + inc query -X POST -d '{\"expires_at\":\"2023-07-17T00:00:00Z\"}' /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups + inc query -X POST -d '{}' /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups # Check that both backups are listed. - [ "$(lxc query /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups | jq '.[]' | wc -l)" -eq 2 ] + [ "$(inc query /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups | jq '.[]' | wc -l)" -eq 2 ] - # Restart LXD which will trigger the task which removes expired volume backups. - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true + # Restart Incus which will trigger the task which removes expired volume backups. + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true # Check that there's only one backup remaining. - [ "$(lxc query /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups | jq '.[]' | wc -l)" -eq 1 ] + [ "$(inc query /1.0/storage-pools/"${poolName}"/volumes/custom/vol1/backups | jq '.[]' | wc -l)" -eq 1 ] # Cleanup. - lxc storage volume delete "${poolName}" vol1 + inc storage volume delete "${poolName}" vol1 } diff --git a/test/suites/basic.sh b/test/suites/basic.sh index 48e378ca9d0..22f63ef93f8 100644 --- a/test/suites/basic.sh +++ b/test/suites/basic.sh @@ -1,164 +1,166 @@ test_basic_usage() { # shellcheck disable=2039,3043 - local lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") + local incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + + # shellcheck disable=2153 + ensure_has_localhost_remote "${INCUS_ADDR}" # Test image export - sum="$(lxc image info testimage | awk '/^Fingerprint/ {print $2}')" - lxc image export testimage "${LXD_DIR}/" - [ "${sum}" = "$(sha256sum "${LXD_DIR}/${sum}.tar.xz" | cut -d' ' -f1)" ] + sum="$(inc image info testimage | awk '/^Fingerprint/ {print $2}')" + inc image export testimage "${INCUS_DIR}/" + [ "${sum}" = "$(sha256sum "${INCUS_DIR}/${sum}.tar.xz" | cut -d' ' -f1)" ] # Test an alias with slashes - lxc image show "${sum}" - lxc image alias create a/b/ "${sum}" - lxc image alias delete a/b/ + inc image show "${sum}" + inc image alias create a/b/ "${sum}" + inc image alias delete a/b/ # Test alias list filtering - lxc image alias create foo "${sum}" - lxc image alias create bar "${sum}" - lxc image alias list local: | grep -q foo - lxc image alias list local: | grep -q bar - lxc image alias list local: foo | grep -q -v bar - lxc image alias list local: "${sum}" | grep -q foo - lxc image alias list local: non-existent | grep -q -v non-existent - lxc image alias delete foo - lxc image alias delete bar - - lxc image alias create foo "${sum}" - lxc image alias rename foo bar - lxc image alias list | grep -qv foo # the old name is gone - lxc image alias delete bar + inc image alias create foo "${sum}" + inc image alias create bar "${sum}" + inc image alias list local: | grep -q foo + inc image alias list local: | grep -q bar + inc image alias list local: foo | grep -q -v bar + inc image alias list local: "${sum}" | grep -q foo + inc image alias list local: non-existent | grep -q -v non-existent + inc image alias delete foo + inc image alias delete bar + + inc image alias create foo "${sum}" + inc image alias rename foo bar + inc image alias list | grep -qv foo # the old name is gone + inc image alias delete bar # Test image list output formats (table & json) - lxc image list --format table | grep -q testimage - lxc image list --format json \ + inc image list --format table | grep -q testimage + inc image list --format json \ | jq '.[]|select(.alias[0].name="testimage")' \ | grep -q '"name": "testimage"' # Test image delete - lxc image delete testimage + inc image delete testimage # test GET /1.0, since the client always puts to /1.0/ - my_curl -f -X GET "https://${LXD_ADDR}/1.0" - my_curl -f -X GET "https://${LXD_ADDR}/1.0/containers" + my_curl -f -X GET "https://${INCUS_ADDR}/1.0" + my_curl -f -X GET "https://${INCUS_ADDR}/1.0/containers" # Re-import the image - mv "${LXD_DIR}/${sum}.tar.xz" "${LXD_DIR}/testimage.tar.xz" - lxc image import "${LXD_DIR}/testimage.tar.xz" --alias testimage user.foo=bar --public - lxc image show testimage | grep -qF "user.foo: bar" - lxc image show testimage | grep -qF "public: true" - lxc image delete testimage - lxc image import "${LXD_DIR}/testimage.tar.xz" --alias testimage - rm "${LXD_DIR}/testimage.tar.xz" + mv "${INCUS_DIR}/${sum}.tar.xz" "${INCUS_DIR}/testimage.tar.xz" + inc image import "${INCUS_DIR}/testimage.tar.xz" --alias testimage user.foo=bar --public + inc image show testimage | grep -qF "user.foo: bar" + inc image show testimage | grep -qF "public: true" + inc image delete testimage + inc image import "${INCUS_DIR}/testimage.tar.xz" --alias testimage + rm "${INCUS_DIR}/testimage.tar.xz" # Test filename for image export - lxc image export testimage "${LXD_DIR}/" - [ "${sum}" = "$(sha256sum "${LXD_DIR}/${sum}.tar.xz" | cut -d' ' -f1)" ] - rm "${LXD_DIR}/${sum}.tar.xz" + inc image export testimage "${INCUS_DIR}/" + [ "${sum}" = "$(sha256sum "${INCUS_DIR}/${sum}.tar.xz" | cut -d' ' -f1)" ] + rm "${INCUS_DIR}/${sum}.tar.xz" # Test custom filename for image export - lxc image export testimage "${LXD_DIR}/foo" - [ "${sum}" = "$(sha256sum "${LXD_DIR}/foo.tar.xz" | cut -d' ' -f1)" ] - rm "${LXD_DIR}/foo.tar.xz" + inc image export testimage "${INCUS_DIR}/foo" + [ "${sum}" = "$(sha256sum "${INCUS_DIR}/foo.tar.xz" | cut -d' ' -f1)" ] + rm "${INCUS_DIR}/foo.tar.xz" # Test image export with a split image. deps/import-busybox --split --alias splitimage - sum="$(lxc image info splitimage | awk '/^Fingerprint/ {print $2}')" + sum="$(inc image info splitimage | awk '/^Fingerprint/ {print $2}')" - lxc image export splitimage "${LXD_DIR}" - [ "${sum}" = "$(cat "${LXD_DIR}/meta-${sum}.tar.xz" "${LXD_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ] + inc image export splitimage "${INCUS_DIR}" + [ "${sum}" = "$(cat "${INCUS_DIR}/meta-${sum}.tar.xz" "${INCUS_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ] # Delete the split image and exported files - rm "${LXD_DIR}/${sum}.tar.xz" - rm "${LXD_DIR}/meta-${sum}.tar.xz" - lxc image delete splitimage + rm "${INCUS_DIR}/${sum}.tar.xz" + rm "${INCUS_DIR}/meta-${sum}.tar.xz" + inc image delete splitimage # Redo the split image export test, this time with the --filename flag # to tell import-busybox to set the 'busybox' filename in the upload. # The sum should remain the same as its the same image. deps/import-busybox --split --filename --alias splitimage - lxc image export splitimage "${LXD_DIR}" - [ "${sum}" = "$(cat "${LXD_DIR}/meta-${sum}.tar.xz" "${LXD_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ] + inc image export splitimage "${INCUS_DIR}" + [ "${sum}" = "$(cat "${INCUS_DIR}/meta-${sum}.tar.xz" "${INCUS_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ] # Delete the split image and exported files - rm "${LXD_DIR}/${sum}.tar.xz" - rm "${LXD_DIR}/meta-${sum}.tar.xz" - lxc image delete splitimage + rm "${INCUS_DIR}/${sum}.tar.xz" + rm "${INCUS_DIR}/meta-${sum}.tar.xz" + inc image delete splitimage # Test --no-profiles flag - poolName=$(lxc profile device get default root pool) - ! lxc init testimage foo --no-profiles || false - lxc init testimage foo --no-profiles -s "${poolName}" - lxc delete -f foo + poolName=$(inc profile device get default root pool) + ! inc init testimage foo --no-profiles || false + inc init testimage foo --no-profiles -s "${poolName}" + inc delete -f foo # Test container creation - lxc init testimage foo - lxc list | grep foo | grep STOPPED - lxc list fo | grep foo | grep STOPPED + inc init testimage foo + inc list | grep foo | grep STOPPED + inc list fo | grep foo | grep STOPPED # Test list json format - lxc list --format json | jq '.[]|select(.name="foo")' | grep '"name": "foo"' + inc list --format json | jq '.[]|select(.name="foo")' | grep '"name": "foo"' # Test list with --columns and --fast - ! lxc list --columns=nsp --fast || false + ! inc list --columns=nsp --fast || false # Check volatile.apply_template is correct. - lxc config get foo volatile.apply_template | grep create + inc config get foo volatile.apply_template | grep create # Start the instance to clear apply_template. - lxc start foo - lxc stop foo -f + inc start foo + inc stop foo -f # Test container rename - lxc move foo bar + inc move foo bar # Check volatile.apply_template is altered during rename. - lxc config get bar volatile.apply_template | grep rename + inc config get bar volatile.apply_template | grep rename - lxc list | grep -v foo - lxc list | grep bar + inc list | grep -v foo + inc list | grep bar - lxc rename bar foo - lxc list | grep -v bar - lxc list | grep foo - lxc rename foo bar + inc rename bar foo + inc list | grep -v bar + inc list | grep foo + inc rename foo bar # Test container copy - lxc copy bar foo - lxc delete foo + inc copy bar foo + inc delete foo # gen untrusted cert gen_cert client3 # don't allow requests without a cert to get trusted data - curl -k -s -X GET "https://${LXD_ADDR}/1.0/containers/foo" | grep 403 + curl -k -s -X GET "https://${INCUS_ADDR}/1.0/containers/foo" | grep 403 # Test unprivileged container publish - lxc publish bar --alias=foo-image prop1=val1 - lxc image show foo-image | grep val1 - curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep -F "/1.0/images/" && false - lxc image delete foo-image + inc publish bar --alias=foo-image prop1=val1 + inc image show foo-image | grep val1 + curl -k -s --cert "${INCUS_CONF}/client3.crt" --key "${INCUS_CONF}/client3.key" -X GET "https://${INCUS_ADDR}/1.0/images" | grep -F "/1.0/images/" && false + inc image delete foo-image # Test container publish with existing alias - lxc publish bar --alias=foo-image --alias=foo-image2 - lxc launch testimage baz + inc publish bar --alias=foo-image --alias=foo-image2 + inc launch testimage baz # change the container filesystem so the resulting image is different - lxc exec baz touch /somefile - lxc stop baz --force + inc exec baz touch /somefile + inc stop baz --force # publishing another image with same alias should fail - ! lxc publish baz --alias=foo-image || false + ! inc publish baz --alias=foo-image || false # publishing another image with same alias and '--reuse' flag should success - lxc publish baz --alias=foo-image --reuse - fooImage=$(lxc image list -cF -fcsv foo-image) - fooImage2=$(lxc image list -cF -fcsv foo-image2) - lxc delete baz - lxc image delete foo-image foo-image2 + inc publish baz --alias=foo-image --reuse + fooImage=$(inc image list -cF -fcsv foo-image) + fooImage2=$(inc image list -cF -fcsv foo-image2) + inc delete baz + inc image delete foo-image foo-image2 # the first image should have foo-image2 alias and the second imgae foo-image alias if [ "$fooImage" = "$fooImage2" ]; then @@ -168,17 +170,17 @@ test_basic_usage() { # Test container publish with existing alias - lxc publish bar --alias=foo-image --alias=foo-image2 - lxc launch testimage baz + inc publish bar --alias=foo-image --alias=foo-image2 + inc launch testimage baz # change the container filesystem so the resulting image is different - lxc exec baz touch /somefile - lxc stop baz --force + inc exec baz touch /somefile + inc stop baz --force # publishing another image with same aliases - lxc publish baz --alias=foo-image --alias=foo-image2 --reuse - fooImage=$(lxc image list -cF -fcsv foo-image) - fooImage2=$(lxc image list -cF -fcsv foo-image2) - lxc delete baz - lxc image delete foo-image + inc publish baz --alias=foo-image --alias=foo-image2 --reuse + fooImage=$(inc image list -cF -fcsv foo-image) + fooImage2=$(inc image list -cF -fcsv foo-image2) + inc delete baz + inc image delete foo-image # the second image should have foo-image and foo-image2 aliases and the first one should be removed if [ "$fooImage" != "$fooImage2" ]; then @@ -188,199 +190,199 @@ test_basic_usage() { # Test image compression on publish - lxc publish bar --alias=foo-image-compressed --compression=bzip2 prop=val1 - lxc image show foo-image-compressed | grep val1 - curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep -F "/1.0/images/" && false - lxc image delete foo-image-compressed + inc publish bar --alias=foo-image-compressed --compression=bzip2 prop=val1 + inc image show foo-image-compressed | grep val1 + curl -k -s --cert "${INCUS_CONF}/client3.crt" --key "${INCUS_CONF}/client3.key" -X GET "https://${INCUS_ADDR}/1.0/images" | grep -F "/1.0/images/" && false + inc image delete foo-image-compressed # Test compression options - lxc publish bar --alias=foo-image-compressed --compression="gzip --rsyncable" prop=val1 - lxc image delete foo-image-compressed + inc publish bar --alias=foo-image-compressed --compression="gzip --rsyncable" prop=val1 + inc image delete foo-image-compressed # Test privileged container publish - lxc profile create priv - lxc profile set priv security.privileged true - lxc init testimage barpriv -p default -p priv - lxc publish barpriv --alias=foo-image prop1=val1 - lxc image show foo-image | grep val1 - curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep -F "/1.0/images/" && false - lxc image delete foo-image - lxc delete barpriv - lxc profile delete priv + inc profile create priv + inc profile set priv security.privileged true + inc init testimage barpriv -p default -p priv + inc publish barpriv --alias=foo-image prop1=val1 + inc image show foo-image | grep val1 + curl -k -s --cert "${INCUS_CONF}/client3.crt" --key "${INCUS_CONF}/client3.key" -X GET "https://${INCUS_ADDR}/1.0/images" | grep -F "/1.0/images/" && false + inc image delete foo-image + inc delete barpriv + inc profile delete priv # Test that containers without metadata.yaml are published successfully. # Note that this quick hack won't work for LVM, since it doesn't always mount # the container's filesystem. That's ok though: the logic we're trying to # test here is independent of storage backend, so running it for just one # backend (or all non-lvm backends) is enough. - if [ "$lxd_backend" = "lvm" ]; then - lxc init testimage nometadata - rm -f "${LXD_DIR}/containers/nometadata/metadata.yaml" - lxc publish nometadata --alias=nometadata-image - lxc image delete nometadata-image - lxc delete nometadata + if [ "$incus_backend" = "lvm" ]; then + inc init testimage nometadata + rm -f "${INCUS_DIR}/containers/nometadata/metadata.yaml" + inc publish nometadata --alias=nometadata-image + inc image delete nometadata-image + inc delete nometadata fi # Test public images - lxc publish --public bar --alias=foo-image2 - curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep -F "/1.0/images/" - lxc image delete foo-image2 + inc publish --public bar --alias=foo-image2 + curl -k -s --cert "${INCUS_CONF}/client3.crt" --key "${INCUS_CONF}/client3.key" -X GET "https://${INCUS_ADDR}/1.0/images" | grep -F "/1.0/images/" + inc image delete foo-image2 # Test invalid container names - ! lxc init testimage -abc || false - ! lxc init testimage abc- || false - ! lxc init testimage 1234 || false - ! lxc init testimage 12test || false - ! lxc init testimage a_b_c || false - ! lxc init testimage aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || false + ! inc init testimage -abc || false + ! inc init testimage abc- || false + ! inc init testimage 1234 || false + ! inc init testimage 12test || false + ! inc init testimage a_b_c || false + ! inc init testimage aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || false # Test snapshot publish - lxc snapshot bar - lxc publish bar/snap0 --alias foo - lxc init foo bar2 - lxc list | grep bar2 - lxc delete bar2 - lxc image delete foo + inc snapshot bar + inc publish bar/snap0 --alias foo + inc init foo bar2 + inc list | grep bar2 + inc delete bar2 + inc image delete foo # Test alias support - cp "${LXD_CONF}/config.yml" "${LXD_CONF}/config.yml.bak" + cp "${INCUS_CONF}/config.yml" "${INCUS_CONF}/config.yml.bak" # 1. Basic built-in alias functionality - [ "$(lxc ls)" = "$(lxc list)" ] + [ "$(inc ls)" = "$(inc list)" ] # 2. Basic user-defined alias functionality - printf "aliases:\\n l: list\\n" >> "${LXD_CONF}/config.yml" - [ "$(lxc l)" = "$(lxc list)" ] + printf "aliases:\\n l: list\\n" >> "${INCUS_CONF}/config.yml" + [ "$(inc l)" = "$(inc list)" ] # 3. Built-in aliases and user-defined aliases can coexist - [ "$(lxc ls)" = "$(lxc l)" ] + [ "$(inc ls)" = "$(inc l)" ] # 4. Multi-argument alias keys and values - echo " i ls: image list" >> "${LXD_CONF}/config.yml" - [ "$(lxc i ls)" = "$(lxc image list)" ] + echo " i ls: image list" >> "${INCUS_CONF}/config.yml" + [ "$(inc i ls)" = "$(inc image list)" ] # 5. Aliases where len(keys) != len(values) (expansion/contraction of number of arguments) - printf " ils: image list\\n container ls: list\\n" >> "${LXD_CONF}/config.yml" - [ "$(lxc ils)" = "$(lxc image list)" ] - [ "$(lxc container ls)" = "$(lxc list)" ] + printf " ils: image list\\n container ls: list\\n" >> "${INCUS_CONF}/config.yml" + [ "$(inc ils)" = "$(inc image list)" ] + [ "$(inc container ls)" = "$(inc list)" ] # 6. User-defined aliases override built-in aliases - echo " cp: list" >> "${LXD_CONF}/config.yml" - [ "$(lxc ls)" = "$(lxc cp)" ] + echo " cp: list" >> "${INCUS_CONF}/config.yml" + [ "$(inc ls)" = "$(inc cp)" ] # 7. User-defined aliases override commands and don't recurse - lxc init testimage foo - LXC_CONFIG_SHOW=$(lxc config show foo --expanded) - echo " config show: config show --expanded" >> "${LXD_CONF}/config.yml" - [ "$(lxc config show foo)" = "$LXC_CONFIG_SHOW" ] - lxc delete foo + inc init testimage foo + INC_CONFIG_SHOW=$(inc config show foo --expanded) + echo " config show: config show --expanded" >> "${INCUS_CONF}/config.yml" + [ "$(inc config show foo)" = "$INC_CONFIG_SHOW" ] + inc delete foo # Restore the config to remove the aliases - mv "${LXD_CONF}/config.yml.bak" "${LXD_CONF}/config.yml" + mv "${INCUS_CONF}/config.yml.bak" "${INCUS_CONF}/config.yml" # Delete the bar container we've used for several tests - lxc delete bar + inc delete bar - # lxc delete should also delete all snapshots of bar - [ ! -d "${LXD_DIR}/snapshots/bar" ] + # inc delete should also delete all snapshots of bar + [ ! -d "${INCUS_DIR}/snapshots/bar" ] # Test randomly named container creation - lxc launch testimage - RDNAME=$(lxc list --format csv --columns n) - lxc delete -f "${RDNAME}" + inc launch testimage + RDNAME=$(inc list --format csv --columns n) + inc delete -f "${RDNAME}" # Test "nonetype" container creation - wait_for "${LXD_ADDR}" my_curl -X POST "https://${LXD_ADDR}/1.0/containers" \ + wait_for "${INCUS_ADDR}" my_curl -X POST "https://${INCUS_ADDR}/1.0/containers" \ -d "{\"name\":\"nonetype\",\"source\":{\"type\":\"none\"}}" - lxc delete nonetype + inc delete nonetype # Test "nonetype" container creation with an LXC config - wait_for "${LXD_ADDR}" my_curl -X POST "https://${LXD_ADDR}/1.0/containers" \ + wait_for "${INCUS_ADDR}" my_curl -X POST "https://${INCUS_ADDR}/1.0/containers" \ -d "{\"name\":\"configtest\",\"config\":{\"raw.lxc\":\"lxc.hook.clone=/bin/true\"},\"source\":{\"type\":\"none\"}}" # shellcheck disable=SC2102 - [ "$(my_curl "https://${LXD_ADDR}/1.0/containers/configtest" | jq -r .metadata.config[\"raw.lxc\"])" = "lxc.hook.clone=/bin/true" ] - lxc delete configtest + [ "$(my_curl "https://${INCUS_ADDR}/1.0/containers/configtest" | jq -r .metadata.config[\"raw.lxc\"])" = "lxc.hook.clone=/bin/true" ] + inc delete configtest # Test activateifneeded/shutdown - LXD_ACTIVATION_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ACTIVATION_DIR}" - spawn_lxd "${LXD_ACTIVATION_DIR}" true + INCUS_ACTIVATION_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ACTIVATION_DIR}" + spawn_incus "${INCUS_ACTIVATION_DIR}" true ( set -e # shellcheck disable=SC2030 - LXD_DIR=${LXD_ACTIVATION_DIR} + INCUS_DIR=${INCUS_ACTIVATION_DIR} ensure_import_testimage - lxd activateifneeded --debug 2>&1 | grep -qF "Daemon has core.https_address set, activating..." - lxc config unset core.https_address --force-local - lxd activateifneeded --debug 2>&1 | grep -qF -v "activating..." - lxc init testimage autostart --force-local - lxd activateifneeded --debug 2>&1 | grep -qF -v "activating..." - lxc config set autostart boot.autostart true --force-local + incus activateifneeded --debug 2>&1 | grep -qF "Daemon has core.https_address set, activating..." + inc config unset core.https_address --force-local + incus activateifneeded --debug 2>&1 | grep -qF -v "activating..." + inc init testimage autostart --force-local + incus activateifneeded --debug 2>&1 | grep -qF -v "activating..." + inc config set autostart boot.autostart true --force-local # Restart the daemon, this forces the global database to be dumped to disk. - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true - lxc stop --force autostart --force-local + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true + inc stop --force autostart --force-local - lxd activateifneeded --debug 2>&1 | grep -qF "Daemon has auto-started instances, activating..." + incus activateifneeded --debug 2>&1 | grep -qF "Daemon has auto-started instances, activating..." - lxc config unset autostart boot.autostart --force-local - lxd activateifneeded --debug 2>&1 | grep -qF -v "activating..." + inc config unset autostart boot.autostart --force-local + incus activateifneeded --debug 2>&1 | grep -qF -v "activating..." - lxc start autostart --force-local - PID=$(lxc info autostart --force-local | awk '/^PID:/ {print $2}') - shutdown_lxd "${LXD_DIR}" + inc start autostart --force-local + PID=$(inc info autostart --force-local | awk '/^PID:/ {print $2}') + shutdown_incus "${INCUS_DIR}" [ -d "/proc/${PID}" ] && false - lxd activateifneeded --debug 2>&1 | grep -qF "Daemon has auto-started instances, activating..." + incus activateifneeded --debug 2>&1 | grep -qF "Daemon has auto-started instances, activating..." # shellcheck disable=SC2031 - respawn_lxd "${LXD_DIR}" true + respawn_incus "${INCUS_DIR}" true - lxc list --force-local autostart | grep -q RUNNING + inc list --force-local autostart | grep -q RUNNING # Check for scheduled instance snapshots - lxc stop --force autostart --force-local - lxc config set autostart snapshots.schedule "* * * * *" --force-local - shutdown_lxd "${LXD_DIR}" - lxd activateifneeded --debug 2>&1 | grep -qF "Daemon has scheduled instance snapshots, activating..." + inc stop --force autostart --force-local + inc config set autostart snapshots.schedule "* * * * *" --force-local + shutdown_incus "${INCUS_DIR}" + incus activateifneeded --debug 2>&1 | grep -qF "Daemon has scheduled instance snapshots, activating..." # shellcheck disable=SC2031 - respawn_lxd "${LXD_DIR}" true + respawn_incus "${INCUS_DIR}" true - lxc config unset autostart snapshots.schedule --force-local + inc config unset autostart snapshots.schedule --force-local # Check for scheduled volume snapshots - storage_pool="lxdtest-$(basename "${LXD_DIR}")" + storage_pool="incustest-$(basename "${INCUS_DIR}")" - lxc storage volume create "${storage_pool}" vol --force-local + inc storage volume create "${storage_pool}" vol --force-local - shutdown_lxd "${LXD_DIR}" - lxd activateifneeded --debug 2>&1 | grep -qF -v "activating..." + shutdown_incus "${INCUS_DIR}" + incus activateifneeded --debug 2>&1 | grep -qF -v "activating..." # shellcheck disable=SC2031 - respawn_lxd "${LXD_DIR}" true + respawn_incus "${INCUS_DIR}" true - lxc storage volume set "${storage_pool}" vol snapshots.schedule="* * * * *" --force-local + inc storage volume set "${storage_pool}" vol snapshots.schedule="* * * * *" --force-local - shutdown_lxd "${LXD_DIR}" - lxd activateifneeded --debug 2>&1 | grep -qF "Daemon has scheduled volume snapshots, activating..." + shutdown_incus "${INCUS_DIR}" + incus activateifneeded --debug 2>&1 | grep -qF "Daemon has scheduled volume snapshots, activating..." # shellcheck disable=SC2031 - respawn_lxd "${LXD_DIR}" true + respawn_incus "${INCUS_DIR}" true - lxc delete autostart --force --force-local - lxc storage volume delete "${storage_pool}" vol --force-local + inc delete autostart --force --force-local + inc storage volume delete "${storage_pool}" vol --force-local ) # shellcheck disable=SC2031,2269 - LXD_DIR=${LXD_DIR} - kill_lxd "${LXD_ACTIVATION_DIR}" + INCUS_DIR=${INCUS_DIR} + kill_incus "${INCUS_ACTIVATION_DIR}" # Create and start a container - lxc launch testimage foo - lxc list | grep foo | grep RUNNING - lxc stop foo --force + inc launch testimage foo + inc list | grep foo | grep RUNNING + inc stop foo --force # cycle it a few times - lxc start foo - mac1=$(lxc exec foo cat /sys/class/net/eth0/address) - lxc stop foo --force - lxc start foo - mac2=$(lxc exec foo cat /sys/class/net/eth0/address) + inc start foo + mac1=$(inc exec foo cat /sys/class/net/eth0/address) + inc stop foo --force + inc start foo + mac2=$(inc exec foo cat /sys/class/net/eth0/address) if [ -n "${mac1}" ] && [ -n "${mac2}" ] && [ "${mac1}" != "${mac2}" ]; then echo "==> MAC addresses didn't match across restarts (${mac1} vs ${mac2})" @@ -388,84 +390,84 @@ test_basic_usage() { fi # Test instance types - lxc launch testimage test-limits -t c0.5-m0.2 - [ "$(lxc config get test-limits limits.cpu)" = "1" ] - [ "$(lxc config get test-limits limits.cpu.allowance)" = "50%" ] - [ "$(lxc config get test-limits limits.memory)" = "204MiB" ] - lxc delete -f test-limits + inc launch testimage test-limits -t c0.5-m0.2 + [ "$(inc config get test-limits limits.cpu)" = "1" ] + [ "$(inc config get test-limits limits.cpu.allowance)" = "50%" ] + [ "$(inc config get test-limits limits.memory)" = "204MiB" ] + inc delete -f test-limits # Test last_used_at field is working properly - lxc init testimage last-used-at-test - lxc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep '1970-01-01T00:00:00Z' - lxc start last-used-at-test - lxc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep -v '1970-01-01T00:00:00Z' - lxc delete last-used-at-test --force + inc init testimage last-used-at-test + inc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep '1970-01-01T00:00:00Z' + inc start last-used-at-test + inc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep -v '1970-01-01T00:00:00Z' + inc delete last-used-at-test --force # Test user, group and cwd - lxc exec foo -- mkdir /blah - [ "$(lxc exec foo --user 1000 -- id -u)" = "1000" ] || false - [ "$(lxc exec foo --group 1000 -- id -g)" = "1000" ] || false - [ "$(lxc exec foo --cwd /blah -- pwd)" = "/blah" ] || false + inc exec foo -- mkdir /blah + [ "$(inc exec foo --user 1000 -- id -u)" = "1000" ] || false + [ "$(inc exec foo --group 1000 -- id -g)" = "1000" ] || false + [ "$(inc exec foo --cwd /blah -- pwd)" = "/blah" ] || false - [ "$(lxc exec foo --user 1234 --group 5678 --cwd /blah -- id -u)" = "1234" ] || false - [ "$(lxc exec foo --user 1234 --group 5678 --cwd /blah -- id -g)" = "5678" ] || false - [ "$(lxc exec foo --user 1234 --group 5678 --cwd /blah -- pwd)" = "/blah" ] || false + [ "$(inc exec foo --user 1234 --group 5678 --cwd /blah -- id -u)" = "1234" ] || false + [ "$(inc exec foo --user 1234 --group 5678 --cwd /blah -- id -g)" = "5678" ] || false + [ "$(inc exec foo --user 1234 --group 5678 --cwd /blah -- pwd)" = "/blah" ] || false # check that we can set the environment - lxc exec foo pwd | grep /root - lxc exec --env BEST_BAND=meshuggah foo env | grep meshuggah - lxc exec foo ip link show | grep eth0 + inc exec foo pwd | grep /root + inc exec --env BEST_BAND=meshuggah foo env | grep meshuggah + inc exec foo ip link show | grep eth0 # check that we can get the return code for a non- wait-for-websocket exec - op=$(my_curl -X POST "https://${LXD_ADDR}/1.0/containers/foo/exec" -d '{"command": ["echo", "test"], "environment": {}, "wait-for-websocket": false, "interactive": false}' | jq -r .operation) - [ "$(my_curl "https://${LXD_ADDR}${op}/wait" | jq -r .metadata.metadata.return)" != "null" ] + op=$(my_curl -X POST "https://${INCUS_ADDR}/1.0/containers/foo/exec" -d '{"command": ["echo", "test"], "environment": {}, "wait-for-websocket": false, "interactive": false}' | jq -r .operation) + [ "$(my_curl "https://${INCUS_ADDR}${op}/wait" | jq -r .metadata.metadata.return)" != "null" ] # test file transfer - echo abc > "${LXD_DIR}/in" + echo abc > "${INCUS_DIR}/in" - lxc file push "${LXD_DIR}/in" foo/root/ - lxc exec foo /bin/cat /root/in | grep abc - lxc exec foo -- /bin/rm -f root/in + inc file push "${INCUS_DIR}/in" foo/root/ + inc exec foo /bin/cat /root/in | grep abc + inc exec foo -- /bin/rm -f root/in - lxc file push "${LXD_DIR}/in" foo/root/in1 - lxc exec foo /bin/cat /root/in1 | grep abc - lxc exec foo -- /bin/rm -f root/in1 + inc file push "${INCUS_DIR}/in" foo/root/in1 + inc exec foo /bin/cat /root/in1 | grep abc + inc exec foo -- /bin/rm -f root/in1 - # test lxc file edit doesn't change target file's owner and permissions - echo "content" | lxc file push - foo/tmp/edit_test - lxc exec foo -- chown 55.55 /tmp/edit_test - lxc exec foo -- chmod 555 /tmp/edit_test - echo "new content" | lxc file edit foo/tmp/edit_test - [ "$(lxc exec foo -- cat /tmp/edit_test)" = "new content" ] - [ "$(lxc exec foo -- stat -c \"%u %g %a\" /tmp/edit_test)" = "55 55 555" ] + # test inc file edit doesn't change target file's owner and permissions + echo "content" | inc file push - foo/tmp/edit_test + inc exec foo -- chown 55.55 /tmp/edit_test + inc exec foo -- chmod 555 /tmp/edit_test + echo "new content" | inc file edit foo/tmp/edit_test + [ "$(inc exec foo -- cat /tmp/edit_test)" = "new content" ] + [ "$(inc exec foo -- stat -c \"%u %g %a\" /tmp/edit_test)" = "55 55 555" ] # make sure stdin is chowned to our container root uid (Issue #590) - [ -t 0 ] && [ -t 1 ] && lxc exec foo -- chown 1000:1000 /proc/self/fd/0 + [ -t 0 ] && [ -t 1 ] && inc exec foo -- chown 1000:1000 /proc/self/fd/0 - echo foo | lxc exec foo tee /tmp/foo + echo foo | inc exec foo tee /tmp/foo # Detect regressions/hangs in exec - sum=$(ps aux | tee "${LXD_DIR}/out" | lxc exec foo md5sum | cut -d' ' -f1) - [ "${sum}" = "$(md5sum "${LXD_DIR}/out" | cut -d' ' -f1)" ] - rm "${LXD_DIR}/out" + sum=$(ps aux | tee "${INCUS_DIR}/out" | inc exec foo md5sum | cut -d' ' -f1) + [ "${sum}" = "$(md5sum "${INCUS_DIR}/out" | cut -d' ' -f1)" ] + rm "${INCUS_DIR}/out" # FIXME: make this backend agnostic - if [ "$lxd_backend" = "dir" ]; then - content=$(cat "${LXD_DIR}/containers/foo/rootfs/tmp/foo") + if [ "$incus_backend" = "dir" ]; then + content=$(cat "${INCUS_DIR}/containers/foo/rootfs/tmp/foo") [ "${content}" = "foo" ] fi - lxc launch testimage deleterunning - my_curl -X DELETE "https://${LXD_ADDR}/1.0/containers/deleterunning" | grep "Instance is running" - lxc delete deleterunning -f + inc launch testimage deleterunning + my_curl -X DELETE "https://${INCUS_ADDR}/1.0/containers/deleterunning" | grep "Instance is running" + inc delete deleterunning -f # cleanup - lxc delete foo -f + inc delete foo -f if [ -e /sys/module/apparmor/ ]; then # check that an apparmor profile is created for this container, that it is # unloaded on stop, and that it is deleted when the container is deleted - lxc launch testimage lxd-apparmor-test + inc launch testimage inc-apparmor-test MAJOR=0 MINOR=0 @@ -475,90 +477,90 @@ test_basic_usage() { fi if [ "${MAJOR}" -gt "1" ] || { [ "${MAJOR}" = "1" ] && [ "${MINOR}" -ge "2" ]; }; then - aa_namespace="lxd-lxd-apparmor-test_<$(echo "${LXD_DIR}" | sed -e 's/\//-/g' -e 's/^.//')>" + aa_namespace="incus-inc-apparmor-test_<$(echo "${INCUS_DIR}" | sed -e 's/\//-/g' -e 's/^.//')>" aa-status | grep -q ":${aa_namespace}:unconfined" || aa-status | grep -qF ":${aa_namespace}://unconfined" - lxc stop lxd-apparmor-test --force + inc stop inc-apparmor-test --force ! aa-status | grep -qF ":${aa_namespace}:" || false else - aa-status | grep "lxd-lxd-apparmor-test_<${LXD_DIR}>" - lxc stop lxd-apparmor-test --force - ! aa-status | grep -qF "lxd-lxd-apparmor-test_<${LXD_DIR}>" || false + aa-status | grep "incus-inc-apparmor-test_<${INCUS_DIR}>" + inc stop inc-apparmor-test --force + ! aa-status | grep -qF "incus-inc-apparmor-test_<${INCUS_DIR}>" || false fi - lxc delete lxd-apparmor-test - [ ! -f "${LXD_DIR}/security/apparmor/profiles/lxd-lxd-apparmor-test" ] + inc delete inc-apparmor-test + [ ! -f "${INCUS_DIR}/security/apparmor/profiles/incus-inc-apparmor-test" ] else echo "==> SKIP: apparmor tests (missing kernel support)" fi if [ "$(awk '/^Seccomp:/ {print $2}' "/proc/self/status")" -eq "0" ]; then - lxc launch testimage lxd-seccomp-test - init=$(lxc info lxd-seccomp-test | awk '/^PID:/ {print $2}') + inc launch testimage inc-seccomp-test + init=$(inc info inc-seccomp-test | awk '/^PID:/ {print $2}') [ "$(awk '/^Seccomp:/ {print $2}' "/proc/${init}/status")" -eq "2" ] - lxc stop --force lxd-seccomp-test - lxc config set lxd-seccomp-test security.syscalls.deny_default false - lxc start lxd-seccomp-test - init=$(lxc info lxd-seccomp-test | awk '/^PID:/ {print $2}') + inc stop --force inc-seccomp-test + inc config set inc-seccomp-test security.syscalls.deny_default false + inc start inc-seccomp-test + init=$(inc info inc-seccomp-test | awk '/^PID:/ {print $2}') [ "$(awk '/^Seccomp:/ {print $2}' "/proc/${init}/status")" -eq "0" ] - lxc delete --force lxd-seccomp-test + inc delete --force inc-seccomp-test else echo "==> SKIP: seccomp tests (seccomp filtering is externally enabled)" fi # make sure that privileged containers are not world-readable - lxc profile create unconfined - lxc profile set unconfined security.privileged true - lxc init testimage foo2 -p unconfined -s "lxdtest-$(basename "${LXD_DIR}")" - [ "$(stat -L -c "%a" "${LXD_DIR}/containers/foo2")" = "100" ] - lxc delete foo2 - lxc profile delete unconfined + inc profile create unconfined + inc profile set unconfined security.privileged true + inc init testimage foo2 -p unconfined -s "incustest-$(basename "${INCUS_DIR}")" + [ "$(stat -L -c "%a" "${INCUS_DIR}/containers/foo2")" = "100" ] + inc delete foo2 + inc profile delete unconfined # Test boot.host_shutdown_timeout config setting - lxc init testimage configtest --config boot.host_shutdown_timeout=45 - [ "$(lxc config get configtest boot.host_shutdown_timeout)" -eq 45 ] - lxc config set configtest boot.host_shutdown_timeout 15 - [ "$(lxc config get configtest boot.host_shutdown_timeout)" -eq 15 ] - lxc delete configtest + inc init testimage configtest --config boot.host_shutdown_timeout=45 + [ "$(inc config get configtest boot.host_shutdown_timeout)" -eq 45 ] + inc config set configtest boot.host_shutdown_timeout 15 + [ "$(inc config get configtest boot.host_shutdown_timeout)" -eq 15 ] + inc delete configtest # Test deleting multiple images # Start 3 containers to create 3 different images - lxc launch testimage c1 - lxc launch testimage c2 - lxc launch testimage c3 - lxc exec c1 -- touch /tmp/c1 - lxc exec c2 -- touch /tmp/c2 - lxc exec c3 -- touch /tmp/c3 - lxc publish --force c1 --alias=image1 - lxc publish --force c2 --alias=image2 - lxc publish --force c3 --alias=image3 - # Delete multiple images with lxc delete and confirm they're deleted - lxc image delete local:image1 local:image2 local:image3 - ! lxc image list | grep -q image1 || false - ! lxc image list | grep -q image2 || false - ! lxc image list | grep -q image3 || false + inc launch testimage c1 + inc launch testimage c2 + inc launch testimage c3 + inc exec c1 -- touch /tmp/c1 + inc exec c2 -- touch /tmp/c2 + inc exec c3 -- touch /tmp/c3 + inc publish --force c1 --alias=image1 + inc publish --force c2 --alias=image2 + inc publish --force c3 --alias=image3 + # Delete multiple images with inc delete and confirm they're deleted + inc image delete local:image1 local:image2 local:image3 + ! inc image list | grep -q image1 || false + ! inc image list | grep -q image2 || false + ! inc image list | grep -q image3 || false # Cleanup the containers - lxc delete --force c1 c2 c3 + inc delete --force c1 c2 c3 # Test --all flag - lxc init testimage c1 - lxc init testimage c2 - lxc start --all - lxc list | grep c1 | grep RUNNING - lxc list | grep c2 | grep RUNNING - ! lxc stop --all c1 || false - lxc stop --all -f - lxc list | grep c1 | grep STOPPED - lxc list | grep c2 | grep STOPPED + inc init testimage c1 + inc init testimage c2 + inc start --all + inc list | grep c1 | grep RUNNING + inc list | grep c2 | grep RUNNING + ! inc stop --all c1 || false + inc stop --all -f + inc list | grep c1 | grep STOPPED + inc list | grep c2 | grep STOPPED # Cleanup the containers - lxc delete --force c1 c2 + inc delete --force c1 c2 # Ephemeral - lxc launch testimage foo -e - OLD_INIT=$(lxc info foo | awk '/^PID:/ {print $2}') + inc launch testimage foo -e + OLD_INIT=$(inc info foo | awk '/^PID:/ {print $2}') REBOOTED="false" for _ in $(seq 60); do - NEW_INIT=$(lxc info foo | awk '/^PID:/ {print $2}' || true) + NEW_INIT=$(inc info foo | awk '/^PID:/ {print $2}' || true) # If init process is running, check if is old or new process. if [ -n "${NEW_INIT}" ]; then @@ -566,7 +568,7 @@ test_basic_usage() { REBOOTED="true" break else - lxc exec foo reboot || true # Signal to running old init processs to reboot if not rebooted yet. + inc exec foo reboot || true # Signal to running old init processs to reboot if not rebooted yet. fi fi @@ -575,83 +577,83 @@ test_basic_usage() { [ "${REBOOTED}" = "true" ] - lxc publish foo --alias foo --force - lxc image delete foo + inc publish foo --alias foo --force + inc image delete foo - lxc restart -f foo - lxc stop foo --force - ! lxc list | grep -q foo || false + inc restart -f foo + inc stop foo --force + ! inc list | grep -q foo || false # Test renaming/deletion of the default profile - ! lxc profile rename default foobar || false - ! lxc profile delete default || false + ! inc profile rename default foobar || false + ! inc profile delete default || false - lxc init testimage c1 - result="$(! lxc config device override c1 root pool=bla 2>&1)" + inc init testimage c1 + result="$(! inc config device override c1 root pool=bla 2>&1)" if ! echo "${result}" | grep "Error: Cannot update root disk device pool name"; then echo "Should fail device override because root disk device storage pool cannot be changed." false fi - lxc rm -f c1 + inc rm -f c1 # Should fail to override root device storage pool when the new pool does not exist. - ! lxc init testimage c1 -d root,pool=bla || false + ! inc init testimage c1 -d root,pool=bla || false # Should succeed in overriding root device storage pool when the pool does exist and the override occurs at create time. - lxc storage create bla dir - lxc init testimage c1 -d root,pool=bla - lxc config show c1 --expanded | grep -Pz ' root:\n path: /\n pool: bla\n type: disk\n' + inc storage create bla dir + inc init testimage c1 -d root,pool=bla + inc config show c1 --expanded | grep -Pz ' root:\n path: /\n pool: bla\n type: disk\n' - lxc storage volume create bla vol1 - lxc storage volume create bla vol2 - lxc config device add c1 dev disk source=vol1 pool=bla path=/vol + inc storage volume create bla vol1 + inc storage volume create bla vol2 + inc config device add c1 dev disk source=vol1 pool=bla path=/vol # Should not be able to override a device that is not part of a profile (i.e. has been specifically added). - result="$(! lxc config device override c1 dev source=vol2 2>&1)" + result="$(! inc config device override c1 dev source=vol2 2>&1)" if ! echo "${result}" | grep "Error: The device already exists"; then echo "Should fail because device is defined against the instance not the profile." false fi - lxc rm -f c1 - lxc storage volume delete bla vol1 - lxc storage volume delete bla vol2 - lxc storage delete bla + inc rm -f c1 + inc storage volume delete bla vol1 + inc storage volume delete bla vol2 + inc storage delete bla # Test rebuilding an instance with its original image. - lxc init testimage c1 - lxc start c1 - lxc exec c1 -- touch /data.txt - lxc stop c1 - lxc rebuild testimage c1 - lxc start c1 - ! lxc exec c1 -- stat /data.txt || false - lxc delete c1 -f + inc init testimage c1 + inc start c1 + inc exec c1 -- touch /data.txt + inc stop c1 + inc rebuild testimage c1 + inc start c1 + ! inc exec c1 -- stat /data.txt || false + inc delete c1 -f # Test a forced rebuild - lxc launch testimage c1 - ! lxc rebuild testimage c1 || false - lxc rebuild testimage c1 --force - lxc delete c1 -f + inc launch testimage c1 + ! inc rebuild testimage c1 || false + inc rebuild testimage c1 --force + inc delete c1 -f # Test rebuilding an instance with a new image. - lxc init c1 --empty - lxc remote add l1 "${LXD_ADDR}" --accept-certificate --password foo - lxc rebuild l1:testimage c1 - lxc start c1 - lxc delete c1 -f - lxc remote remove l1 + inc init c1 --empty + inc remote add l1 "${INCUS_ADDR}" --accept-certificate --password foo + inc rebuild l1:testimage c1 + inc start c1 + inc delete c1 -f + inc remote remove l1 # Test rebuilding an instance with an empty file system. - lxc init testimage c1 - lxc rebuild c1 --empty - lxc delete c1 -f + inc init testimage c1 + inc rebuild c1 --empty + inc delete c1 -f # Test assigning an empty profile (with no root disk device) to an instance. - lxc init testimage c1 - lxc profile create foo - ! lxc profile assign c1 foo || false - lxc profile delete foo - lxc delete -f c1 + inc init testimage c1 + inc profile create foo + ! inc profile assign c1 foo || false + inc profile delete foo + inc delete -f c1 } diff --git a/test/suites/cloud-init.sh b/test/suites/cloud-init.sh index 20dfc269394..f0b8f562f7d 100644 --- a/test/suites/cloud-init.sh +++ b/test/suites/cloud-init.sh @@ -1,30 +1,30 @@ test_cloud_init() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - lxc init testimage c1 - ID1=$(lxc config get c1 volatile.cloud-init.instance-id) + inc init testimage c1 + ID1=$(inc config get c1 volatile.cloud-init.instance-id) [ -n "${ID1}" ] - lxc rename c1 c2 - ID2=$(lxc config get c2 volatile.cloud-init.instance-id) + inc rename c1 c2 + ID2=$(inc config get c2 volatile.cloud-init.instance-id) [ -n "${ID2}" ] && [ "${ID2}" != "${ID1}" ] - lxc copy c2 c1 - ID3=$(lxc config get c1 volatile.cloud-init.instance-id) + inc copy c2 c1 + ID3=$(inc config get c1 volatile.cloud-init.instance-id) [ -n "${ID3}" ] && [ "${ID3}" != "${ID2}" ] - lxc config set c1 cloud-init.user-data blah - ID4=$(lxc config get c1 volatile.cloud-init.instance-id) + inc config set c1 cloud-init.user-data blah + ID4=$(inc config get c1 volatile.cloud-init.instance-id) [ -n "${ID4}" ] && [ "${ID4}" != "${ID3}" ] - lxc config device override c1 eth0 user.foo=bar - ID5=$(lxc config get c1 volatile.cloud-init.instance-id) + inc config device override c1 eth0 user.foo=bar + ID5=$(inc config get c1 volatile.cloud-init.instance-id) [ "${ID5}" = "${ID4}" ] - lxc config device set c1 eth0 name=foo - ID6=$(lxc config get c1 volatile.cloud-init.instance-id) + inc config device set c1 eth0 name=foo + ID6=$(inc config get c1 volatile.cloud-init.instance-id) [ -n "${ID6}" ] && [ "${ID6}" != "${ID5}" ] - lxc delete -f c1 c2 + inc delete -f c1 c2 } diff --git a/test/suites/clustering.sh b/test/suites/clustering.sh index 4350aed1dd1..a8126c65987 100644 --- a/test/suites/clustering.sh +++ b/test/suites/clustering.sh @@ -1,211 +1,211 @@ test_clustering_enable() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false # Test specified core.https_address with no cluster.https_address ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} + INCUS_DIR=${INCUS_INIT_DIR} - lxc config show | grep "core.https_address" | grep -qE "127.0.0.1:[0-9]{4,5}$" + inc config show | grep "core.https_address" | grep -qE "127.0.0.1:[0-9]{4,5}$" # Launch a container. ensure_import_testimage - lxc storage create default dir - lxc profile device add default root disk path="/" pool="default" - lxc launch testimage c1 + inc storage create default dir + inc profile device add default root disk path="/" pool="default" + inc launch testimage c1 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q node1 + inc cluster enable node1 + inc cluster list | grep -q node1 # The container is still there and now shows up as # running on node 1. - lxc list | grep c1 | grep -q node1 + inc list | grep c1 | grep -q node1 # Clustering can't be enabled on an already clustered instance. - ! lxc cluster enable node2 || false + ! inc cluster enable node2 || false # Delete the container - lxc stop c1 --force - lxc delete c1 + inc stop c1 --force + inc delete c1 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test wildcard core.https_address with no cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config set core.https_address :: + INCUS_DIR=${INCUS_INIT_DIR} + inc config set core.https_address :: # Enable clustering. - ! lxc cluster enable node1 || false + ! inc cluster enable node1 || false ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test default port core.https_address with no cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config set core.https_address 127.0.0.1 + INCUS_DIR=${INCUS_INIT_DIR} + inc config set core.https_address 127.0.0.1 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test wildcard core.https_address with valid cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config set core.https_address :: - lxc config set cluster.https_address 127.0.0.1:8443 + INCUS_DIR=${INCUS_INIT_DIR} + inc config set core.https_address :: + inc config set cluster.https_address 127.0.0.1:8443 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test empty core.https_address with no cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config unset core.https_address + INCUS_DIR=${INCUS_INIT_DIR} + inc config unset core.https_address # Enable clustering. - ! lxc cluster enable node1 || false + ! inc cluster enable node1 || false ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test empty core.https_address with valid cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config unset core.https_address - lxc config set cluster.https_address 127.0.0.1:8443 + INCUS_DIR=${INCUS_INIT_DIR} + inc config unset core.https_address + inc config set cluster.https_address 127.0.0.1:8443 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test empty core.https_address with default port cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config unset core.https_address - lxc config set cluster.https_address 127.0.0.1 + INCUS_DIR=${INCUS_INIT_DIR} + inc config unset core.https_address + inc config set cluster.https_address 127.0.0.1 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test covered cluster.https_address - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config set core.https_address 127.0.0.1:8443 - lxc config set cluster.https_address 127.0.0.1:8443 + INCUS_DIR=${INCUS_INIT_DIR} + inc config set core.https_address 127.0.0.1:8443 + inc config set cluster.https_address 127.0.0.1:8443 # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" # Test cluster listener after reload - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR=${LXD_INIT_DIR} - lxc config set cluster.https_address 127.0.0.1:8443 - kill -9 "$(cat "${LXD_DIR}/lxd.pid")" - respawn_lxd "${LXD_DIR}" true + INCUS_DIR=${INCUS_INIT_DIR} + inc config set cluster.https_address 127.0.0.1:8443 + kill -9 "$(cat "${INCUS_DIR}/incus.pid")" + respawn_incus "${INCUS_DIR}" true # Enable clustering. - lxc cluster enable node1 - lxc cluster list | grep -q 127.0.0.1:8443 + inc cluster enable node1 + inc cluster list | grep -q 127.0.0.1:8443 ) - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" } test_clustering_membership() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Configuration keys can be changed on any node. - LXD_DIR="${LXD_TWO_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -q 'cluster.offline_threshold: "11"' - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -q 'cluster.offline_threshold: "11"' + INCUS_DIR="${INCUS_TWO_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -q 'cluster.offline_threshold: "11"' + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -q 'cluster.offline_threshold: "11"' # The preseeded network bridge exists on all nodes. ns1_pid="$(cat "${TEST_DIR}/ns/${ns1}/PID")" @@ -216,459 +216,459 @@ test_clustering_membership() { # Create a pending network and pool, to show that they are not # considered when checking if the joining node has all the required # networks and pools. - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 dir --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc network create net1 --target node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 dir --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc network create net1 --target node2 # Spawn a third node, using the non-leader node2 as join target. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${INCUS_THREE_DIR}" # Spawn a fourth node, this will be a non-database node. setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" # Spawn a fifth node, using non-database node4 as join target. setup_clustering_netns 5 - LXD_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FIVE_DIR}" + INCUS_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FIVE_DIR}" ns5="${prefix}5" - spawn_lxd_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 4 "${LXD_FIVE_DIR}" + spawn_incus_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 4 "${INCUS_FIVE_DIR}" # List all nodes, using clients points to different nodes and # checking which are database nodes and which are database-standby nodes. - LXD_DIR="${LXD_THREE_DIR}" lxc cluster list - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node1 | grep -q "\- database-leader$" - LXD_DIR="${LXD_THREE_DIR}" lxc cluster list | grep -Fc "database-standby" | grep -Fx 2 - LXD_DIR="${LXD_FIVE_DIR}" lxc cluster list | grep -Fc "database " | grep -Fx 3 + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster list + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node1 | grep -q "\- database-leader$" + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster list | grep -Fc "database-standby" | grep -Fx 2 + INCUS_DIR="${INCUS_FIVE_DIR}" inc cluster list | grep -Fc "database " | grep -Fx 3 # Show a single node - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node5 | grep -q "node5" + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node5 | grep -q "node5" # Client certificate are shared across all nodes. - lxc remote add cluster 10.1.1.101:8443 --accept-certificate --password=sekret - lxc remote set-url cluster https://10.1.1.102:8443 - lxc network list cluster: | grep -q "${bridge}" - lxc remote remove cluster + inc remote add cluster 10.1.1.101:8443 --accept-certificate --password=sekret + inc remote set-url cluster https://10.1.1.102:8443 + inc network list cluster: | grep -q "${bridge}" + inc remote remove cluster # Check info for single node (from local and remote node). - LXD_DIR="${LXD_FIVE_DIR}" lxc cluster info node5 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster info node5 + INCUS_DIR="${INCUS_FIVE_DIR}" inc cluster info node5 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster info node5 # Disable image replication - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.images_minimal_replica 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.images_minimal_replica 1 # Shutdown a database node, and wait a few seconds so it will be # detected as down. - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 12 - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node3 | grep -q "status: Offline" + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node3 | grep -q "status: Offline" # Gracefully remove a node and check trust certificate is removed. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep node4 - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'SELECT name FROM certificates WHERE type = 2' | grep node4 - LXD_DIR="${LXD_TWO_DIR}" lxc cluster remove node4 - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep node4 || false - ! LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'SELECT name FROM certificates WHERE type = 2' | grep node4 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep node4 + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'SELECT name FROM certificates WHERE type = 2' | grep node4 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster remove node4 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep node4 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'SELECT name FROM certificates WHERE type = 2' | grep node4 || false # The node isn't clustered anymore. - ! LXD_DIR="${LXD_FOUR_DIR}" lxc cluster list || false + ! INCUS_DIR="${INCUS_FOUR_DIR}" inc cluster list || false # Generate a join token for the sixth node. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - token=$(LXD_DIR="${LXD_ONE_DIR}" lxc cluster add node6 | tail -n 1) + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + token=$(INCUS_DIR="${INCUS_ONE_DIR}" inc cluster add node6 | tail -n 1) # Check token is associated to correct name. - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens | grep node6 | grep "${token}" + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens | grep node6 | grep "${token}" # Spawn a sixth node, using join token. setup_clustering_netns 6 - LXD_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_SIX_DIR}" + INCUS_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_SIX_DIR}" ns6="${prefix}6" # shellcheck disable=SC2034 - LXD_SECRET="${token}" - spawn_lxd_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 2 "${LXD_SIX_DIR}" - unset LXD_SECRET + INCUS_SECRET="${token}" + spawn_incus_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 2 "${INCUS_SIX_DIR}" + unset INCUS_SECRET # Check token has been deleted after join. - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens - ! LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens | grep node6 || false + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens + ! INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens | grep node6 || false # Generate a join token for a seventh node - token=$(LXD_DIR="${LXD_ONE_DIR}" lxc cluster add node7 | tail -n 1) + token=$(INCUS_DIR="${INCUS_ONE_DIR}" inc cluster add node7 | tail -n 1) # Check token is associated to correct name - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens | grep node7 | grep "${token}" + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens | grep node7 | grep "${token}" # Revoke the token - LXD_DIR="${LXD_ONE_DIR}" lxc cluster revoke-token node7 | tail -n 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster revoke-token node7 | tail -n 1 # Check token has been deleted - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens - ! LXD_DIR="${LXD_TWO_DIR}" lxc cluster list-tokens | grep node7 || false + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens + ! INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list-tokens | grep node7 || false # Set cluster token expiry to 30 seconds - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.join_token_expiry=30S + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.join_token_expiry=30S # Generate a join token for an eigth and ninth node - token_valid=$(LXD_DIR="${LXD_ONE_DIR}" lxc cluster add node8 | tail -n 1) + token_valid=$(INCUS_DIR="${INCUS_ONE_DIR}" inc cluster add node8 | tail -n 1) # Spawn an eigth node, using join token. setup_clustering_netns 8 - LXD_EIGHT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_EIGHT_DIR}" + INCUS_EIGHT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_EIGHT_DIR}" ns8="${prefix}8" # shellcheck disable=SC2034 - LXD_SECRET="${token_valid}" - spawn_lxd_and_join_cluster "${ns8}" "${bridge}" "${cert}" 8 2 "${LXD_EIGHT_DIR}" - unset LXD_SECRET + INCUS_SECRET="${token_valid}" + spawn_incus_and_join_cluster "${ns8}" "${bridge}" "${cert}" 8 2 "${INCUS_EIGHT_DIR}" + unset INCUS_SECRET # This will cause the token to expire - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.join_token_expiry=5S - token_expired=$(LXD_DIR="${LXD_ONE_DIR}" lxc cluster add node9 | tail -n 1) + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.join_token_expiry=5S + token_expired=$(INCUS_DIR="${INCUS_ONE_DIR}" inc cluster add node9 | tail -n 1) sleep 6 # Spawn a ninth node, using join token. setup_clustering_netns 9 - LXD_NINE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_NINE_DIR}" + INCUS_NINE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_NINE_DIR}" ns9="${prefix}9" # shellcheck disable=SC2034 - LXD_SECRET="${token_expired}" - ! spawn_lxd_and_join_cluster "${ns9}" "${bridge}" "${cert}" 9 2 "${LXD_NINE_DIR}" || false - unset LXD_SECRET + INCUS_SECRET="${token_expired}" + ! spawn_incus_and_join_cluster "${ns9}" "${bridge}" "${cert}" 9 2 "${INCUS_NINE_DIR}" || false + unset INCUS_SECRET # Unset join_token_expiry which will set it to the default value of 3h - LXD_DIR="${LXD_ONE_DIR}" lxc config unset cluster.join_token_expiry - - LXD_DIR="${LXD_NINE_DIR}" lxd shutdown - LXD_DIR="${LXD_EIGHT_DIR}" lxd shutdown - LXD_DIR="${LXD_SIX_DIR}" lxd shutdown - LXD_DIR="${LXD_FIVE_DIR}" lxd shutdown - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" inc config unset cluster.join_token_expiry + + INCUS_DIR="${INCUS_NINE_DIR}" incus shutdown + INCUS_DIR="${INCUS_EIGHT_DIR}" incus shutdown + INCUS_DIR="${INCUS_SIX_DIR}" incus shutdown + INCUS_DIR="${INCUS_FIVE_DIR}" incus shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_NINE_DIR}/unix.socket" - rm -f "${LXD_EIGHT_DIR}/unix.socket" - rm -f "${LXD_SIX_DIR}/unix.socket" - rm -f "${LXD_FIVE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_NINE_DIR}/unix.socket" + rm -f "${INCUS_EIGHT_DIR}/unix.socket" + rm -f "${INCUS_SIX_DIR}/unix.socket" + rm -f "${INCUS_FIVE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" - kill_lxd "${LXD_FIVE_DIR}" - kill_lxd "${LXD_SIX_DIR}" - kill_lxd "${LXD_EIGHT_DIR}" - kill_lxd "${LXD_NINE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" + kill_incus "${INCUS_FIVE_DIR}" + kill_incus "${INCUS_SIX_DIR}" + kill_incus "${INCUS_EIGHT_DIR}" + kill_incus "${INCUS_NINE_DIR}" } test_clustering_containers() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Init a container on node2, using a client connected to node1 - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 testimage foo + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 testimage foo # The container is visible through both nodes - LXD_DIR="${LXD_ONE_DIR}" lxc list | grep foo | grep -q STOPPED - LXD_DIR="${LXD_ONE_DIR}" lxc list | grep foo | grep -q node2 - LXD_DIR="${LXD_TWO_DIR}" lxc list | grep foo | grep -q STOPPED + INCUS_DIR="${INCUS_ONE_DIR}" inc list | grep foo | grep -q STOPPED + INCUS_DIR="${INCUS_ONE_DIR}" inc list | grep foo | grep -q node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc list | grep foo | grep -q STOPPED # A Location: field indicates on which node the container is running - LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | grep -q "Location: node2" # Start the container via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc start foo - LXD_DIR="${LXD_TWO_DIR}" lxc info foo | grep -q "Status: RUNNING" - LXD_DIR="${LXD_ONE_DIR}" lxc list | grep foo | grep -q RUNNING + INCUS_DIR="${INCUS_ONE_DIR}" inc start foo + INCUS_DIR="${INCUS_TWO_DIR}" inc info foo | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_ONE_DIR}" inc list | grep foo | grep -q RUNNING # Trying to delete a node which has container results in an error - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster remove node2 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster remove node2 || false # Exec a command in the container via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc exec foo ls / | grep -q proc + INCUS_DIR="${INCUS_ONE_DIR}" inc exec foo ls / | grep -q proc # Pull, push and delete files from the container via node1 - ! LXD_DIR="${LXD_ONE_DIR}" lxc file pull foo/non-existing-file "${TEST_DIR}/non-existing-file" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc file pull foo/non-existing-file "${TEST_DIR}/non-existing-file" || false mkdir "${TEST_DIR}/hello-world" echo "hello world" > "${TEST_DIR}/hello-world/text" - LXD_DIR="${LXD_ONE_DIR}" lxc file push "${TEST_DIR}/hello-world/text" foo/hello-world-text - LXD_DIR="${LXD_ONE_DIR}" lxc file pull foo/hello-world-text "${TEST_DIR}/hello-world-text" + INCUS_DIR="${INCUS_ONE_DIR}" inc file push "${TEST_DIR}/hello-world/text" foo/hello-world-text + INCUS_DIR="${INCUS_ONE_DIR}" inc file pull foo/hello-world-text "${TEST_DIR}/hello-world-text" grep -q "hello world" "${TEST_DIR}/hello-world-text" rm "${TEST_DIR}/hello-world-text" - LXD_DIR="${LXD_ONE_DIR}" lxc file push --recursive "${TEST_DIR}/hello-world" foo/ + INCUS_DIR="${INCUS_ONE_DIR}" inc file push --recursive "${TEST_DIR}/hello-world" foo/ rm -r "${TEST_DIR}/hello-world" - LXD_DIR="${LXD_ONE_DIR}" lxc file pull --recursive foo/hello-world "${TEST_DIR}" + INCUS_DIR="${INCUS_ONE_DIR}" inc file pull --recursive foo/hello-world "${TEST_DIR}" grep -q "hello world" "${TEST_DIR}/hello-world/text" rm -r "${TEST_DIR}/hello-world" - LXD_DIR="${LXD_ONE_DIR}" lxc file delete foo/hello-world/text - ! LXD_DIR="${LXD_ONE_DIR}" lxc file pull foo/hello-world/text "${TEST_DIR}/hello-world-text" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc file delete foo/hello-world/text + ! INCUS_DIR="${INCUS_ONE_DIR}" inc file pull foo/hello-world/text "${TEST_DIR}/hello-world-text" || false # Stop the container via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc stop foo --force + INCUS_DIR="${INCUS_ONE_DIR}" inc stop foo --force # Rename the container via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc rename foo foo2 - LXD_DIR="${LXD_TWO_DIR}" lxc list | grep -q foo2 - LXD_DIR="${LXD_ONE_DIR}" lxc rename foo2 foo + INCUS_DIR="${INCUS_ONE_DIR}" inc rename foo foo2 + INCUS_DIR="${INCUS_TWO_DIR}" inc list | grep -q foo2 + INCUS_DIR="${INCUS_ONE_DIR}" inc rename foo2 foo # Show lxc.log via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info --show-log foo | grep -q Log + INCUS_DIR="${INCUS_ONE_DIR}" inc info --show-log foo | grep -q Log # Create, rename and delete a snapshot of the container via node1 - LXD_DIR="${LXD_ONE_DIR}" lxc snapshot foo foo-bak - LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q foo-bak - LXD_DIR="${LXD_ONE_DIR}" lxc rename foo/foo-bak foo/foo-bak-2 - LXD_DIR="${LXD_ONE_DIR}" lxc delete foo/foo-bak-2 - ! LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q foo-bak-2 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc snapshot foo foo-bak + INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | grep -q foo-bak + INCUS_DIR="${INCUS_ONE_DIR}" inc rename foo/foo-bak foo/foo-bak-2 + INCUS_DIR="${INCUS_ONE_DIR}" inc delete foo/foo-bak-2 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | grep -q foo-bak-2 || false # Export from node1 the image that was imported on node2 - LXD_DIR="${LXD_ONE_DIR}" lxc image export testimage "${TEST_DIR}/testimage" + INCUS_DIR="${INCUS_ONE_DIR}" inc image export testimage "${TEST_DIR}/testimage" rm "${TEST_DIR}/testimage.tar.xz" # Create a container on node1 using the image that was stored on # node2. - LXD_DIR="${LXD_TWO_DIR}" lxc launch --target node1 testimage bar - LXD_DIR="${LXD_TWO_DIR}" lxc stop bar --force - LXD_DIR="${LXD_ONE_DIR}" lxc delete bar - ! LXD_DIR="${LXD_TWO_DIR}" lxc list | grep -q bar || false + INCUS_DIR="${INCUS_TWO_DIR}" inc launch --target node1 testimage bar + INCUS_DIR="${INCUS_TWO_DIR}" inc stop bar --force + INCUS_DIR="${INCUS_ONE_DIR}" inc delete bar + ! INCUS_DIR="${INCUS_TWO_DIR}" inc list | grep -q bar || false # Create a container on node1 using a snapshot from node2. - LXD_DIR="${LXD_ONE_DIR}" lxc snapshot foo foo-bak - LXD_DIR="${LXD_TWO_DIR}" lxc copy foo/foo-bak bar --target node1 - LXD_DIR="${LXD_TWO_DIR}" lxc info bar | grep -q "Location: node1" - LXD_DIR="${LXD_THREE_DIR}" lxc delete bar + INCUS_DIR="${INCUS_ONE_DIR}" inc snapshot foo foo-bak + INCUS_DIR="${INCUS_TWO_DIR}" inc copy foo/foo-bak bar --target node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc info bar | grep -q "Location: node1" + INCUS_DIR="${INCUS_THREE_DIR}" inc delete bar # Copy the container on node2 to node3, using a client connected to # node1. - LXD_DIR="${LXD_ONE_DIR}" lxc copy foo bar --target node3 - LXD_DIR="${LXD_TWO_DIR}" lxc info bar | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc copy foo bar --target node3 + INCUS_DIR="${INCUS_TWO_DIR}" inc info bar | grep -q "Location: node3" # Move the container on node3 to node1, using a client connected to # node2 and a different container name than the original one. The # volatile.apply_template config key is preserved. - apply_template1=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get bar volatile.apply_template) + apply_template1=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get bar volatile.apply_template) - LXD_DIR="${LXD_TWO_DIR}" lxc move bar egg --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc info egg | grep -q "Location: node2" - apply_template2=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get egg volatile.apply_template) + INCUS_DIR="${INCUS_TWO_DIR}" inc move bar egg --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc info egg | grep -q "Location: node2" + apply_template2=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get egg volatile.apply_template) [ "${apply_template1}" = "${apply_template2}" ] || false # Move back to node3 the container on node1, keeping the same name. - apply_template1=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get egg volatile.apply_template) - LXD_DIR="${LXD_TWO_DIR}" lxc move egg --target node3 - LXD_DIR="${LXD_ONE_DIR}" lxc info egg | grep -q "Location: node3" - apply_template2=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get egg volatile.apply_template) + apply_template1=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get egg volatile.apply_template) + INCUS_DIR="${INCUS_TWO_DIR}" inc move egg --target node3 + INCUS_DIR="${INCUS_ONE_DIR}" inc info egg | grep -q "Location: node3" + apply_template2=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get egg volatile.apply_template) [ "${apply_template1}" = "${apply_template2}" ] || false if command -v criu >/dev/null 2>&1; then # If CRIU supported, then try doing a live move using same name, # as CRIU doesn't work when moving to a different name. - LXD_DIR="${LXD_TWO_DIR}" lxc config set egg raw.lxc=lxc.console.path=none - LXD_DIR="${LXD_TWO_DIR}" lxc start egg - LXD_DIR="${LXD_TWO_DIR}" lxc exec egg -- umount /dev/.lxd-mounts - LXD_DIR="${LXD_TWO_DIR}" lxc move egg --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info egg | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc move egg --target node3 --stateless - LXD_DIR="${LXD_TWO_DIR}" lxc stop -f egg + INCUS_DIR="${INCUS_TWO_DIR}" inc config set egg raw.lxc=lxc.console.path=none + INCUS_DIR="${INCUS_TWO_DIR}" inc start egg + INCUS_DIR="${INCUS_TWO_DIR}" inc exec egg -- umount /dev/.incus-mounts + INCUS_DIR="${INCUS_TWO_DIR}" inc move egg --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info egg | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc move egg --target node3 --stateless + INCUS_DIR="${INCUS_TWO_DIR}" inc stop -f egg fi # Create backup and attempt to move container. Move should fail and container should remain on node1. - LXD_DIR="${LXD_THREE_DIR}" lxc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/instances/egg/backups - ! LXD_DIR="${LXD_THREE_DIR}" lxc move egg --target node2 || false - LXD_DIR="${LXD_THREE_DIR}" lxc info egg | grep -q "Location: node3" + INCUS_DIR="${INCUS_THREE_DIR}" inc query -X POST --wait -d '{\"name\":\"foo\"}' /1.0/instances/egg/backups + ! INCUS_DIR="${INCUS_THREE_DIR}" inc move egg --target node2 || false + INCUS_DIR="${INCUS_THREE_DIR}" inc info egg | grep -q "Location: node3" - LXD_DIR="${LXD_THREE_DIR}" lxc delete egg + INCUS_DIR="${INCUS_THREE_DIR}" inc delete egg # Delete the network now, since we're going to shutdown node2 and it # won't be possible afterwise. - LXD_DIR="${LXD_TWO_DIR}" lxc network delete "${bridge}" + INCUS_DIR="${INCUS_TWO_DIR}" inc network delete "${bridge}" # Shutdown node 2, wait for it to be considered offline, and list # containers. - LXD_DIR="${LXD_THREE_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown sleep 12 - LXD_DIR="${LXD_ONE_DIR}" lxc list | grep foo | grep -q ERROR + INCUS_DIR="${INCUS_ONE_DIR}" inc list | grep foo | grep -q ERROR # Start a container without specifying any target. It will be placed # on node1 since node2 is offline and both node1 and node3 have zero # containers, but node1 has a lower node ID. - LXD_DIR="${LXD_THREE_DIR}" lxc launch testimage bar - LXD_DIR="${LXD_THREE_DIR}" lxc info bar | grep -q "Location: node1" + INCUS_DIR="${INCUS_THREE_DIR}" inc launch testimage bar + INCUS_DIR="${INCUS_THREE_DIR}" inc info bar | grep -q "Location: node1" # Start a container without specifying any target. It will be placed # on node3 since node2 is offline and node1 already has a container. - LXD_DIR="${LXD_THREE_DIR}" lxc launch testimage egg - LXD_DIR="${LXD_THREE_DIR}" lxc info egg | grep -q "Location: node3" + INCUS_DIR="${INCUS_THREE_DIR}" inc launch testimage egg + INCUS_DIR="${INCUS_THREE_DIR}" inc info egg | grep -q "Location: node3" - LXD_DIR="${LXD_ONE_DIR}" lxc stop egg --force - LXD_DIR="${LXD_ONE_DIR}" lxc stop bar --force + INCUS_DIR="${INCUS_ONE_DIR}" inc stop egg --force + INCUS_DIR="${INCUS_ONE_DIR}" inc stop bar --force - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } test_clustering_storage() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # The random storage backend is not supported in clustering tests, # since we need to have the same storage driver on all nodes, so use the driver chosen for the standalone pool. - poolDriver=$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}') + poolDriver=$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}') setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "${poolDriver}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "${poolDriver}" # The state of the preseeded storage pool shows up as CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep data | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep data | grep -q CREATED # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" "${poolDriver}" # The state of the preseeded storage pool is still CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep data | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep data | grep -q CREATED # Check both nodes show preseeded storage pool created. - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'data' AND nodes.name = 'node1'" | grep "| node1 | 1 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'data' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'data' AND nodes.name = 'node1'" | grep "| node1 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'data' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Trying to pass config values other than 'source' results in an error - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir source=/foo size=123 --target node1 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir source=/foo size=123 --target node1 || false # Test storage pool node state tracking using a dir pool. if [ "${poolDriver}" = "dir" ]; then # Create pending nodes. - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" --target node1 - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" --target node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 0 |" # Modify first pending node with invalid config and check it fails and all nodes are pending. - LXD_DIR="${LXD_ONE_DIR}" lxc storage set pool1 source=/tmp/not/exist --target node1 - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" || false - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage set pool1 source=/tmp/not/exist --target node1 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 0 |" # Run create on second node, so it succeeds and then fails notifying first node. - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" || false - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Check we cannot update global config while in pending state. - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage set pool1 rsync.bwlimit 10 || false - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage set pool1 rsync.bwlimit 10 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage set pool1 rsync.bwlimit 10 || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage set pool1 rsync.bwlimit 10 || false # Check can delete pending pool and created nodes are cleaned up. - LXD_DIR="${LXD_TWO_DIR}" lxc storage show pool1 --target=node2 - LXD_TWO_SOURCE="$(LXD_DIR="${LXD_TWO_DIR}" lxc storage get pool1 source --target=node2)" - stat "${LXD_TWO_SOURCE}/containers" - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1 - ! stat "${LXD_TWO_SOURCE}/containers" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc storage show pool1 --target=node2 + INCUS_TWO_SOURCE="$(INCUS_DIR="${INCUS_TWO_DIR}" inc storage get pool1 source --target=node2)" + stat "${INCUS_TWO_SOURCE}/containers" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete pool1 + ! stat "${INCUS_TWO_SOURCE}/containers" || false # Create new partially created pool and check we can fix it. - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" source=/tmp/not/exist --target node1 - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep status: | grep -q Pending - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" || false - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep status: | grep -q Errored - LXD_DIR="${LXD_ONE_DIR}" lxc storage unset pool1 source --target node1 - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" rsync.bwlimit=1000 || false # Check global config is rejected on re-create. - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" || false # Check re-create after successful create is rejected. - LXD_ONE_SOURCE="$(LXD_DIR="${LXD_ONE_DIR}" lxc storage get pool1 source --target=node1)" - LXD_TWO_SOURCE="$(LXD_DIR="${LXD_TWO_DIR}" lxc storage get pool1 source --target=node2)" - stat "${LXD_ONE_SOURCE}/containers" - stat "${LXD_TWO_SOURCE}/containers" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" source=/tmp/not/exist --target node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep status: | grep -q Pending + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep status: | grep -q Errored + INCUS_DIR="${INCUS_ONE_DIR}" inc storage unset pool1 source --target node1 + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" rsync.bwlimit=1000 || false # Check global config is rejected on re-create. + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" || false # Check re-create after successful create is rejected. + INCUS_ONE_SOURCE="$(INCUS_DIR="${INCUS_ONE_DIR}" inc storage get pool1 source --target=node1)" + INCUS_TWO_SOURCE="$(INCUS_DIR="${INCUS_TWO_DIR}" inc storage get pool1 source --target=node2)" + stat "${INCUS_ONE_SOURCE}/containers" + stat "${INCUS_TWO_SOURCE}/containers" # Check both nodes marked created. - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 1 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node1'" | grep "| node1 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,storage_pools_nodes.state FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id JOIN storage_pools ON storage_pools.id = storage_pools_nodes.storage_pool_id WHERE storage_pools.name = 'pool1' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Check copying storage volumes works. - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create pool1 vol1 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2 - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2 --refresh + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume create pool1 vol1 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2 --refresh # Delete pool and check cleaned up. - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 vol1 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 vol1 --target=node2 - LXD_DIR="${LXD_TWO_DIR}" lxc storage delete pool1 - ! stat "${LXD_ONE_SOURCE}/containers" || false - ! stat "${LXD_TWO_SOURCE}/containers" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume delete pool1 vol1 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume delete pool1 vol1 --target=node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage delete pool1 + ! stat "${INCUS_ONE_SOURCE}/containers" || false + ! stat "${INCUS_TWO_SOURCE}/containers" || false fi # Define storage pools on the two nodes @@ -680,7 +680,7 @@ test_clustering_storage() { driver_config="size=1GiB" fi if [ "${poolDriver}" = "ceph" ]; then - driver_config="source=lxdtest-$(basename "${TEST_DIR}")-pool1" + driver_config="source=incustest-$(basename "${TEST_DIR}")-pool1" fi driver_config_node1="${driver_config}" @@ -698,237 +698,237 @@ test_clustering_storage() { if [ -n "${driver_config_node1}" ]; then # shellcheck disable=SC2086 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" ${driver_config_node1} --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" ${driver_config_node1} --target node1 else - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" --target node1 fi - LXD_DIR="${LXD_TWO_DIR}" lxc storage show pool1 | grep -q node1 - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage show pool1 | grep -q node2 || false + INCUS_DIR="${INCUS_TWO_DIR}" inc storage show pool1 | grep -q node1 + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage show pool1 | grep -q node2 || false if [ -n "${driver_config_node2}" ]; then # shellcheck disable=SC2086 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" ${driver_config_node2} --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" ${driver_config_node2} --target node2 else - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" --target node2 fi - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep status: | grep -q Pending + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep status: | grep -q Pending # A container can't be created when associated with a pending pool. - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - ! LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 -s pool1 testimage bar || false - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + ! INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 -s pool1 testimage bar || false + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage # The source config key is not legal for the final pool creation if [ "${poolDriver}" = "dir" ]; then - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir source=/foo || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir source=/foo || false fi # Create the storage pool if [ "${poolDriver}" = "lvm" ]; then - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" volume.size=25MiB + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" volume.size=25MiB elif [ "${poolDriver}" = "ceph" ]; then - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" volume.size=25MiB ceph.osd.pg_num=16 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" volume.size=25MiB ceph.osd.pg_num=16 else - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 "${poolDriver}" + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 "${poolDriver}" fi - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep status: | grep -q Created + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep status: | grep -q Created # The 'source' config key is omitted when showing the cluster # configuration, and included when showing the node-specific one. - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage show pool1 | grep -q source || false - source1="$(basename "${LXD_ONE_DIR}")" - source2="$(basename "${LXD_TWO_DIR}")" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage show pool1 | grep -q source || false + source1="$(basename "${INCUS_ONE_DIR}")" + source2="$(basename "${INCUS_TWO_DIR}")" if [ "${poolDriver}" = "ceph" ]; then # For ceph volume the source field is the name of the underlying ceph pool - source1="lxdtest-$(basename "${TEST_DIR}")" + source1="incustest-$(basename "${TEST_DIR}")" source2="${source1}" fi - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 --target node1 | grep source | grep -q "${source1}" - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 --target node2 | grep source | grep -q "${source2}" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 --target node1 | grep source | grep -q "${source1}" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 --target node2 | grep source | grep -q "${source2}" # Update the storage pool if [ "${poolDriver}" = "dir" ]; then - LXD_DIR="${LXD_ONE_DIR}" lxc storage set pool1 rsync.bwlimit 10 - LXD_DIR="${LXD_TWO_DIR}" lxc storage show pool1 | grep rsync.bwlimit | grep -q 10 - LXD_DIR="${LXD_TWO_DIR}" lxc storage unset pool1 rsync.bwlimit - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep -q rsync.bwlimit || false + INCUS_DIR="${INCUS_ONE_DIR}" inc storage set pool1 rsync.bwlimit 10 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage show pool1 | grep rsync.bwlimit | grep -q 10 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage unset pool1 rsync.bwlimit + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep -q rsync.bwlimit || false fi if [ "${poolDriver}" = "ceph" ]; then # Test migration of ceph-based containers - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node2 -s pool1 testimage foo + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc launch --target node2 -s pool1 testimage foo # The container can't be moved if it's running - ! LXD_DIR="${LXD_TWO_DIR}" lxc move foo --target node1 || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc move foo --target node1 || false # Stop the container and create a snapshot - LXD_DIR="${LXD_ONE_DIR}" lxc stop foo --force - LXD_DIR="${LXD_ONE_DIR}" lxc snapshot foo snap-test + INCUS_DIR="${INCUS_ONE_DIR}" inc stop foo --force + INCUS_DIR="${INCUS_ONE_DIR}" inc snapshot foo snap-test # Move the container to node1 - LXD_DIR="${LXD_TWO_DIR}" lxc move foo --target node1 - LXD_DIR="${LXD_TWO_DIR}" lxc info foo | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info foo | grep -q "snap-test" + INCUS_DIR="${INCUS_TWO_DIR}" inc move foo --target node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc info foo | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info foo | grep -q "snap-test" # Start and stop the container on its new node1 host - LXD_DIR="${LXD_TWO_DIR}" lxc start foo - LXD_DIR="${LXD_TWO_DIR}" lxc stop foo --force + INCUS_DIR="${INCUS_TWO_DIR}" inc start foo + INCUS_DIR="${INCUS_TWO_DIR}" inc stop foo --force # Init a new container on node2 using the snapshot on node1 - LXD_DIR="${LXD_ONE_DIR}" lxc copy foo/snap-test egg --target node2 - LXD_DIR="${LXD_TWO_DIR}" lxc start egg - LXD_DIR="${LXD_ONE_DIR}" lxc stop egg --force - LXD_DIR="${LXD_ONE_DIR}" lxc delete egg + INCUS_DIR="${INCUS_ONE_DIR}" inc copy foo/snap-test egg --target node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc start egg + INCUS_DIR="${INCUS_ONE_DIR}" inc stop egg --force + INCUS_DIR="${INCUS_ONE_DIR}" inc delete egg # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" "${poolDriver}" # Move the container to node3, renaming it - LXD_DIR="${LXD_TWO_DIR}" lxc move foo bar --target node3 - LXD_DIR="${LXD_TWO_DIR}" lxc info bar | grep -q "Location: node3" - LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "snap-test" + INCUS_DIR="${INCUS_TWO_DIR}" inc move foo bar --target node3 + INCUS_DIR="${INCUS_TWO_DIR}" inc info bar | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc info bar | grep -q "snap-test" # Shutdown node 3, and wait for it to be considered offline. - LXD_DIR="${LXD_THREE_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 12 # Move the container back to node2, even if node3 is offline - LXD_DIR="${LXD_ONE_DIR}" lxc move bar --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "Location: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info bar | grep -q "snap-test" + INCUS_DIR="${INCUS_ONE_DIR}" inc move bar --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc info bar | grep -q "Location: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info bar | grep -q "snap-test" # Start and stop the container on its new node2 host - LXD_DIR="${LXD_TWO_DIR}" lxc start bar - LXD_DIR="${LXD_ONE_DIR}" lxc stop bar --force + INCUS_DIR="${INCUS_TWO_DIR}" inc start bar + INCUS_DIR="${INCUS_ONE_DIR}" inc stop bar --force - LXD_DIR="${LXD_ONE_DIR}" lxc cluster remove node3 --force --yes + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster remove node3 --force --yes - LXD_DIR="${LXD_ONE_DIR}" lxc delete bar + INCUS_DIR="${INCUS_ONE_DIR}" inc delete bar # Attach a custom volume to a container on node1 - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create pool1 v1 - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node1 -s pool1 testimage baz - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume attach pool1 custom/v1 baz testDevice /opt + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume create pool1 v1 + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node1 -s pool1 testimage baz + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume attach pool1 custom/v1 baz testDevice /opt # Trying to attach a custom volume to a container on another node fails - LXD_DIR="${LXD_TWO_DIR}" lxc init --target node2 -s pool1 testimage buz - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage volume attach pool1 custom/v1 buz testDevice /opt || false + INCUS_DIR="${INCUS_TWO_DIR}" inc init --target node2 -s pool1 testimage buz + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume attach pool1 custom/v1 buz testDevice /opt || false # Create an unrelated volume and rename it on a node which differs from the # one running the container (issue #6435). - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume create pool1 v2 - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume rename pool1 v2 v2-renamed - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume delete pool1 v2-renamed + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume create pool1 v2 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume rename pool1 v2 v2-renamed + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume delete pool1 v2-renamed - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume detach pool1 v1 baz + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume detach pool1 v1 baz - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 v1 - LXD_DIR="${LXD_ONE_DIR}" lxc delete baz - LXD_DIR="${LXD_ONE_DIR}" lxc delete buz + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume delete pool1 v1 + INCUS_DIR="${INCUS_ONE_DIR}" inc delete baz + INCUS_DIR="${INCUS_ONE_DIR}" inc delete buz - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage fi # Test migration of zfs/btrfs-based containers if [ "${poolDriver}" = "zfs" ] || [ "${poolDriver}" = "btrfs" ]; then # Launch a container on node2 - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node2 testimage foo - LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q "Location: node2" + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc launch --target node2 testimage foo + INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | grep -q "Location: node2" # Stop the container and move it to node1 - LXD_DIR="${LXD_ONE_DIR}" lxc stop foo --force - LXD_DIR="${LXD_TWO_DIR}" lxc move foo bar --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc stop foo --force + INCUS_DIR="${INCUS_TWO_DIR}" inc move foo bar --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info bar | grep -q "Location: node1" # Start and stop the migrated container on node1 - LXD_DIR="${LXD_TWO_DIR}" lxc start bar - LXD_DIR="${LXD_ONE_DIR}" lxc stop bar --force + INCUS_DIR="${INCUS_TWO_DIR}" inc start bar + INCUS_DIR="${INCUS_ONE_DIR}" inc stop bar --force # Rename the container locally on node1 - LXD_DIR="${LXD_TWO_DIR}" lxc rename bar foo - LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc rename bar foo + INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | grep -q "Location: node1" # Copy the container without specifying a target, it will be placed on node2 # since it's the one with the least number of containers (0 vs 1) sleep 6 # Wait for pending operations to be removed from the database - LXD_DIR="${LXD_ONE_DIR}" lxc copy foo bar - LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc copy foo bar + INCUS_DIR="${INCUS_ONE_DIR}" inc info bar | grep -q "Location: node2" # Start and stop the copied container on node2 - LXD_DIR="${LXD_TWO_DIR}" lxc start bar - LXD_DIR="${LXD_ONE_DIR}" lxc stop bar --force + INCUS_DIR="${INCUS_TWO_DIR}" inc start bar + INCUS_DIR="${INCUS_ONE_DIR}" inc stop bar --force # Purge the containers - LXD_DIR="${LXD_ONE_DIR}" lxc delete bar - LXD_DIR="${LXD_ONE_DIR}" lxc delete foo + INCUS_DIR="${INCUS_ONE_DIR}" inc delete bar + INCUS_DIR="${INCUS_ONE_DIR}" inc delete foo # Delete the image too. - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage fi # Delete the storage pool - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1 - ! LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep -q pool1 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete pool1 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep -q pool1 || false if [ "${poolDriver}" != "ceph" ]; then # Create a volume on node1 - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create data web - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume list data | grep web | grep -q node1 - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume list data | grep web | grep -q node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume create data web + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume list data | grep web | grep -q node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume list data | grep web | grep -q node1 # Since the volume name is unique to node1, it's possible to show, rename, # get the volume without specifying the --target parameter. - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show data web | grep -q "location: node1" - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume rename data web webbaz - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume rename data webbaz web - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume get data web size + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume show data web | grep -q "location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume rename data web webbaz + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume rename data webbaz web + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume get data web size # Create another volume on node2 with the same name of the one on # node1. - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create --target node2 data web + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume create --target node2 data web # Trying to show, rename or delete the web volume without --target # fails, because it's not unique. - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show data web || false - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage volume rename data web webbaz || false - ! LXD_DIR="${LXD_TWO_DIR}" lxc storage volume delete data web || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume show data web || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume rename data web webbaz || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume delete data web || false # Specifying the --target parameter shows, renames and deletes the # proper volume. - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show --target node1 data web | grep -q "location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show --target node2 data web | grep -q "location: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume rename --target node1 data web webbaz - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume rename --target node2 data web webbaz - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume delete --target node2 data webbaz + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume show --target node1 data web | grep -q "location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume show --target node2 data web | grep -q "location: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume rename --target node1 data web webbaz + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume rename --target node2 data web webbaz + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume delete --target node2 data webbaz # Since now there's only one volume in the pool left named webbaz, # it's possible to delete it without specifying --target. - LXD_DIR="${LXD_TWO_DIR}" lxc storage volume delete data webbaz + INCUS_DIR="${INCUS_TWO_DIR}" inc storage volume delete data webbaz fi - printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default - LXD_DIR="${LXD_TWO_DIR}" lxc storage delete data + printf 'config: {}\ndevices: {}' | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default + INCUS_DIR="${INCUS_TWO_DIR}" inc storage delete data - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - if [ -n "${LXD_THREE_DIR:-}" ]; then - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + if [ -n "${INCUS_THREE_DIR:-}" ]; then + kill_incus "${INCUS_THREE_DIR}" fi } @@ -937,21 +937,21 @@ test_clustering_storage() { # procedure for non-clustered daemons. test_clustering_storage_single_node() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # The random storage backend is not supported in clustering tests, # since we need to have the same storage driver on all nodes, so use the driver chosen for the standalone pool. - poolDriver=$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}') + poolDriver=$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}') setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "${poolDriver}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "${poolDriver}" # Create a pending storage pool on the node. driver_config="" @@ -962,7 +962,7 @@ test_clustering_storage_single_node() { driver_config="size=1GiB" fi if [ "${poolDriver}" = "ceph" ]; then - driver_config="source=lxdtest-$(basename "${TEST_DIR}")-pool1" + driver_config="source=incustest-$(basename "${TEST_DIR}")-pool1" fi driver_config_node="${driver_config}" if [ "${poolDriver}" = "zfs" ]; then @@ -971,479 +971,479 @@ test_clustering_storage_single_node() { if [ -n "${driver_config_node}" ]; then # shellcheck disable=SC2086 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" ${driver_config_node} --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" ${driver_config_node} --target node1 else - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" --target node1 fi # Finalize the storage pool creation - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" - LXD_DIR="${LXD_ONE_DIR}" lxc storage show pool1 | grep status: | grep -q Created + INCUS_DIR="${INCUS_ONE_DIR}" inc storage show pool1 | grep status: | grep -q Created # Delete the storage pool - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete pool1 # Create the storage pool directly, without the two-stage process. if [ -n "${driver_config_node}" ]; then # shellcheck disable=SC2086 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" ${driver_config_node} + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" ${driver_config_node} else - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 "${poolDriver}" + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 "${poolDriver}" fi # Delete the storage pool - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete pool1 - printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete data - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + printf 'config: {}\ndevices: {}' | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete data + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" + kill_incus "${INCUS_ONE_DIR}" } test_clustering_network() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # The state of the preseeded network shows up as CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc network list | grep "${bridge}" | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc network list | grep "${bridge}" | grep -q CREATED # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Create a project with restricted.networks.subnets set to check the default networks are created before projects # when a member joins the cluster. - LXD_DIR="${LXD_ONE_DIR}" lxc network set "${bridge}" ipv4.routes=192.0.2.0/24 - LXD_DIR="${LXD_ONE_DIR}" lxc project create foo \ + INCUS_DIR="${INCUS_ONE_DIR}" inc network set "${bridge}" ipv4.routes=192.0.2.0/24 + INCUS_DIR="${INCUS_ONE_DIR}" inc project create foo \ -c restricted=true \ -c features.networks=true \ -c restricted.networks.subnets="${bridge}":192.0.2.0/24 # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # The state of the preseeded network is still CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc network list| grep "${bridge}" | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc network list| grep "${bridge}" | grep -q CREATED # Check both nodes show network created. - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${bridge}' AND nodes.name = 'node1'" | grep "| node1 | 1 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${bridge}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${bridge}' AND nodes.name = 'node1'" | grep "| node1 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${bridge}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Trying to pass config values other than # 'bridge.external_interfaces' results in an error - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create foo ipv4.address=auto --target node1 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create foo ipv4.address=auto --target node1 || false net="${bridge}x" # Define networks on the two nodes - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node1 - LXD_DIR="${LXD_TWO_DIR}" lxc network show "${net}" | grep -q node1 - ! LXD_DIR="${LXD_TWO_DIR}" lxc network show "${net}" | grep -q node2 || false - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node2 - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node2 || false - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Pending + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc network show "${net}" | grep -q node1 + ! INCUS_DIR="${INCUS_TWO_DIR}" inc network show "${net}" | grep -q node2 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node2 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node2 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Pending # A container can't be created when its NIC is associated with a pending network. - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - ! LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 -n "${net}" testimage bar || false + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + ! INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 -n "${net}" testimage bar || false # The bridge.external_interfaces config key is not legal for the final network creation - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" bridge.external_interfaces=foo || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" bridge.external_interfaces=foo || false # Create the network - LXD_DIR="${LXD_TWO_DIR}" lxc network create "${net}" - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Created - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" --target node2 | grep status: | grep -q Created + INCUS_DIR="${INCUS_TWO_DIR}" inc network create "${net}" + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Created + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" --target node2 | grep status: | grep -q Created # FIXME: rename the network is not supported with clustering - ! LXD_DIR="${LXD_TWO_DIR}" lxc network rename "${net}" "${net}-foo" || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc network rename "${net}" "${net}-foo" || false # Delete the networks - LXD_DIR="${LXD_TWO_DIR}" lxc network delete "${net}" - LXD_DIR="${LXD_TWO_DIR}" lxc network delete "${bridge}" + INCUS_DIR="${INCUS_TWO_DIR}" inc network delete "${net}" + INCUS_DIR="${INCUS_TWO_DIR}" inc network delete "${bridge}" - LXD_PID1="$(LXD_DIR="${LXD_ONE_DIR}" lxc query /1.0 | jq .environment.server_pid)" - LXD_PID2="$(LXD_DIR="${LXD_TWO_DIR}" lxc query /1.0 | jq .environment.server_pid)" + INCUS_PID1="$(INCUS_DIR="${INCUS_ONE_DIR}" inc query /1.0 | jq .environment.server_pid)" + INCUS_PID2="$(INCUS_DIR="${INCUS_TWO_DIR}" inc query /1.0 | jq .environment.server_pid)" # Test network create partial failures. - nsenter -n -t "${LXD_PID1}" -- ip link add "${net}" type dummy # Create dummy interface to conflict with network. - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Pending # Check has pending status. + nsenter -n -t "${INCUS_PID1}" -- ip link add "${net}" type dummy # Create dummy interface to conflict with network. + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Pending # Check has pending status. # Run network create on other node1 (expect this to fail early due to existing interface). - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" || false - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Errored # Check has errored status. + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Errored # Check has errored status. # Check each node status (expect both node1 and node2 to be pending as local member running created failed first). - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 0 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 0 |" # Run network create on other node2 (still excpect to fail on node1, but expect node2 create to succeed). - ! LXD_DIR="${LXD_TWO_DIR}" lxc network create "${net}" || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc network create "${net}" || false # Check each node status (expect node1 to be pending and node2 to be created). - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 0 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 0 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Check interfaces are expected types (dummy on node1 and bridge on node2). - nsenter -n -t "${LXD_PID1}" -- ip -details link show "${net}" | grep dummy - nsenter -n -t "${LXD_PID2}" -- ip -details link show "${net}" | grep bridge + nsenter -n -t "${INCUS_PID1}" -- ip -details link show "${net}" | grep dummy + nsenter -n -t "${INCUS_PID2}" -- ip -details link show "${net}" | grep bridge # Check we cannot update network global config while in pending state on either node. - ! LXD_DIR="${LXD_ONE_DIR}" lxc network set "${net}" ipv4.dhcp false || false - ! LXD_DIR="${LXD_TWO_DIR}" lxc network set "${net}" ipv4.dhcp false || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network set "${net}" ipv4.dhcp false || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc network set "${net}" ipv4.dhcp false || false # Check we can update node-specific config on the node that has been created (and that it is applied). - nsenter -n -t "${LXD_PID2}" -- ip link add "ext-${net}" type dummy # Create dummy interface to add to bridge. - LXD_DIR="${LXD_TWO_DIR}" lxc network set "${net}" bridge.external_interfaces "ext-${net}" --target node2 - nsenter -n -t "${LXD_PID2}" -- ip link show "ext-${net}" | grep "master ${net}" + nsenter -n -t "${INCUS_PID2}" -- ip link add "ext-${net}" type dummy # Create dummy interface to add to bridge. + INCUS_DIR="${INCUS_TWO_DIR}" inc network set "${net}" bridge.external_interfaces "ext-${net}" --target node2 + nsenter -n -t "${INCUS_PID2}" -- ip link show "ext-${net}" | grep "master ${net}" # Check we can update node-specific config on the node that hasn't been created (and that only DB is updated). - nsenter -n -t "${LXD_PID1}" -- ip link add "ext-${net}" type dummy # Create dummy interface to add to bridge. - nsenter -n -t "${LXD_PID1}" -- ip address add 192.0.2.1/32 dev "ext-${net}" # Add address to prevent attach. - LXD_DIR="${LXD_ONE_DIR}" lxc network set "${net}" bridge.external_interfaces "ext-${net}" --target node1 - ! nsenter -n -t "${LXD_PID1}" -- ip link show "ext-${net}" | grep "master ${net}" || false # Don't expect to be attached. + nsenter -n -t "${INCUS_PID1}" -- ip link add "ext-${net}" type dummy # Create dummy interface to add to bridge. + nsenter -n -t "${INCUS_PID1}" -- ip address add 192.0.2.1/32 dev "ext-${net}" # Add address to prevent attach. + INCUS_DIR="${INCUS_ONE_DIR}" inc network set "${net}" bridge.external_interfaces "ext-${net}" --target node1 + ! nsenter -n -t "${INCUS_PID1}" -- ip link show "ext-${net}" | grep "master ${net}" || false # Don't expect to be attached. # Delete partially created network and check nodes that were created are cleaned up. - LXD_DIR="${LXD_ONE_DIR}" lxc network delete "${net}" - ! nsenter -n -t "${LXD_PID2}" -- ip link show "${net}" || false # Check bridge is removed. - nsenter -n -t "${LXD_PID2}" -- ip link show "ext-${net}" # Check external interface still exists. - nsenter -n -t "${LXD_PID1}" -- ip -details link show "${net}" | grep dummy # Check node1 conflict still exists. + INCUS_DIR="${INCUS_ONE_DIR}" inc network delete "${net}" + ! nsenter -n -t "${INCUS_PID2}" -- ip link show "${net}" || false # Check bridge is removed. + nsenter -n -t "${INCUS_PID2}" -- ip link show "ext-${net}" # Check external interface still exists. + nsenter -n -t "${INCUS_PID1}" -- ip -details link show "${net}" | grep dummy # Check node1 conflict still exists. # Create new partially created network and check we can fix it. - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" --target node2 - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" ipv4.address=192.0.2.1/24 ipv6.address=2001:db8::1/64|| false - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Errored # Check has errored status. - nsenter -n -t "${LXD_PID1}" -- ip link delete "${net}" # Remove conflicting interface. - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" ipv4.dhcp=false || false # Check supplying global config on re-create is blocked. - LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" # Check re-create succeeds. - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" | grep status: | grep -q Created # Check is created after fix. - nsenter -n -t "${LXD_PID1}" -- ip -details link show "${net}" | grep bridge # Check bridge exists. - nsenter -n -t "${LXD_PID2}" -- ip -details link show "${net}" | grep bridge # Check bridge exists. - ! LXD_DIR="${LXD_ONE_DIR}" lxc network create "${net}" || false # Check re-create is blocked after success. + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" --target node2 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" ipv4.address=192.0.2.1/24 ipv6.address=2001:db8::1/64|| false + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Errored # Check has errored status. + nsenter -n -t "${INCUS_PID1}" -- ip link delete "${net}" # Remove conflicting interface. + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" ipv4.dhcp=false || false # Check supplying global config on re-create is blocked. + INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" # Check re-create succeeds. + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" | grep status: | grep -q Created # Check is created after fix. + nsenter -n -t "${INCUS_PID1}" -- ip -details link show "${net}" | grep bridge # Check bridge exists. + nsenter -n -t "${INCUS_PID2}" -- ip -details link show "${net}" | grep bridge # Check bridge exists. + ! INCUS_DIR="${INCUS_ONE_DIR}" inc network create "${net}" || false # Check re-create is blocked after success. # Check both nodes marked created. - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 1 |" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node1'" | grep "| node1 | 1 |" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "SELECT nodes.name,networks_nodes.state FROM nodes JOIN networks_nodes ON networks_nodes.node_id = nodes.id JOIN networks ON networks.id = networks_nodes.network_id WHERE networks.name = '${net}' AND nodes.name = 'node2'" | grep "| node2 | 1 |" # Check instance can be connected to created network and assign static DHCP allocations. - LXD_DIR="${LXD_ONE_DIR}" lxc network show "${net}" - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node1 -n "${net}" testimage c1 - LXD_DIR="${LXD_ONE_DIR}" lxc config device set c1 eth0 ipv4.address=192.0.2.2 + INCUS_DIR="${INCUS_ONE_DIR}" inc network show "${net}" + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node1 -n "${net}" testimage c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c1 eth0 ipv4.address=192.0.2.2 # Check cannot assign static IPv6 without stateful DHCPv6 enabled. - ! LXD_DIR="${LXD_ONE_DIR}" lxc config device set c1 eth0 ipv6.address=2001:db8::2 || false - LXD_DIR="${LXD_ONE_DIR}" lxc network set "${net}" ipv6.dhcp.stateful=true - LXD_DIR="${LXD_ONE_DIR}" lxc config device set c1 eth0 ipv6.address=2001:db8::2 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c1 eth0 ipv6.address=2001:db8::2 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc network set "${net}" ipv6.dhcp.stateful=true + INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c1 eth0 ipv6.address=2001:db8::2 # Check duplicate static DHCP allocation detection is working for same server as c1. - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node1 -n "${net}" testimage c2 - ! LXD_DIR="${LXD_ONE_DIR}" lxc config device set c2 eth0 ipv4.address=192.0.2.2 || false - ! LXD_DIR="${LXD_ONE_DIR}" lxc config device set c2 eth0 ipv6.address=2001:db8::2 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node1 -n "${net}" testimage c2 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c2 eth0 ipv4.address=192.0.2.2 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c2 eth0 ipv6.address=2001:db8::2 || false # Check duplicate static DHCP allocation is allowed for instance on a different server. - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 -n "${net}" testimage c3 - LXD_DIR="${LXD_ONE_DIR}" lxc config device set c3 eth0 ipv4.address=192.0.2.2 - LXD_DIR="${LXD_ONE_DIR}" lxc config device set c3 eth0 ipv6.address=2001:db8::2 + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 -n "${net}" testimage c3 + INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c3 eth0 ipv4.address=192.0.2.2 + INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c3 eth0 ipv6.address=2001:db8::2 # Check duplicate MAC address assignment detection is working using both network and parent keys. - c1MAC=$(LXD_DIR="${LXD_ONE_DIR}" lxc config get c1 volatile.eth0.hwaddr) - ! LXD_DIR="${LXD_ONE_DIR}" lxc config device set c2 eth0 hwaddr="${c1MAC}" || false - LXD_DIR="${LXD_ONE_DIR}" lxc config device set c3 eth0 hwaddr="${c1MAC}" + c1MAC=$(INCUS_DIR="${INCUS_ONE_DIR}" inc config get c1 volatile.eth0.hwaddr) + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c2 eth0 hwaddr="${c1MAC}" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc config device set c3 eth0 hwaddr="${c1MAC}" # Check duplicate static MAC assignment detection is working for same server as c1. - LXD_DIR="${LXD_ONE_DIR}" lxc config device remove c2 eth0 - ! LXD_DIR="${LXD_ONE_DIR}" lxc config device add c2 eth0 nic hwaddr="${c1MAC}" nictype=bridged parent="${net}" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc config device remove c2 eth0 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config device add c2 eth0 nic hwaddr="${c1MAC}" nictype=bridged parent="${net}" || false # Check duplicate static MAC assignment is allowed for instance on a different server. - LXD_DIR="${LXD_ONE_DIR}" lxc config device remove c3 eth0 - LXD_DIR="${LXD_ONE_DIR}" lxc config device add c3 eth0 nic hwaddr="${c1MAC}" nictype=bridged parent="${net}" + INCUS_DIR="${INCUS_ONE_DIR}" inc config device remove c3 eth0 + INCUS_DIR="${INCUS_ONE_DIR}" inc config device add c3 eth0 nic hwaddr="${c1MAC}" nictype=bridged parent="${net}" # Cleanup instances and image. - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 c2 c3 - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 c2 c3 + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage # Delete network. - LXD_DIR="${LXD_ONE_DIR}" lxc network delete "${net}" - ! nsenter -n -t "${LXD_PID1}" -- ip link show "${net}" || false # Check bridge is removed. - ! nsenter -n -t "${LXD_PID2}" -- ip link show "${net}" || false # Check bridge is removed. + INCUS_DIR="${INCUS_ONE_DIR}" inc network delete "${net}" + ! nsenter -n -t "${INCUS_PID1}" -- ip link show "${net}" || false # Check bridge is removed. + ! nsenter -n -t "${INCUS_PID2}" -- ip link show "${net}" || false # Check bridge is removed. - LXD_DIR="${LXD_ONE_DIR}" lxc project delete foo + INCUS_DIR="${INCUS_ONE_DIR}" inc project delete foo - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } # Perform an upgrade of a 2-member cluster, then a join a third member and # perform one more upgrade test_clustering_upgrade() { # shellcheck disable=2039,3043 - local LXD_DIR LXD_NETNS + local INCUS_DIR INCUS_NETNS setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # First, test the upgrade with a 2-node cluster setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Respawn the second node, making it believe it has an higher # version than it actually has. - export LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS=1 - shutdown_lxd "${LXD_TWO_DIR}" - LXD_NETNS="${ns2}" respawn_lxd "${LXD_TWO_DIR}" false + export INCUS_ARTIFICIALLY_BUMP_API_EXTENSIONS=1 + shutdown_incus "${INCUS_TWO_DIR}" + INCUS_NETNS="${ns2}" respawn_incus "${INCUS_TWO_DIR}" false # The second daemon is blocked waiting for the other to be upgraded - ! LXD_DIR="${LXD_TWO_DIR}" lxd waitready --timeout=5 || false + ! INCUS_DIR="${INCUS_TWO_DIR}" incus waitready --timeout=5 || false - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "message: Fully operational" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "message: waiting for other nodes to be upgraded" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "message: Fully operational" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "message: waiting for other nodes to be upgraded" # Respawn the first node, so it matches the version the second node # believes to have. - shutdown_lxd "${LXD_ONE_DIR}" - LXD_NETNS="${ns1}" respawn_lxd "${LXD_ONE_DIR}" true + shutdown_incus "${INCUS_ONE_DIR}" + INCUS_NETNS="${ns1}" respawn_incus "${INCUS_ONE_DIR}" true # The second daemon has now unblocked - LXD_DIR="${LXD_TWO_DIR}" lxd waitready --timeout=30 + INCUS_DIR="${INCUS_TWO_DIR}" incus waitready --timeout=30 # The cluster is again operational - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q "OFFLINE" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q "OFFLINE" || false # Now spawn a third node and test the upgrade with a 3-node cluster. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Respawn the second node, making it believe it has an higher # version than it actually has. - export LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS=2 - shutdown_lxd "${LXD_TWO_DIR}" - LXD_NETNS="${ns2}" respawn_lxd "${LXD_TWO_DIR}" false + export INCUS_ARTIFICIALLY_BUMP_API_EXTENSIONS=2 + shutdown_incus "${INCUS_TWO_DIR}" + INCUS_NETNS="${ns2}" respawn_incus "${INCUS_TWO_DIR}" false # The second daemon is blocked waiting for the other two to be # upgraded - ! LXD_DIR="${LXD_TWO_DIR}" lxd waitready --timeout=5 || false + ! INCUS_DIR="${INCUS_TWO_DIR}" incus waitready --timeout=5 || false - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "message: Fully operational" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "message: waiting for other nodes to be upgraded" - LXD_DIR="${LXD_THREE_DIR}" lxc cluster show node3 | grep -q "message: Fully operational" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "message: Fully operational" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "message: waiting for other nodes to be upgraded" + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster show node3 | grep -q "message: Fully operational" # Respawn the first node and third node, so they match the version # the second node believes to have. - shutdown_lxd "${LXD_ONE_DIR}" - LXD_NETNS="${ns1}" respawn_lxd "${LXD_ONE_DIR}" false - shutdown_lxd "${LXD_THREE_DIR}" - LXD_NETNS="${ns3}" respawn_lxd "${LXD_THREE_DIR}" true + shutdown_incus "${INCUS_ONE_DIR}" + INCUS_NETNS="${ns1}" respawn_incus "${INCUS_ONE_DIR}" false + shutdown_incus "${INCUS_THREE_DIR}" + INCUS_NETNS="${ns3}" respawn_incus "${INCUS_THREE_DIR}" true # The cluster is again operational - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q "OFFLINE" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q "OFFLINE" || false - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } # Perform an upgrade of an 8-member cluster. test_clustering_upgrade_large() { # shellcheck disable=2039,3043 - local LXD_DIR LXD_NETNS N + local INCUS_DIR INCUS_NETNS N setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" - LXD_CLUSTER_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + INCUS_CLUSTER_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) N=8 setup_clustering_netns 1 - LXD_ONE_DIR="${LXD_CLUSTER_DIR}/1" - mkdir -p "${LXD_ONE_DIR}" - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR="${INCUS_CLUSTER_DIR}/1" + mkdir -p "${INCUS_ONE_DIR}" + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") for i in $(seq 2 "${N}"); do setup_clustering_netns "${i}" - LXD_ITH_DIR="${LXD_CLUSTER_DIR}/${i}" - mkdir -p "${LXD_ITH_DIR}" - chmod +x "${LXD_ITH_DIR}" + INCUS_ITH_DIR="${INCUS_CLUSTER_DIR}/${i}" + mkdir -p "${INCUS_ITH_DIR}" + chmod +x "${INCUS_ITH_DIR}" nsi="${prefix}${i}" - spawn_lxd_and_join_cluster "${nsi}" "${bridge}" "${cert}" "${i}" 1 "${LXD_ITH_DIR}" + spawn_incus_and_join_cluster "${nsi}" "${bridge}" "${cert}" "${i}" 1 "${INCUS_ITH_DIR}" done # Respawn all nodes in sequence, as if their version had been upgrade. - export LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS=1 + export INCUS_ARTIFICIALLY_BUMP_API_EXTENSIONS=1 for i in $(seq "${N}" -1 1); do - shutdown_lxd "${LXD_CLUSTER_DIR}/${i}" - LXD_NETNS="${prefix}${i}" respawn_lxd "${LXD_CLUSTER_DIR}/${i}" false + shutdown_incus "${INCUS_CLUSTER_DIR}/${i}" + INCUS_NETNS="${prefix}${i}" respawn_incus "${INCUS_CLUSTER_DIR}/${i}" false done - LXD_DIR="${LXD_ONE_DIR}" lxd waitready --timeout=10 - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q "OFFLINE" || false + INCUS_DIR="${INCUS_ONE_DIR}" incus waitready --timeout=10 + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q "OFFLINE" || false for i in $(seq "${N}" -1 1); do - LXD_DIR="${LXD_CLUSTER_DIR}/${i}" lxd shutdown + INCUS_DIR="${INCUS_CLUSTER_DIR}/${i}" incus shutdown done sleep 0.5 for i in $(seq "${N}"); do - rm -f "${LXD_CLUSTER_DIR}/${i}/unix.socket" + rm -f "${INCUS_CLUSTER_DIR}/${i}/unix.socket" done teardown_clustering_netns teardown_clustering_bridge for i in $(seq "${N}"); do - kill_lxd "${LXD_CLUSTER_DIR}/${i}" + kill_incus "${INCUS_CLUSTER_DIR}/${i}" done } test_clustering_publish() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" - # Give LXD a couple of seconds to get event API connected properly + # Give Incus a couple of seconds to get event API connected properly sleep 2 # Init a container on node2, using a client connected to node1 - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 testimage foo + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 testimage foo - LXD_DIR="${LXD_ONE_DIR}" lxc publish foo --alias=foo-image - LXD_DIR="${LXD_ONE_DIR}" lxc image show foo-image | grep -q "public: false" - LXD_DIR="${LXD_TWO_DIR}" lxc image delete foo-image + INCUS_DIR="${INCUS_ONE_DIR}" inc publish foo --alias=foo-image + INCUS_DIR="${INCUS_ONE_DIR}" inc image show foo-image | grep -q "public: false" + INCUS_DIR="${INCUS_TWO_DIR}" inc image delete foo-image - LXD_DIR="${LXD_TWO_DIR}" lxc snapshot foo backup - LXD_DIR="${LXD_ONE_DIR}" lxc publish foo/backup --alias=foo-backup-image - LXD_DIR="${LXD_ONE_DIR}" lxc image show foo-backup-image | grep -q "public: false" + INCUS_DIR="${INCUS_TWO_DIR}" inc snapshot foo backup + INCUS_DIR="${INCUS_ONE_DIR}" inc publish foo/backup --alias=foo-backup-image + INCUS_DIR="${INCUS_ONE_DIR}" inc image show foo-backup-image | grep -q "public: false" - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_profiles() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Create an empty profile. - LXD_DIR="${LXD_TWO_DIR}" lxc profile create web + INCUS_DIR="${INCUS_TWO_DIR}" inc profile create web # Launch two containers on the two nodes, using the above profile. - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage # TODO: Fix known race in importing small images that complete before event listener is setup. sleep 2 - LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node1 -p default -p web testimage c1 - LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node2 -p default -p web testimage c2 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch --target node1 -p default -p web testimage c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch --target node2 -p default -p web testimage c2 # Edit the profile. source=$(mktemp -d -p "${TEST_DIR}" XXX) @@ -1464,298 +1464,298 @@ used_by: - /1.0/instances/c1 - /1.0/instances/c2 EOF - ) | LXD_DIR="${LXD_TWO_DIR}" lxc profile edit web + ) | INCUS_DIR="${INCUS_TWO_DIR}" inc profile edit web - LXD_DIR="${LXD_TWO_DIR}" lxc exec c1 ls /mnt | grep -q hello - LXD_DIR="${LXD_TWO_DIR}" lxc exec c2 ls /mnt | grep -q hello + INCUS_DIR="${INCUS_TWO_DIR}" inc exec c1 ls /mnt | grep -q hello + INCUS_DIR="${INCUS_TWO_DIR}" inc exec c2 ls /mnt | grep -q hello - LXD_DIR="${LXD_TWO_DIR}" lxc stop c1 --force - LXD_DIR="${LXD_ONE_DIR}" lxc stop c2 --force + INCUS_DIR="${INCUS_TWO_DIR}" inc stop c1 --force + INCUS_DIR="${INCUS_ONE_DIR}" inc stop c2 --force - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_update_cert() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # Bootstrap a node to steal its certs setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" cert_path=$(mktemp -p "${TEST_DIR}" XXX) key_path=$(mktemp -p "${TEST_DIR}" XXX) # Save the certs - cp "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" - cp "${LXD_ONE_DIR}/cluster.key" "${key_path}" + cp "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" + cp "${INCUS_ONE_DIR}/cluster.key" "${key_path}" # Tear down the instance - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" + kill_incus "${INCUS_ONE_DIR}" # Set up again setup_clustering_bridge # Bootstrap the first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # quick check - ! cmp -s "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" || false - ! cmp -s "${LXD_ONE_DIR}/cluster.key" "${key_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.key" "${key_path}" || false # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Send update request - LXD_DIR="${LXD_ONE_DIR}" lxc cluster update-cert "${cert_path}" "${key_path}" -q + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster update-cert "${cert_path}" "${key_path}" -q - cmp -s "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" || false - cmp -s "${LXD_TWO_DIR}/cluster.crt" "${cert_path}" || false + cmp -s "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" || false + cmp -s "${INCUS_TWO_DIR}/cluster.crt" "${cert_path}" || false - cmp -s "${LXD_ONE_DIR}/cluster.key" "${key_path}" || false - cmp -s "${LXD_TWO_DIR}/cluster.key" "${key_path}" || false + cmp -s "${INCUS_ONE_DIR}/cluster.key" "${key_path}" || false + cmp -s "${INCUS_TWO_DIR}/cluster.key" "${key_path}" || false - LXD_DIR="${LXD_ONE_DIR}" lxc info --target node2 | grep -q "server_name: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_update_cert_reversion() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # Bootstrap a node to steal its certs setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" cert_path=$(mktemp -p "${TEST_DIR}" XXX) key_path=$(mktemp -p "${TEST_DIR}" XXX) # Save the certs - cp "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" - cp "${LXD_ONE_DIR}/cluster.key" "${key_path}" + cp "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" + cp "${INCUS_ONE_DIR}/cluster.key" "${key_path}" # Tear down the instance - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" + kill_incus "${INCUS_ONE_DIR}" # Set up again setup_clustering_bridge # Bootstrap the first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # quick check - ! cmp -s "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" || false - ! cmp -s "${LXD_ONE_DIR}/cluster.key" "${key_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.key" "${key_path}" || false # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Shutdown third node - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - kill_lxd "${LXD_THREE_DIR}" + rm -f "${INCUS_THREE_DIR}/unix.socket" + kill_incus "${INCUS_THREE_DIR}" # Send update request - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster update-cert "${cert_path}" "${key_path}" -q || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster update-cert "${cert_path}" "${key_path}" -q || false - ! cmp -s "${LXD_ONE_DIR}/cluster.crt" "${cert_path}" || false - ! cmp -s "${LXD_TWO_DIR}/cluster.crt" "${cert_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.crt" "${cert_path}" || false + ! cmp -s "${INCUS_TWO_DIR}/cluster.crt" "${cert_path}" || false - ! cmp -s "${LXD_ONE_DIR}/cluster.key" "${key_path}" || false - ! cmp -s "${LXD_TWO_DIR}/cluster.key" "${key_path}" || false + ! cmp -s "${INCUS_ONE_DIR}/cluster.key" "${key_path}" || false + ! cmp -s "${INCUS_TWO_DIR}/cluster.key" "${key_path}" || false - LXD_DIR="${LXD_ONE_DIR}" lxc info --target node2 | grep -q "server_name: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_ONE_DIR}" lxc warning list | grep -q "Unable to update cluster certificate" + INCUS_DIR="${INCUS_ONE_DIR}" inc warning list | grep -q "Unable to update cluster certificate" - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_join_api() { # shellcheck disable=2039,2034,3043 - local LXD_DIR LXD_NETNS + local INCUS_DIR INCUS_NETNS setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" - cert=$(sed ':a;N;$!ba;s/\n/\\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\\n/g' "${INCUS_ONE_DIR}/cluster.crt") setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - LXD_NETNS="${ns2}" spawn_lxd "${LXD_TWO_DIR}" false + INCUS_NETNS="${ns2}" spawn_incus "${INCUS_TWO_DIR}" false - op=$(curl --unix-socket "${LXD_TWO_DIR}/unix.socket" -X PUT "lxd/1.0/cluster" -d "{\"server_name\":\"node2\",\"enabled\":true,\"member_config\":[{\"entity\": \"storage-pool\",\"name\":\"data\",\"key\":\"source\",\"value\":\"\"}],\"server_address\":\"10.1.1.102:8443\",\"cluster_address\":\"10.1.1.101:8443\",\"cluster_certificate\":\"${cert}\",\"cluster_password\":\"sekret\"}" | jq -r .operation) - curl --unix-socket "${LXD_TWO_DIR}/unix.socket" "lxd${op}/wait" + op=$(curl --unix-socket "${INCUS_TWO_DIR}/unix.socket" -X PUT "incus/1.0/cluster" -d "{\"server_name\":\"node2\",\"enabled\":true,\"member_config\":[{\"entity\": \"storage-pool\",\"name\":\"data\",\"key\":\"source\",\"value\":\"\"}],\"server_address\":\"10.1.1.102:8443\",\"cluster_address\":\"10.1.1.101:8443\",\"cluster_certificate\":\"${cert}\",\"cluster_password\":\"sekret\"}" | jq -r .operation) + curl --unix-socket "${INCUS_TWO_DIR}/unix.socket" "incus${op}/wait" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "message: Fully operational" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "message: Fully operational" - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" } test_clustering_shutdown_nodes() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Init a container on node1, using a client connected to node1 - LXD_DIR="${LXD_ONE_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node1 testimage foo + INCUS_DIR="${INCUS_ONE_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc launch --target node1 testimage foo # Get container PID - instance_pid=$(LXD_DIR="${LXD_ONE_DIR}" lxc info foo | awk '/^PID:/ {print $2}') + instance_pid=$(INCUS_DIR="${INCUS_ONE_DIR}" inc info foo | awk '/^PID:/ {print $2}') # Get server PIDs - daemon_pid1=$(LXD_DIR="${LXD_ONE_DIR}" lxc info | awk '/server_pid/{print $2}') - daemon_pid2=$(LXD_DIR="${LXD_TWO_DIR}" lxc info | awk '/server_pid/{print $2}') - daemon_pid3=$(LXD_DIR="${LXD_THREE_DIR}" lxc info | awk '/server_pid/{print $2}') + daemon_pid1=$(INCUS_DIR="${INCUS_ONE_DIR}" inc info | awk '/server_pid/{print $2}') + daemon_pid2=$(INCUS_DIR="${INCUS_TWO_DIR}" inc info | awk '/server_pid/{print $2}') + daemon_pid3=$(INCUS_DIR="${INCUS_THREE_DIR}" inc info | awk '/server_pid/{print $2}') - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown wait "${daemon_pid2}" - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown wait "${daemon_pid3}" # Wait for raft election to take place and become aware that quorum has been lost (should take 3-6s). sleep 10 # Make sure the database is not available to the first node - ! LXD_DIR="${LXD_ONE_DIR}" timeout -k 5 5 lxc cluster ls || false + ! INCUS_DIR="${INCUS_ONE_DIR}" timeout -k 5 5 inc cluster ls || false - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown - # Wait for LXD to terminate, otherwise the db will not be empty, and the + # Wait for Incus to terminate, otherwise the db will not be empty, and the # cleanup code will fail wait "${daemon_pid1}" @@ -1765,207 +1765,207 @@ test_clustering_shutdown_nodes() { teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_THREE_DIR}" } test_clustering_projects() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Create a test project - LXD_DIR="${LXD_ONE_DIR}" lxc project create p1 - LXD_DIR="${LXD_ONE_DIR}" lxc project switch p1 - LXD_DIR="${LXD_ONE_DIR}" lxc profile device add default root disk path="/" pool="data" + INCUS_DIR="${INCUS_ONE_DIR}" inc project create p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc project switch p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc profile device add default root disk path="/" pool="data" # Create a container in the project. - LXD_DIR="${LXD_ONE_DIR}" deps/import-busybox --project p1 --alias testimage - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node2 testimage c1 + INCUS_DIR="${INCUS_ONE_DIR}" deps/import-busybox --project p1 --alias testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node2 testimage c1 # The container is visible through both nodes - LXD_DIR="${LXD_ONE_DIR}" lxc list | grep -q c1 - LXD_DIR="${LXD_TWO_DIR}" lxc list | grep -q c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc list | grep -q c1 + INCUS_DIR="${INCUS_TWO_DIR}" inc list | grep -q c1 - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 # Remove the image file and DB record from node1. - rm "${LXD_ONE_DIR}"/images/* - LXD_DIR="${LXD_TWO_DIR}" lxd sql global 'delete from images_nodes where node_id = 1' + rm "${INCUS_ONE_DIR}"/images/* + INCUS_DIR="${INCUS_TWO_DIR}" incus sql global 'delete from images_nodes where node_id = 1' # Check image import from node2 by creating container on node1 in other project. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc init --target node1 testimage c2 --project p1 - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c2 --project p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc init --target node1 testimage c2 --project p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c2 --project p1 - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage - LXD_DIR="${LXD_ONE_DIR}" lxc project switch default + INCUS_DIR="${INCUS_ONE_DIR}" inc project switch default - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_address() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" # Bootstrap the first node using a custom cluster port - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "dir" "8444" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "dir" "8444" # The bootstrap node appears in the list with its cluster-specific port - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q 8444 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "database: true" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q 8444 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "database: true" # Add a remote using the core.https_address of the bootstrap node, and check # that the REST API is exposed. url="https://10.1.1.101:8443" - lxc remote add cluster --password sekret --accept-certificate "${url}" - lxc storage list cluster: | grep -q data + inc remote add cluster --password sekret --accept-certificate "${url}" + inc storage list cluster: | grep -q data # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node using a custom cluster port setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" "dir" "8444" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" "dir" "8444" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q node2 - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node2 | grep -q "database: true" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node2 | grep -q "database: true" # The new node appears with its custom cluster port - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep ^url | grep -q 8444 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep ^url | grep -q 8444 # The core.https_address config value can be changed and the REST API is still # accessible. - LXD_DIR="${LXD_ONE_DIR}" lxc config set "core.https_address" 10.1.1.101:9999 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set "core.https_address" 10.1.1.101:9999 url="https://10.1.1.101:9999" - lxc remote set-url cluster "${url}" - lxc storage list cluster:| grep -q data + inc remote set-url cluster "${url}" + inc storage list cluster:| grep -q data # The cluster.https_address config value can't be changed. - ! LXD_DIR="${LXD_ONE_DIR}" lxc config set "cluster.https_address" "10.1.1.101:8448" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc config set "cluster.https_address" "10.1.1.101:8448" || false # Create a container using the REST API exposed over core.https_address. - LXD_DIR="${LXD_ONE_DIR}" deps/import-busybox --alias testimage - lxc init --target node2 testimage cluster:c1 - lxc list cluster: | grep -q c1 + INCUS_DIR="${INCUS_ONE_DIR}" deps/import-busybox --alias testimage + inc init --target node2 testimage cluster:c1 + inc list cluster: | grep -q c1 # The core.https_address config value can be set to a wildcard address if # the port is the same as cluster.https_address. - LXD_DIR="${LXD_ONE_DIR}" lxc config set "core.https_address" "0.0.0.0:8444" + INCUS_DIR="${INCUS_ONE_DIR}" inc config set "core.https_address" "0.0.0.0:8444" - LXD_DIR="${LXD_TWO_DIR}" lxc delete c1 + INCUS_DIR="${INCUS_TWO_DIR}" inc delete c1 - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" - lxc remote remove cluster + inc remote remove cluster teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_image_replication() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Image replication will be performed across all nodes in the cluster by default - images_minimal_replica1=$(LXD_DIR="${LXD_ONE_DIR}" lxc config get cluster.images_minimal_replica) - images_minimal_replica2=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get cluster.images_minimal_replica) + images_minimal_replica1=$(INCUS_DIR="${INCUS_ONE_DIR}" inc config get cluster.images_minimal_replica) + images_minimal_replica2=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get cluster.images_minimal_replica) [ "$images_minimal_replica1" = "" ] || false [ "$images_minimal_replica2" = "" ] || false # Import the test image on node1 - LXD_DIR="${LXD_ONE_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" ensure_import_testimage # The image is visible through both nodes - LXD_DIR="${LXD_ONE_DIR}" lxc image list | grep -q testimage - LXD_DIR="${LXD_TWO_DIR}" lxc image list | grep -q testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image list | grep -q testimage + INCUS_DIR="${INCUS_TWO_DIR}" inc image list | grep -q testimage # The image tarball is available on both nodes - fingerprint=$(LXD_DIR="${LXD_ONE_DIR}" lxc image info testimage | awk '/^Fingerprint/ {print $2}') - [ -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false + fingerprint=$(INCUS_DIR="${INCUS_ONE_DIR}" inc image info testimage | awk '/^Fingerprint/ {print $2}') + [ -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Wait for the test image to be synced into the joined node on the background retries=10 while [ "${retries}" != "0" ]; do - if [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ]; then + if [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ]; then sleep 0.5 retries=$((retries-1)) continue @@ -1979,113 +1979,113 @@ test_clustering_image_replication() { fi # Delete the imported image - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Import the test image on node3 - LXD_DIR="${LXD_THREE_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_THREE_DIR}" ensure_import_testimage # The image is visible through all three nodes - LXD_DIR="${LXD_ONE_DIR}" lxc image list | grep -q testimage - LXD_DIR="${LXD_TWO_DIR}" lxc image list | grep -q testimage - LXD_DIR="${LXD_THREE_DIR}" lxc image list | grep -q testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image list | grep -q testimage + INCUS_DIR="${INCUS_TWO_DIR}" inc image list | grep -q testimage + INCUS_DIR="${INCUS_THREE_DIR}" inc image list | grep -q testimage # The image tarball is available on all three nodes - fingerprint=$(LXD_DIR="${LXD_ONE_DIR}" lxc image info testimage | awk '/^Fingerprint/ {print $2}') - [ -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + fingerprint=$(INCUS_DIR="${INCUS_ONE_DIR}" inc image info testimage | awk '/^Fingerprint/ {print $2}') + [ -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Delete the imported image - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Import the image from the container - LXD_DIR="${LXD_ONE_DIR}" ensure_import_testimage - lxc launch testimage c1 + INCUS_DIR="${INCUS_ONE_DIR}" ensure_import_testimage + inc launch testimage c1 # Modify the container's rootfs and create a new image from the container - lxc exec c1 -- touch /a - lxc stop c1 --force - lxc publish c1 --alias new-image + inc exec c1 -- touch /a + inc stop c1 --force + inc publish c1 --alias new-image - fingerprint=$(LXD_DIR="${LXD_ONE_DIR}" lxc image info new-image | awk '/^Fingerprint/ {print $2}') - [ -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + fingerprint=$(INCUS_DIR="${INCUS_ONE_DIR}" inc image info new-image | awk '/^Fingerprint/ {print $2}') + [ -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Delete the imported image - LXD_DIR="${LXD_TWO_DIR}" lxc image delete new-image - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + INCUS_DIR="${INCUS_TWO_DIR}" inc image delete new-image + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Delete the container - lxc delete c1 + inc delete c1 # Delete the imported image - fingerprint=$(LXD_DIR="${LXD_ONE_DIR}" lxc image info testimage | awk '/^Fingerprint/ {print $2}') - LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + fingerprint=$(INCUS_DIR="${INCUS_ONE_DIR}" inc image info testimage | awk '/^Fingerprint/ {print $2}') + INCUS_DIR="${INCUS_ONE_DIR}" inc image delete testimage + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Disable the image replication - LXD_DIR="${LXD_TWO_DIR}" lxc config set cluster.images_minimal_replica 1 - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -q 'cluster.images_minimal_replica: "1"' - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -q 'cluster.images_minimal_replica: "1"' - LXD_DIR="${LXD_THREE_DIR}" lxc info | grep -q 'cluster.images_minimal_replica: "1"' + INCUS_DIR="${INCUS_TWO_DIR}" inc config set cluster.images_minimal_replica 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -q 'cluster.images_minimal_replica: "1"' + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -q 'cluster.images_minimal_replica: "1"' + INCUS_DIR="${INCUS_THREE_DIR}" inc info | grep -q 'cluster.images_minimal_replica: "1"' # Import the test image on node2 - LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_TWO_DIR}" ensure_import_testimage # The image is visible through all three nodes - LXD_DIR="${LXD_ONE_DIR}" lxc image list | grep -q testimage - LXD_DIR="${LXD_TWO_DIR}" lxc image list | grep -q testimage - LXD_DIR="${LXD_THREE_DIR}" lxc image list | grep -q testimage + INCUS_DIR="${INCUS_ONE_DIR}" inc image list | grep -q testimage + INCUS_DIR="${INCUS_TWO_DIR}" inc image list | grep -q testimage + INCUS_DIR="${INCUS_THREE_DIR}" inc image list | grep -q testimage # The image tarball is only available on node2 - fingerprint=$(LXD_DIR="${LXD_TWO_DIR}" lxc image info testimage | awk '/^Fingerprint/ {print $2}') - [ -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false + fingerprint=$(INCUS_DIR="${INCUS_TWO_DIR}" inc image info testimage | awk '/^Fingerprint/ {print $2}') + [ -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false # Delete the imported image - LXD_DIR="${LXD_TWO_DIR}" lxc image delete testimage - [ ! -f "${LXD_ONE_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_TWO_DIR}/images/${fingerprint}" ] || false - [ ! -f "${LXD_THREE_DIR}/images/${fingerprint}" ] || false - - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" inc image delete testimage + [ ! -f "${INCUS_ONE_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_TWO_DIR}/images/${fingerprint}" ] || false + [ ! -f "${INCUS_THREE_DIR}/images/${fingerprint}" ] || false + + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } test_clustering_dns() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR # Because we do not want tests to only run on Ubuntu (due to cluster's fan network dependency) # instead we will just spawn forkdns directly and check DNS resolution. # shellcheck disable=SC2031 - lxdDir="${LXD_DIR}" - prefix="lxd$$" + incusDir="${INCUS_DIR}" + prefix="inc$$" ipRand=$(shuf -i 0-9 -n 1) # Create first dummy interface for forkdns @@ -2094,10 +2094,10 @@ test_clustering_dns() { ip a add 127.0.1.1"${ipRand}"/32 dev "${prefix}1" # Create forkdns config directory - mkdir "${lxdDir}"/networks/lxdtest1/forkdns.servers -p + mkdir "${incusDir}"/networks/inctest1/forkdns.servers -p # Launch forkdns (we expect syslog error about missing servers.conf file) - lxd forkdns 127.0.1.1"${ipRand}":1053 lxd lxdtest1 & + incus forkdns 127.0.1.1"${ipRand}":1053 incus inctest1 & forkdns_pid1=$! # Create first dummy interface for forkdns @@ -2106,44 +2106,44 @@ test_clustering_dns() { ip a add 127.0.1.2"${ipRand}"/32 dev "${prefix}2" # Create forkdns config directory - mkdir "${lxdDir}"/networks/lxdtest2/forkdns.servers -p + mkdir "${incusDir}"/networks/inctest2/forkdns.servers -p # Launch forkdns (we expect syslog error about missing servers.conf file) - lxd forkdns 127.0.1.2"${ipRand}":1053 lxd lxdtest2 & + incus forkdns 127.0.1.2"${ipRand}":1053 incus inctest2 & forkdns_pid2=$! # Let the processes come up sleep 1 # Create servers list file for forkdns1 pointing at forkdns2 (should be live reloaded) - echo "127.0.1.2${ipRand}" > "${lxdDir}"/networks/lxdtest1/forkdns.servers/servers.conf.tmp - mv "${lxdDir}"/networks/lxdtest1/forkdns.servers/servers.conf.tmp "${lxdDir}"/networks/lxdtest1/forkdns.servers/servers.conf + echo "127.0.1.2${ipRand}" > "${incusDir}"/networks/inctest1/forkdns.servers/servers.conf.tmp + mv "${incusDir}"/networks/inctest1/forkdns.servers/servers.conf.tmp "${incusDir}"/networks/inctest1/forkdns.servers/servers.conf # Create fake DHCP lease file on forkdns2 network - echo "$(date +%s) 00:16:3e:98:05:40 10.140.78.145 test1 ff:2b:a8:0a:df:00:02:00:00:ab:11:36:ea:11:e5:37:e0:85:45" > "${lxdDir}"/networks/lxdtest2/dnsmasq.leases + echo "$(date +%s) 00:16:3e:98:05:40 10.140.78.145 test1 ff:2b:a8:0a:df:00:02:00:00:ab:11:36:ea:11:e5:37:e0:85:45" > "${incusDir}"/networks/inctest2/dnsmasq.leases # Test querying forkdns1 for A record that is on forkdns2 network - if ! dig @127.0.1.1"${ipRand}" -p1053 test1.lxd | grep "10.140.78.145" ; then - echo "test1.lxd A DNS resolution failed" + if ! dig @127.0.1.1"${ipRand}" -p1053 test1.incus | grep "10.140.78.145" ; then + echo "test1.incus A DNS resolution failed" false fi # Test querying forkdns1 for AAAA record when equivalent A record is on forkdns2 network - if ! dig @127.0.1.1"${ipRand}" -p1053 AAAA test1.lxd | grep "status: NOERROR" ; then - echo "test1.lxd empty AAAAA DNS resolution failed" + if ! dig @127.0.1.1"${ipRand}" -p1053 AAAA test1.incus | grep "status: NOERROR" ; then + echo "test1.incus empty AAAAA DNS resolution failed" false fi # Test querying forkdns1 for PTR record that is on forkdns2 network - if ! dig @127.0.1.1"${ipRand}" -p1053 -x 10.140.78.145 | grep "test1.lxd" ; then + if ! dig @127.0.1.1"${ipRand}" -p1053 -x 10.140.78.145 | grep "test1.incus" ; then echo "10.140.78.145 PTR DNS resolution failed" false fi # Test querying forkdns1 for A record that is on forkdns2 network with recursion disabled to # ensure request isn't relayed - if ! dig @127.0.1.1"${ipRand}" -p1053 +norecurse test1.lxd | grep "NXDOMAIN" ; then - echo "test1.lxd A norecurse didnt return NXDOMAIN" + if ! dig @127.0.1.1"${ipRand}" -p1053 +norecurse test1.incus | grep "NXDOMAIN" ; then + echo "test1.incus A norecurse didnt return NXDOMAIN" false fi @@ -2163,168 +2163,168 @@ test_clustering_dns() { test_clustering_recover() { # shellcheck disable=2039,2034,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Wait a bit for raft roles to update. sleep 5 # Check the current database nodes - LXD_DIR="${LXD_ONE_DIR}" lxd cluster list-database | grep -q "10.1.1.101:8443" - LXD_DIR="${LXD_ONE_DIR}" lxd cluster list-database | grep -q "10.1.1.102:8443" - LXD_DIR="${LXD_ONE_DIR}" lxd cluster list-database | grep -q "10.1.1.103:8443" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster list-database | grep -q "10.1.1.101:8443" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster list-database | grep -q "10.1.1.102:8443" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster list-database | grep -q "10.1.1.103:8443" # Create a test project, just to insert something in the database. - LXD_DIR="${LXD_ONE_DIR}" lxc project create p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc project create p1 # Trying to recover a running daemon results in an error. - ! LXD_DIR="${LXD_ONE_DIR}" lxd cluster recover-from-quorum-loss || false + ! INCUS_DIR="${INCUS_ONE_DIR}" incus cluster recover-from-quorum-loss || false # Shutdown all nodes. - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 # Now recover the first node and restart it. - LXD_DIR="${LXD_ONE_DIR}" lxd cluster recover-from-quorum-loss -q - respawn_lxd_cluster_member "${ns1}" "${LXD_ONE_DIR}" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster recover-from-quorum-loss -q + respawn_incus_cluster_member "${ns1}" "${INCUS_ONE_DIR}" # The project we had created is still there - LXD_DIR="${LXD_ONE_DIR}" lxc project list | grep -q p1 + INCUS_DIR="${INCUS_ONE_DIR}" inc project list | grep -q p1 # The database nodes have been updated - LXD_DIR="${LXD_ONE_DIR}" lxd cluster list-database | grep -q "10.1.1.101:8443" - ! LXD_DIR="${LXD_ONE_DIR}" lxd cluster list-database | grep -q "10.1.1.102:8443" || false + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster list-database | grep -q "10.1.1.101:8443" + ! INCUS_DIR="${INCUS_ONE_DIR}" incus cluster list-database | grep -q "10.1.1.102:8443" || false # Cleanup the dead node. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster remove node2 --force --yes - LXD_DIR="${LXD_ONE_DIR}" lxc cluster remove node3 --force --yes + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster remove node2 --force --yes + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster remove node3 --force --yes - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } # When a voter cluster member is shutdown, its role gets transferred to a spare # node. test_clustering_handover() { # shellcheck disable=2039,2034,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" echo "Launched member 1" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" echo "Launched member 2" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" echo "Launched member 3" # Spawn a fourth node, this will be a non-voter, stand-by node. setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" echo "Launched member 4" - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep -Fc "database-standby" | grep -Fx 1 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list | grep -Fc "database-standby" | grep -Fx 1 # Shutdown the first node. - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown echo "Stopped member 1" # The fourth node has been promoted, while the first one demoted. - LXD_DIR="${LXD_THREE_DIR}" lxd sql local 'select * from raft_nodes' - LXD_DIR="${LXD_THREE_DIR}" lxc cluster ls - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node4 - LXD_DIR="${LXD_THREE_DIR}" lxc cluster show node1 - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node4 | grep -q "\- database$" - LXD_DIR="${LXD_THREE_DIR}" lxc cluster show node1 | grep -q "database: false" + INCUS_DIR="${INCUS_THREE_DIR}" incus sql local 'select * from raft_nodes' + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster ls + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node4 + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster show node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node4 | grep -q "\- database$" + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster show node1 | grep -q "database: false" # Even if we shutdown one more node, the cluster is still available. - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown echo "Stopped member 2" - LXD_DIR="${LXD_THREE_DIR}" lxc cluster list + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster list # Respawn the first node, which is now a spare, and the second node, which # is still a voter. echo "Respawning cluster members 1 and 2..." - respawn_lxd_cluster_member "${ns1}" "${LXD_ONE_DIR}" - respawn_lxd_cluster_member "${ns2}" "${LXD_TWO_DIR}" + respawn_incus_cluster_member "${ns1}" "${INCUS_ONE_DIR}" + respawn_incus_cluster_member "${ns2}" "${INCUS_TWO_DIR}" echo "Started members 1 and 2" # Shutdown two voters concurrently. echo "Shutting down cluster members 2 and 3..." - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown & + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown & pid1="$!" - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown & + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown & pid2="$!" wait "$pid1" @@ -2335,149 +2335,149 @@ test_clustering_handover() { # Bringing back one of them restore the quorum. echo "Respawning cluster member 2..." - respawn_lxd_cluster_member "${ns2}" "${LXD_TWO_DIR}" + respawn_incus_cluster_member "${ns2}" "${INCUS_TWO_DIR}" echo "Started member 2" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" } # If a voter node crashes and is detected as offline, its role is migrated to a # stand-by. test_clustering_rebalance() { # shellcheck disable=2039,2034,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Spawn a fourth node setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" # Wait a bit for raft roles to update. sleep 5 # Check there is one database-standby member. - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep -Fc "database-standby" | grep -Fx 1 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list | grep -Fc "database-standby" | grep -Fx 1 # Kill the second node. - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 11 - kill -9 "$(cat "${LXD_TWO_DIR}/lxd.pid")" + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.offline_threshold 11 + kill -9 "$(cat "${INCUS_TWO_DIR}/incus.pid")" # Wait for the second node to be considered offline and be replaced by the # fourth node. sleep 15 # The second node is offline and has been demoted. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "status: Offline" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "database: false" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node4 | grep -q "status: Online" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node4 | grep -q "\- database$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "status: Offline" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "database: false" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node4 | grep -q "status: Online" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node4 | grep -q "\- database$" # Respawn the second node. It won't be able to disrupt the current leader, # since dqlite uses pre-vote. - respawn_lxd_cluster_member "${ns2}" "${LXD_TWO_DIR}" + respawn_incus_cluster_member "${ns2}" "${INCUS_TWO_DIR}" sleep 12 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "status: Online" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "database: true" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "status: Online" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "database: true" - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" } # Recover a cluster where a raft node was removed from the nodes table but not # from the raft configuration. test_clustering_remove_raft_node() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Configuration keys can be changed on any node. - LXD_DIR="${LXD_TWO_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -q 'cluster.offline_threshold: "11"' - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -q 'cluster.offline_threshold: "11"' + INCUS_DIR="${INCUS_TWO_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -q 'cluster.offline_threshold: "11"' + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -q 'cluster.offline_threshold: "11"' # The preseeded network bridge exists on all nodes. ns1_pid="$(cat "${TEST_DIR}/ns/${ns1}/PID")" @@ -2488,32 +2488,32 @@ test_clustering_remove_raft_node() { # Create a pending network and pool, to show that they are not # considered when checking if the joining node has all the required # networks and pools. - LXD_DIR="${LXD_TWO_DIR}" lxc storage create pool1 dir --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc network create net1 --target node2 + INCUS_DIR="${INCUS_TWO_DIR}" inc storage create pool1 dir --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc network create net1 --target node2 # Spawn a third node, using the non-leader node2 as join target. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${INCUS_THREE_DIR}" # Spawn a fourth node, this will be a database-standby node. setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list # Kill the second node, to prevent it from transferring its database role at shutdown. - kill -9 "$(cat "${LXD_TWO_DIR}/lxd.pid")" + kill -9 "$(cat "${INCUS_TWO_DIR}/incus.pid")" # Remove the second node from the database but not from the raft configuration. retries=10 while [ "${retries}" != "0" ]; do - LXD_DIR="${LXD_ONE_DIR}" lxd sql global "DELETE FROM nodes WHERE address = '10.1.1.102:8443'" && break + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global "DELETE FROM nodes WHERE address = '10.1.1.102:8443'" && break sleep 0.5 retries=$((retries-1)) done @@ -2527,225 +2527,225 @@ test_clustering_remove_raft_node() { sleep 12 # The node does not appear anymore in the cluster list. - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -q "node2" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -q "node2" || false # There are only 2 database nodes. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "\- database-leader$" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node3 | grep -q "\- database$" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node4 | grep -q "\- database$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "\- database-leader$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node3 | grep -q "\- database$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node4 | grep -q "\- database$" # The second node is still in the raft_nodes table. - LXD_DIR="${LXD_ONE_DIR}" lxd sql local "SELECT * FROM raft_nodes" | grep -q "10.1.1.102" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql local "SELECT * FROM raft_nodes" | grep -q "10.1.1.102" # Force removing the raft node. - LXD_DIR="${LXD_ONE_DIR}" lxd cluster remove-raft-node -q "10.1.1.102" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster remove-raft-node -q "10.1.1.102" # Wait for a heartbeat to propagate and a rebalance to be performed. sleep 12 # We're back to 3 database nodes. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "\- database-leader$" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node3 | grep -q "\- database$" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node4 | grep -q "\- database$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "\- database-leader$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node3 | grep -q "\- database$" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node4 | grep -q "\- database$" # The second node is gone from the raft_nodes_table. - ! LXD_DIR="${LXD_ONE_DIR}" lxd sql local "SELECT * FROM raft_nodes" | grep -q "10.1.1.102" || false + ! INCUS_DIR="${INCUS_ONE_DIR}" incus sql local "SELECT * FROM raft_nodes" | grep -q "10.1.1.102" || false - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" } test_clustering_failure_domains() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node, using the non-leader node2 as join target. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${INCUS_THREE_DIR}" # Spawn a fourth node, this will be a non-database node. setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" # Spawn a fifth node, using non-database node4 as join target. setup_clustering_netns 5 - LXD_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FIVE_DIR}" + INCUS_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FIVE_DIR}" ns5="${prefix}5" - spawn_lxd_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 4 "${LXD_FIVE_DIR}" + spawn_incus_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 4 "${INCUS_FIVE_DIR}" # Spawn a sixth node, using non-database node4 as join target. setup_clustering_netns 6 - LXD_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_SIX_DIR}" + INCUS_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_SIX_DIR}" ns6="${prefix}6" - spawn_lxd_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 4 "${LXD_SIX_DIR}" + spawn_incus_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 4 "${INCUS_SIX_DIR}" # Default failure domain - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "failure_domain: default" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "failure_domain: default" # Set failure domains # shellcheck disable=SC2039 - printf "roles: [\"database\"]\nfailure_domain: \"az1\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node1 + printf "roles: [\"database\"]\nfailure_domain: \"az1\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node1 # shellcheck disable=SC2039 - printf "roles: [\"database\"]\nfailure_domain: \"az2\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node2 + printf "roles: [\"database\"]\nfailure_domain: \"az2\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node2 # shellcheck disable=SC2039 - printf "roles: [\"database\"]\nfailure_domain: \"az3\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node3 + printf "roles: [\"database\"]\nfailure_domain: \"az3\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node3 # shellcheck disable=SC2039 - printf "roles: []\nfailure_domain: \"az1\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node4 + printf "roles: []\nfailure_domain: \"az1\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node4 # shellcheck disable=SC2039 - printf "roles: []\nfailure_domain: \"az2\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node5 + printf "roles: []\nfailure_domain: \"az2\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node5 # shellcheck disable=SC2039 - printf "roles: []\nfailure_domain: \"az3\"\ngroups: [\"default\"]" | LXD_DIR="${LXD_THREE_DIR}" lxc cluster edit node6 + printf "roles: []\nfailure_domain: \"az3\"\ngroups: [\"default\"]" | INCUS_DIR="${INCUS_THREE_DIR}" inc cluster edit node6 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "failure_domain: az2" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "failure_domain: az2" # Shutdown a node in az2, its replacement is picked from az2. - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown sleep 3 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node2 | grep -q "database: false" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node5 | grep -q "database: true" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node2 | grep -q "database: false" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node5 | grep -q "database: true" - LXD_DIR="${LXD_SIX_DIR}" lxd shutdown - LXD_DIR="${LXD_FIVE_DIR}" lxd shutdown - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_SIX_DIR}" incus shutdown + INCUS_DIR="${INCUS_FIVE_DIR}" incus shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_SIX_DIR}/unix.socket" - rm -f "${LXD_FIVE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_SIX_DIR}/unix.socket" + rm -f "${INCUS_FIVE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" - kill_lxd "${LXD_FIVE_DIR}" - kill_lxd "${LXD_SIX_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" + kill_incus "${INCUS_FIVE_DIR}" + kill_incus "${INCUS_SIX_DIR}" } test_clustering_image_refresh() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # The random storage backend is not supported in clustering tests, # since we need to have the same storage driver on all nodes, so use the driver chosen for the standalone pool. - poolDriver=$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}') + poolDriver=$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}') # Spawn first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "${poolDriver}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "${poolDriver}" - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.images_minimal_replica 1 - LXD_DIR="${LXD_ONE_DIR}" lxc config set images.auto_update_interval 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.images_minimal_replica 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set images.auto_update_interval 1 # The state of the preseeded storage pool shows up as CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep data | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep data | grep -q CREATED # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" "${poolDriver}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" "${poolDriver}" # Spawn public node which has a public testimage setup_clustering_netns 4 - LXD_REMOTE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_REMOTE_DIR}" + INCUS_REMOTE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_REMOTE_DIR}" ns4="${prefix}4" - LXD_NETNS="${ns4}" spawn_lxd "${LXD_REMOTE_DIR}" false - dir_configure "${LXD_REMOTE_DIR}" - LXD_DIR="${LXD_REMOTE_DIR}" deps/import-busybox --alias testimage --public + INCUS_NETNS="${ns4}" spawn_incus "${INCUS_REMOTE_DIR}" false + dir_configure "${INCUS_REMOTE_DIR}" + INCUS_DIR="${INCUS_REMOTE_DIR}" deps/import-busybox --alias testimage --public - LXD_DIR="${LXD_REMOTE_DIR}" lxc config set core.https_address "10.1.1.104:8443" + INCUS_DIR="${INCUS_REMOTE_DIR}" inc config set core.https_address "10.1.1.104:8443" # Add remotes - lxc remote add public "https://10.1.1.104:8443" --accept-certificate --password foo --public - lxc remote add cluster "https://10.1.1.101:8443" --accept-certificate --password sekret + inc remote add public "https://10.1.1.104:8443" --accept-certificate --password foo --public + inc remote add cluster "https://10.1.1.101:8443" --accept-certificate --password sekret - LXD_DIR="${LXD_REMOTE_DIR}" lxc init testimage c1 + INCUS_DIR="${INCUS_REMOTE_DIR}" inc init testimage c1 # Create additional projects - LXD_DIR="${LXD_ONE_DIR}" lxc project create foo - LXD_DIR="${LXD_ONE_DIR}" lxc project create bar + INCUS_DIR="${INCUS_ONE_DIR}" inc project create foo + INCUS_DIR="${INCUS_ONE_DIR}" inc project create bar # Copy default profile to all projects (this includes the root disk) - LXD_DIR="${LXD_ONE_DIR}" lxc profile show default | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default --project foo - LXD_DIR="${LXD_ONE_DIR}" lxc profile show default | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default --project bar + INCUS_DIR="${INCUS_ONE_DIR}" inc profile show default | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default --project foo + INCUS_DIR="${INCUS_ONE_DIR}" inc profile show default | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default --project bar for project in default foo bar; do # Copy the public image to each project - LXD_DIR="${LXD_ONE_DIR}" lxc image copy public:testimage local: --alias testimage --project "${project}" + INCUS_DIR="${INCUS_ONE_DIR}" inc image copy public:testimage local: --alias testimage --project "${project}" # Diable autoupdate for testimage in project foo if [ "${project}" = "foo" ]; then @@ -2754,33 +2754,33 @@ test_clustering_image_refresh() { auto_update=true fi - LXD_DIR="${LXD_ONE_DIR}" lxc image show testimage --project "${project}" | sed -r "s/auto_update: .*/auto_update: ${auto_update}/g" | LXD_DIR="${LXD_ONE_DIR}" lxc image edit testimage --project "${project}" + INCUS_DIR="${INCUS_ONE_DIR}" inc image show testimage --project "${project}" | sed -r "s/auto_update: .*/auto_update: ${auto_update}/g" | INCUS_DIR="${INCUS_ONE_DIR}" inc image edit testimage --project "${project}" # Create a container in each project - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 --project "${project}" + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 --project "${project}" done # Modify public testimage - old_fingerprint="$(LXD_DIR="${LXD_REMOTE_DIR}" lxc image ls testimage -c f --format csv)" - dd if=/dev/urandom count=32 | LXD_DIR="${LXD_REMOTE_DIR}" lxc file push - c1/foo - LXD_DIR="${LXD_REMOTE_DIR}" lxc publish c1 --alias testimage --reuse --public - new_fingerprint="$(LXD_DIR="${LXD_REMOTE_DIR}" lxc image ls testimage -c f --format csv)" + old_fingerprint="$(INCUS_DIR="${INCUS_REMOTE_DIR}" inc image ls testimage -c f --format csv)" + dd if=/dev/urandom count=32 | INCUS_DIR="${INCUS_REMOTE_DIR}" inc file push - c1/foo + INCUS_DIR="${INCUS_REMOTE_DIR}" inc publish c1 --alias testimage --reuse --public + new_fingerprint="$(INCUS_DIR="${INCUS_REMOTE_DIR}" inc image ls testimage -c f --format csv)" pids="" if [ "${poolDriver}" != "dir" ]; then # Check image storage volume records exist. - lxd sql global 'select name from storage_volumes' + incus sql global 'select name from storage_volumes' if [ "${poolDriver}" = "ceph" ]; then - lxd sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 1 + incus sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 1 else - lxd sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 3 + incus sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 3 fi fi # Trigger image refresh on all nodes - for lxd_dir in "${LXD_ONE_DIR}" "${LXD_TWO_DIR}" "${LXD_THREE_DIR}"; do - LXD_DIR="${lxd_dir}" lxc query /internal/testing/image-refresh & + for incus_dir in "${INCUS_ONE_DIR}" "${INCUS_TWO_DIR}" "${INCUS_THREE_DIR}"; do + INCUS_DIR="${incus_dir}" inc query /internal/testing/image-refresh & pids="$! ${pids}" done @@ -2791,14 +2791,14 @@ test_clustering_image_refresh() { done if [ "${poolDriver}" != "dir" ]; then - lxd sql global 'select name from storage_volumes' + incus sql global 'select name from storage_volumes' # Check image storage volume records actually removed from relevant members and replaced with new fingerprint. if [ "${poolDriver}" = "ceph" ]; then - lxd sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 0 - lxd sql global 'select name from storage_volumes' | grep -Fc "${new_fingerprint}" | grep -Fx 1 + incus sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 0 + incus sql global 'select name from storage_volumes' | grep -Fc "${new_fingerprint}" | grep -Fx 1 else - lxd sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 1 - lxd sql global 'select name from storage_volumes' | grep -Fc "${new_fingerprint}" | grep -Fx 2 + incus sql global 'select name from storage_volumes' | grep -Fc "${old_fingerprint}" | grep -Fx 1 + incus sql global 'select name from storage_volumes' | grep -Fc "${new_fingerprint}" | grep -Fx 2 fi fi @@ -2806,19 +2806,19 @@ test_clustering_image_refresh() { # while project foo should still have the old image. # Also, it should only show 1 entry for the old image and 2 entries # for the new one. - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false pids="" # Trigger image refresh on all nodes. This shouldn't do anything as the image # is already up-to-date. - for lxd_dir in "${LXD_ONE_DIR}" "${LXD_TWO_DIR}" "${LXD_THREE_DIR}"; do - LXD_DIR="${lxd_dir}" lxc query /internal/testing/image-refresh & + for incus_dir in "${INCUS_ONE_DIR}" "${INCUS_TWO_DIR}" "${INCUS_THREE_DIR}"; do + INCUS_DIR="${incus_dir}" inc query /internal/testing/image-refresh & pids="$! ${pids}" done @@ -2828,23 +2828,23 @@ test_clustering_image_refresh() { wait "${pid}" || true done - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false # Modify public testimage - dd if=/dev/urandom count=32 | LXD_DIR="${LXD_REMOTE_DIR}" lxc file push - c1/foo - LXD_DIR="${LXD_REMOTE_DIR}" lxc publish c1 --alias testimage --reuse --public - new_fingerprint="$(LXD_DIR="${LXD_REMOTE_DIR}" lxc image ls testimage -c f --format csv)" + dd if=/dev/urandom count=32 | INCUS_DIR="${INCUS_REMOTE_DIR}" inc file push - c1/foo + INCUS_DIR="${INCUS_REMOTE_DIR}" inc publish c1 --alias testimage --reuse --public + new_fingerprint="$(INCUS_DIR="${INCUS_REMOTE_DIR}" inc image ls testimage -c f --format csv)" pids="" # Trigger image refresh on all nodes - for lxd_dir in "${LXD_ONE_DIR}" "${LXD_TWO_DIR}" "${LXD_THREE_DIR}"; do - LXD_DIR="${lxd_dir}" lxc query /internal/testing/image-refresh & + for incus_dir in "${INCUS_ONE_DIR}" "${INCUS_TWO_DIR}" "${INCUS_THREE_DIR}"; do + INCUS_DIR="${incus_dir}" inc query /internal/testing/image-refresh & pids="$! ${pids}" done @@ -2856,600 +2856,600 @@ test_clustering_image_refresh() { pids="" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="foo"' | grep "${old_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${old_fingerprint}")" -eq 1 ] || false - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" - LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" - [ "$(LXD_DIR="${LXD_ONE_DIR}" lxd sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="default"' | grep "${new_fingerprint}" + INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images join projects on images.project_id=projects.id where projects.name="bar"' | grep "${new_fingerprint}" + [ "$(INCUS_DIR="${INCUS_ONE_DIR}" incus sql global 'select images.fingerprint from images' | grep -c "${new_fingerprint}")" -eq 2 ] || false # Clean up everything for project in default foo bar; do # shellcheck disable=SC2046 - LXD_DIR="${LXD_ONE_DIR}" lxc image rm --project "${project}" $(LXD_DIR="${LXD_ONE_DIR}" lxc image ls --format csv --project "${project}" | cut -d, -f2) + INCUS_DIR="${INCUS_ONE_DIR}" inc image rm --project "${project}" $(INCUS_DIR="${INCUS_ONE_DIR}" inc image ls --format csv --project "${project}" | cut -d, -f2) # shellcheck disable=SC2046 - LXD_DIR="${LXD_ONE_DIR}" lxc rm --project "${project}" $(LXD_DIR="${LXD_ONE_DIR}" lxc ls --format csv --project "${project}" | cut -d, -f1) + INCUS_DIR="${INCUS_ONE_DIR}" inc rm --project "${project}" $(INCUS_DIR="${INCUS_ONE_DIR}" inc ls --format csv --project "${project}" | cut -d, -f1) done # shellcheck disable=SC2046 - LXD_DIR="${LXD_REMOTE_DIR}" lxc image rm $(LXD_DIR="${LXD_REMOTE_DIR}" lxc image ls --format csv | cut -d, -f2) + INCUS_DIR="${INCUS_REMOTE_DIR}" inc image rm $(INCUS_DIR="${INCUS_REMOTE_DIR}" inc image ls --format csv | cut -d, -f2) # shellcheck disable=SC2046 - LXD_DIR="${LXD_REMOTE_DIR}" lxc rm $(LXD_DIR="${LXD_REMOTE_DIR}" lxc ls --format csv | cut -d, -f1) + INCUS_DIR="${INCUS_REMOTE_DIR}" inc rm $(INCUS_DIR="${INCUS_REMOTE_DIR}" inc ls --format csv | cut -d, -f1) - LXD_DIR="${LXD_ONE_DIR}" lxc project delete foo - LXD_DIR="${LXD_ONE_DIR}" lxc project delete bar - printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete data + INCUS_DIR="${INCUS_ONE_DIR}" inc project delete foo + INCUS_DIR="${INCUS_ONE_DIR}" inc project delete bar + printf 'config: {}\ndevices: {}' | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete data - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_REMOTE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_REMOTE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_REMOTE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_REMOTE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_REMOTE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_REMOTE_DIR}" - lxc remote rm cluster + inc remote rm cluster # shellcheck disable=SC2034 - LXD_NETNS= + INCUS_NETNS= } test_clustering_evacuation() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # The random storage backend is not supported in clustering tests, # since we need to have the same storage driver on all nodes, so use the driver chosen for the standalone pool. - poolDriver=$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}') + poolDriver=$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}') # Spawn first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "${poolDriver}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "${poolDriver}" # The state of the preseeded storage pool shows up as CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep data | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep data | grep -q CREATED # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" "${poolDriver}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" "${poolDriver}" # Create local pool - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir --target node3 - LXD_DIR="${LXD_ONE_DIR}" lxc storage create pool1 dir + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir --target node3 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage create pool1 dir # Create local storage volume - LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create pool1 vol1 + INCUS_DIR="${INCUS_ONE_DIR}" inc storage volume create pool1 vol1 - LXD_DIR="${LXD_ONE_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" ensure_import_testimage - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c1 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc config set c1 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c1 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c1 boot.host_shutdown_timeout=1 - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c2 --target=node1 -c cluster.evacuate=auto -s pool1 - LXD_DIR="${LXD_ONE_DIR}" lxc config set c2 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c2 --target=node1 -c cluster.evacuate=auto -s pool1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c2 boot.host_shutdown_timeout=1 - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c3 --target=node1 -c cluster.evacuate=stop - LXD_DIR="${LXD_ONE_DIR}" lxc config set c3 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c3 --target=node1 -c cluster.evacuate=stop + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c3 boot.host_shutdown_timeout=1 - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c4 --target=node1 -c cluster.evacuate=migrate -s pool1 - LXD_DIR="${LXD_ONE_DIR}" lxc config set c4 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c4 --target=node1 -c cluster.evacuate=migrate -s pool1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c4 boot.host_shutdown_timeout=1 - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c5 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc config set c5 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c5 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c5 boot.host_shutdown_timeout=1 - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c6 --target=node2 - LXD_DIR="${LXD_ONE_DIR}" lxc config set c6 boot.host_shutdown_timeout=1 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c6 --target=node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set c6 boot.host_shutdown_timeout=1 # For debugging - LXD_DIR="${LXD_TWO_DIR}" lxc list + INCUS_DIR="${INCUS_TWO_DIR}" inc list # Evacuate first node - LXD_DIR="${LXD_TWO_DIR}" lxc cluster evacuate node1 --force + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster evacuate node1 --force # Ensure the node is evacuated - LXD_DIR="${LXD_TWO_DIR}" lxc cluster show node1 | grep -q "status: Evacuated" + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster show node1 | grep -q "status: Evacuated" # For debugging - LXD_DIR="${LXD_TWO_DIR}" lxc list + INCUS_DIR="${INCUS_TWO_DIR}" inc list # Check instance status - LXD_DIR="${LXD_TWO_DIR}" lxc info c1 | grep -q "Status: RUNNING" - ! LXD_DIR="${LXD_TWO_DIR}" lxc info c1 | grep -q "Location: node1" || false - LXD_DIR="${LXD_TWO_DIR}" lxc info c2 | grep -q "Status: RUNNING" - ! LXD_DIR="${LXD_TWO_DIR}" lxc info c2 | grep -q "Location: node1" || false - LXD_DIR="${LXD_TWO_DIR}" lxc info c3 | grep -q "Status: STOPPED" - LXD_DIR="${LXD_TWO_DIR}" lxc info c3 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c4 | grep -q "Status: RUNNING" - ! LXD_DIR="${LXD_TWO_DIR}" lxc info c4 | grep -q "Location: node1" || false - LXD_DIR="${LXD_TWO_DIR}" lxc info c5 | grep -q "Status: STOPPED" - ! LXD_DIR="${LXD_TWO_DIR}" lxc info c5 | grep -q "Location: node1" || false - LXD_DIR="${LXD_TWO_DIR}" lxc info c6 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c6 | grep -q "Location: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c1 | grep -q "Status: RUNNING" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc info c1 | grep -q "Location: node1" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc info c2 | grep -q "Status: RUNNING" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc info c2 | grep -q "Location: node1" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc info c3 | grep -q "Status: STOPPED" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c3 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c4 | grep -q "Status: RUNNING" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc info c4 | grep -q "Location: node1" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc info c5 | grep -q "Status: STOPPED" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc info c5 | grep -q "Location: node1" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc info c6 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c6 | grep -q "Location: node2" # Ensure instances cannot be created on the evacuated node - ! LXD_DIR="${LXD_TWO_DIR}" lxc launch testimage c7 --target=node1 || false + ! INCUS_DIR="${INCUS_TWO_DIR}" inc launch testimage c7 --target=node1 || false # Restore first node - LXD_DIR="${LXD_TWO_DIR}" lxc cluster restore node1 --force + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster restore node1 --force # For debugging - LXD_DIR="${LXD_TWO_DIR}" lxc list + INCUS_DIR="${INCUS_TWO_DIR}" inc list # Ensure the instances were moved back to the origin - LXD_DIR="${LXD_TWO_DIR}" lxc info c1 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c1 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c2 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c2 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c3 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c3 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c4 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c4 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c5 | grep -q "Status: STOPPED" - LXD_DIR="${LXD_TWO_DIR}" lxc info c5 | grep -q "Location: node1" - LXD_DIR="${LXD_TWO_DIR}" lxc info c6 | grep -q "Status: RUNNING" - LXD_DIR="${LXD_TWO_DIR}" lxc info c6 | grep -q "Location: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c1 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c1 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c2 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c2 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c3 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c3 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c4 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c4 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c5 | grep -q "Status: STOPPED" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c5 | grep -q "Location: node1" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c6 | grep -q "Status: RUNNING" + INCUS_DIR="${INCUS_TWO_DIR}" inc info c6 | grep -q "Location: node2" # Clean up - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c1 - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c2 - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c3 - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c4 - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c5 - LXD_DIR="${LXD_TWO_DIR}" lxc rm -f c6 - LXD_DIR="${LXD_TWO_DIR}" lxc image rm testimage + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c1 + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c2 + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c3 + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c4 + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c5 + INCUS_DIR="${INCUS_TWO_DIR}" inc rm -f c6 + INCUS_DIR="${INCUS_TWO_DIR}" inc image rm testimage - printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete data + printf 'config: {}\ndevices: {}' | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete data # Shut down cluster - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" # shellcheck disable=SC2034 - LXD_NETNS= + INCUS_NETNS= } test_clustering_edit_configuration() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # Bootstrap the first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn 6 nodes in total for role coverage. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" setup_clustering_netns 5 - LXD_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FIVE_DIR}" + INCUS_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FIVE_DIR}" ns5="${prefix}5" - spawn_lxd_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 1 "${LXD_FIVE_DIR}" + spawn_incus_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 1 "${INCUS_FIVE_DIR}" setup_clustering_netns 6 - LXD_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_SIX_DIR}" + INCUS_SIX_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_SIX_DIR}" ns6="${prefix}6" - spawn_lxd_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 1 "${LXD_SIX_DIR}" + spawn_incus_and_join_cluster "${ns6}" "${bridge}" "${cert}" 6 1 "${INCUS_SIX_DIR}" - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.offline_threshold 11 # Ensure successful communication - LXD_DIR="${LXD_ONE_DIR}" lxc info --target node2 | grep -q "server_name: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_THREE_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_FOUR_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_FIVE_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_SIX_DIR}" lxc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_THREE_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_SIX_DIR}" inc info --target node1 | grep -q "server_name: node1" # Shut down all nodes, de-syncing the roles tables - shutdown_lxd "${LXD_ONE_DIR}" - shutdown_lxd "${LXD_TWO_DIR}" - shutdown_lxd "${LXD_THREE_DIR}" - shutdown_lxd "${LXD_FOUR_DIR}" + shutdown_incus "${INCUS_ONE_DIR}" + shutdown_incus "${INCUS_TWO_DIR}" + shutdown_incus "${INCUS_THREE_DIR}" + shutdown_incus "${INCUS_FOUR_DIR}" # Force-kill the last two to prevent leadership loss. - daemon_pid=$(cat "${LXD_FIVE_DIR}/lxd.pid") + daemon_pid=$(cat "${INCUS_FIVE_DIR}/incus.pid") kill -9 "${daemon_pid}" 2>/dev/null || true - daemon_pid=$(cat "${LXD_SIX_DIR}/lxd.pid") + daemon_pid=$(cat "${INCUS_SIX_DIR}/incus.pid") kill -9 "${daemon_pid}" 2>/dev/null || true config=$(mktemp -p "${TEST_DIR}" XXX) # Update the cluster configuration with new port numbers - LXD_DIR="${LXD_ONE_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_ONE_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_ONE_DIR}" incus cluster edit < "${config}" - LXD_DIR="${LXD_TWO_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_TWO_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_TWO_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_TWO_DIR}" incus cluster edit < "${config}" - LXD_DIR="${LXD_THREE_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_THREE_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_THREE_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_THREE_DIR}" incus cluster edit < "${config}" - LXD_DIR="${LXD_FOUR_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_FOUR_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_FOUR_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_FOUR_DIR}" incus cluster edit < "${config}" - LXD_DIR="${LXD_FIVE_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_FIVE_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_FIVE_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_FIVE_DIR}" incus cluster edit < "${config}" - LXD_DIR="${LXD_SIX_DIR}" lxd cluster show > "${config}" + INCUS_DIR="${INCUS_SIX_DIR}" incus cluster show > "${config}" sed -e "s/:8443/:9393/" -i "${config}" - LXD_DIR="${LXD_SIX_DIR}" lxd cluster edit < "${config}" + INCUS_DIR="${INCUS_SIX_DIR}" incus cluster edit < "${config}" # Respawn the nodes - LXD_NETNS="${ns1}" respawn_lxd "${LXD_ONE_DIR}" false - LXD_NETNS="${ns2}" respawn_lxd "${LXD_TWO_DIR}" false - LXD_NETNS="${ns3}" respawn_lxd "${LXD_THREE_DIR}" false - LXD_NETNS="${ns4}" respawn_lxd "${LXD_FOUR_DIR}" false - LXD_NETNS="${ns5}" respawn_lxd "${LXD_FIVE_DIR}" false + INCUS_NETNS="${ns1}" respawn_incus "${INCUS_ONE_DIR}" false + INCUS_NETNS="${ns2}" respawn_incus "${INCUS_TWO_DIR}" false + INCUS_NETNS="${ns3}" respawn_incus "${INCUS_THREE_DIR}" false + INCUS_NETNS="${ns4}" respawn_incus "${INCUS_FOUR_DIR}" false + INCUS_NETNS="${ns5}" respawn_incus "${INCUS_FIVE_DIR}" false # Only wait on the last node, because we don't know who the voters are - LXD_NETNS="${ns6}" respawn_lxd "${LXD_SIX_DIR}" true + INCUS_NETNS="${ns6}" respawn_incus "${INCUS_SIX_DIR}" true # Let the heartbeats catch up sleep 12 # Ensure successful communication - LXD_DIR="${LXD_ONE_DIR}" lxc info --target node2 | grep -q "server_name: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_THREE_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_FOUR_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_FIVE_DIR}" lxc info --target node1 | grep -q "server_name: node1" - LXD_DIR="${LXD_SIX_DIR}" lxc info --target node1 | grep -q "server_name: node1" - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster ls | grep -q "No heartbeat" || false + INCUS_DIR="${INCUS_ONE_DIR}" inc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_THREE_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_SIX_DIR}" inc info --target node1 | grep -q "server_name: node1" + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster ls | grep -q "No heartbeat" || false # Clean up - shutdown_lxd "${LXD_ONE_DIR}" - shutdown_lxd "${LXD_TWO_DIR}" - shutdown_lxd "${LXD_THREE_DIR}" - shutdown_lxd "${LXD_FOUR_DIR}" + shutdown_incus "${INCUS_ONE_DIR}" + shutdown_incus "${INCUS_TWO_DIR}" + shutdown_incus "${INCUS_THREE_DIR}" + shutdown_incus "${INCUS_FOUR_DIR}" # Force-kill the last two to prevent leadership loss. - daemon_pid=$(cat "${LXD_FIVE_DIR}/lxd.pid") + daemon_pid=$(cat "${INCUS_FIVE_DIR}/incus.pid") kill -9 "${daemon_pid}" 2>/dev/null || true - daemon_pid=$(cat "${LXD_SIX_DIR}/lxd.pid") + daemon_pid=$(cat "${INCUS_SIX_DIR}/incus.pid") kill -9 "${daemon_pid}" 2>/dev/null || true - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" - rm -f "${LXD_FIVE_DIR}/unix.socket" - rm -f "${LXD_SIX_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" + rm -f "${INCUS_FIVE_DIR}/unix.socket" + rm -f "${INCUS_SIX_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" - kill_lxd "${LXD_FIVE_DIR}" - kill_lxd "${LXD_SIX_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" + kill_incus "${INCUS_FIVE_DIR}" + kill_incus "${INCUS_SIX_DIR}" } test_clustering_remove_members() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # Bootstrap the first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Ensure successful communication - LXD_DIR="${LXD_ONE_DIR}" lxc info --target node2 | grep -q "server_name: node2" - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node1 | grep -q "server_name: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node1 | grep -q "server_name: node1" # Remove the leader, via the stand-by node - LXD_DIR="${LXD_TWO_DIR}" lxc cluster rm node1 + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster rm node1 # Ensure the remaining node is working - ! LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep -q "node1" || false - LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep -q "node2" + ! INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list | grep -q "node1" || false + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster list | grep -q "node2" # Previous leader should no longer be clustered - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster list || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list || false # Spawn a third node, joining the cluster with node2 setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 2 "${INCUS_THREE_DIR}" # Ensure successful communication - LXD_DIR="${LXD_TWO_DIR}" lxc info --target node3 | grep -q "server_name: node3" - LXD_DIR="${LXD_THREE_DIR}" lxc info --target node2 | grep -q "server_name: node2" + INCUS_DIR="${INCUS_TWO_DIR}" inc info --target node3 | grep -q "server_name: node3" + INCUS_DIR="${INCUS_THREE_DIR}" inc info --target node2 | grep -q "server_name: node2" # Remove the third node, via itself - LXD_DIR="${LXD_THREE_DIR}" lxc cluster rm node3 + INCUS_DIR="${INCUS_THREE_DIR}" inc cluster rm node3 # Ensure only node2 is left in the cluster - LXD_DIR="${LXD_TWO_DIR}" lxc cluster ls | grep -q node2 - ! LXD_DIR="${LXD_TWO_DIR}" lxc cluster ls -f csv | grep -qv node2 || false + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster ls | grep -q node2 + ! INCUS_DIR="${INCUS_TWO_DIR}" inc cluster ls -f csv | grep -qv node2 || false # Ensure clustering is disabled (no output) on node1 and node3 - ! LXD_DIR="${LXD_ONE_DIR}" lxc cluster ls | grep -qv "." || false - ! LXD_DIR="${LXD_THREE_DIR}" lxc cluster ls | grep -qv "." || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc cluster ls | grep -qv "." || false + ! INCUS_DIR="${INCUS_THREE_DIR}" inc cluster ls | grep -qv "." || false # Clean up - daemon_pid1=$(cat "${LXD_ONE_DIR}/lxd.pid") - shutdown_lxd "${LXD_ONE_DIR}" + daemon_pid1=$(cat "${INCUS_ONE_DIR}/incus.pid") + shutdown_incus "${INCUS_ONE_DIR}" - daemon_pid2=$(cat "${LXD_TWO_DIR}/lxd.pid") - shutdown_lxd "${LXD_TWO_DIR}" + daemon_pid2=$(cat "${INCUS_TWO_DIR}/incus.pid") + shutdown_incus "${INCUS_TWO_DIR}" - daemon_pid3=$(cat "${LXD_THREE_DIR}/lxd.pid") - shutdown_lxd "${LXD_THREE_DIR}" + daemon_pid3=$(cat "${INCUS_THREE_DIR}/incus.pid") + shutdown_incus "${INCUS_THREE_DIR}" wait "${daemon_pid1}" wait "${daemon_pid2}" wait "${daemon_pid3}" - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } test_clustering_autotarget() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Use node1 for all cluster actions. - LXD_DIR="${LXD_ONE_DIR}" + INCUS_DIR="${INCUS_ONE_DIR}" # Spawn c1 on node2 from node1 ensure_import_testimage - lxc init --target node2 testimage c1 - lxc ls | grep c1 | grep -q node2 + inc init --target node2 testimage c1 + inc ls | grep c1 | grep -q node2 # Set node1 config to disable autotarget - lxc cluster set node1 scheduler.instance manual + inc cluster set node1 scheduler.instance manual # Spawn another node, autotargeting node2 although it has more instances. - lxc init testimage c2 - lxc ls | grep c2 | grep -q node2 + inc init testimage c2 + inc ls | grep c2 | grep -q node2 - shutdown_lxd "${LXD_ONE_DIR}" - shutdown_lxd "${LXD_TWO_DIR}" + shutdown_incus "${INCUS_ONE_DIR}" + shutdown_incus "${INCUS_TWO_DIR}" sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } test_clustering_groups() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" - lxc remote add cluster --password sekret --accept-certificate "https://10.1.1.101:8443" + inc remote add cluster --password sekret --accept-certificate "https://10.1.1.101:8443" # Initially, there is only the default group - lxc cluster group show cluster:default - [ "$(lxc query cluster:/1.0/cluster/groups | jq 'length')" -eq 1 ] + inc cluster group show cluster:default + [ "$(inc query cluster:/1.0/cluster/groups | jq 'length')" -eq 1 ] # All nodes initially belong to the default group - [ "$(lxc query cluster:/1.0/cluster/groups/default | jq '.members | length')" -eq 3 ] + [ "$(inc query cluster:/1.0/cluster/groups/default | jq '.members | length')" -eq 3 ] # Renaming the default group is not allowed - ! lxc cluster group rename cluster:default foobar || false + ! inc cluster group rename cluster:default foobar || false - lxc cluster list cluster: + inc cluster list cluster: # Nodes need to belong to at least one group, removing it from the default group should therefore fail - ! lxc cluster group remove cluster:node1 default || false + ! inc cluster group remove cluster:node1 default || false # Create new cluster group which should be empty - lxc cluster group create cluster:foobar - [ "$(lxc query cluster:/1.0/cluster/groups/foobar | jq '.members | length')" -eq 0 ] + inc cluster group create cluster:foobar + [ "$(inc query cluster:/1.0/cluster/groups/foobar | jq '.members | length')" -eq 0 ] # Copy both description and members from default group - lxc cluster group show cluster:default | lxc cluster group edit cluster:foobar - [ "$(lxc query cluster:/1.0/cluster/groups/foobar | jq '.description == "Default cluster group"')" = "true" ] - [ "$(lxc query cluster:/1.0/cluster/groups/foobar | jq '.members | length')" -eq 3 ] + inc cluster group show cluster:default | inc cluster group edit cluster:foobar + [ "$(inc query cluster:/1.0/cluster/groups/foobar | jq '.description == "Default cluster group"')" = "true" ] + [ "$(inc query cluster:/1.0/cluster/groups/foobar | jq '.members | length')" -eq 3 ] # Delete all members from new group - lxc cluster group remove cluster:node1 foobar - lxc cluster group remove cluster:node2 foobar - lxc cluster group remove cluster:node3 foobar + inc cluster group remove cluster:node1 foobar + inc cluster group remove cluster:node2 foobar + inc cluster group remove cluster:node3 foobar # Add second node to new group. Node2 will now belong to both groups. - lxc cluster group assign cluster:node2 default,foobar - [ "$(lxc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "default"; .)')" = "true" ] - [ "$(lxc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "foobar"; .)')" = "true" ] + inc cluster group assign cluster:node2 default,foobar + [ "$(inc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "default"; .)')" = "true" ] + [ "$(inc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "foobar"; .)')" = "true" ] # Deleting the "foobar" group should fail as it still has members - ! lxc cluster group delete cluster:foobar || false + ! inc cluster group delete cluster:foobar || false # Since node2 now belongs to two groups, it can be removed from the default group - lxc cluster group remove cluster:node2 default - lxc query cluster:/1.0/cluster/members/node2 + inc cluster group remove cluster:node2 default + inc query cluster:/1.0/cluster/members/node2 - [ "$(lxc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "default"; .)')" = "false" ] - [ "$(lxc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "foobar"; .)')" = "true" ] + [ "$(inc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "default"; .)')" = "false" ] + [ "$(inc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "foobar"; .)')" = "true" ] # Rename group "foobar" to "blah" - lxc cluster group rename cluster:foobar blah - [ "$(lxc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "blah"; .)')" = "true" ] + inc cluster group rename cluster:foobar blah + [ "$(inc query cluster:/1.0/cluster/members/node2 | jq 'any(.groups[] == "blah"; .)')" = "true" ] - lxc cluster group create cluster:foobar2 - lxc cluster group assign cluster:node3 default,foobar2 + inc cluster group create cluster:foobar2 + inc cluster group assign cluster:node3 default,foobar2 # Create a new group "newgroup" - lxc cluster group create cluster:newgroup - [ "$(lxc query cluster:/1.0/cluster/groups/newgroup | jq '.members | length')" -eq 0 ] + inc cluster group create cluster:newgroup + [ "$(inc query cluster:/1.0/cluster/groups/newgroup | jq '.members | length')" -eq 0 ] # Add node1 to the "newgroup" group - lxc cluster group add cluster:node1 newgroup - [ "$(lxc query cluster:/1.0/cluster/members/node1 | jq 'any(.groups[] == "newgroup"; .)')" = "true" ] + inc cluster group add cluster:node1 newgroup + [ "$(inc query cluster:/1.0/cluster/members/node1 | jq 'any(.groups[] == "newgroup"; .)')" = "true" ] # remove node1 from "newgroup" - lxc cluster group remove cluster:node1 newgroup + inc cluster group remove cluster:node1 newgroup # delete cluster group "newgroup" - lxc cluster group delete cluster:newgroup + inc cluster group delete cluster:newgroup # With these settings: # - node1 will receive instances unless a different node is directly targeted (not via group) # - node2 will receive instances if either targeted by group or directly # - node3 will only receive instances if targeted directly - lxc cluster set cluster:node2 scheduler.instance=group - lxc cluster set cluster:node3 scheduler.instance=manual + inc cluster set cluster:node2 scheduler.instance=group + inc cluster set cluster:node3 scheduler.instance=manual ensure_import_testimage # Cluster group "foobar" doesn't exist and should therefore fail - ! lxc init testimage cluster:c1 --target=@foobar || false + ! inc init testimage cluster:c1 --target=@foobar || false # At this stage we have: # - node1 in group default accepting all instances @@ -3457,149 +3457,149 @@ test_clustering_groups() { # - node3 in group default accepting direct targeting only # c1 should go to node1 - lxc init testimage cluster:c1 - lxc info cluster:c1 | grep -q "Location: node1" + inc init testimage cluster:c1 + inc info cluster:c1 | grep -q "Location: node1" # c2 should go to node2 - lxc init testimage cluster:c2 --target=@blah - lxc info cluster:c2 | grep -q "Location: node2" + inc init testimage cluster:c2 --target=@blah + inc info cluster:c2 | grep -q "Location: node2" # c3 should go to node2 again - lxc init testimage cluster:c3 --target=@blah - lxc info cluster:c3 | grep -q "Location: node2" + inc init testimage cluster:c3 --target=@blah + inc info cluster:c3 | grep -q "Location: node2" # Direct targeting of node2 should work - lxc init testimage cluster:c4 --target=node2 - lxc info cluster:c4 | grep -q "Location: node2" + inc init testimage cluster:c4 --target=node2 + inc info cluster:c4 | grep -q "Location: node2" # Direct targeting of node3 should work - lxc init testimage cluster:c5 --target=node3 - lxc info cluster:c5 | grep -q "Location: node3" + inc init testimage cluster:c5 --target=node3 + inc info cluster:c5 | grep -q "Location: node3" # Clean up - lxc rm -f c1 c2 c3 c4 c5 + inc rm -f c1 c2 c3 c4 c5 # Restricted project tests - lxc project create foo -c features.images=false -c restricted=true -c restricted.cluster.groups=blah - lxc profile show default | lxc profile edit default --project foo + inc project create foo -c features.images=false -c restricted=true -c restricted.cluster.groups=blah + inc profile show default | inc profile edit default --project foo # Check cannot create instance in restricted project that only allows blah group, when the only member that # exists in the blah group also has scheduler.instance=group set (so it must be targeted via group or directly). - ! lxc init testimage cluster:c1 --project foo || false + ! inc init testimage cluster:c1 --project foo || false # Check cannot create instance in restricted project when targeting a member that isn't in the restricted # project's allowed cluster groups list. - ! lxc init testimage cluster:c1 --project foo --target=node1 || false - ! lxc init testimage cluster:c1 --project foo --target=@foobar2 || false + ! inc init testimage cluster:c1 --project foo --target=node1 || false + ! inc init testimage cluster:c1 --project foo --target=@foobar2 || false # Check can create instance in restricted project when not targeting any specific member, but that it will only # be created on members within the project's allowed cluster groups list. - lxc cluster unset cluster:node2 scheduler.instance - lxc init testimage cluster:c1 --project foo - lxc init testimage cluster:c2 --project foo - lxc info cluster:c1 --project foo | grep -q "Location: node2" - lxc info cluster:c2 --project foo | grep -q "Location: node2" - lxc delete -f c1 c2 --project foo + inc cluster unset cluster:node2 scheduler.instance + inc init testimage cluster:c1 --project foo + inc init testimage cluster:c2 --project foo + inc info cluster:c1 --project foo | grep -q "Location: node2" + inc info cluster:c2 --project foo | grep -q "Location: node2" + inc delete -f c1 c2 --project foo # Check can specify any member or group when restricted.cluster.groups is empty. - lxc project unset foo restricted.cluster.groups - lxc init testimage cluster:c1 --project foo --target=node1 - lxc info cluster:c1 --project foo | grep -q "Location: node1" + inc project unset foo restricted.cluster.groups + inc init testimage cluster:c1 --project foo --target=node1 + inc info cluster:c1 --project foo | grep -q "Location: node1" - lxc init testimage cluster:c2 --project foo --target=@blah - lxc info cluster:c2 --project foo | grep -q "Location: node2" + inc init testimage cluster:c2 --project foo --target=@blah + inc info cluster:c2 --project foo | grep -q "Location: node2" - lxc delete -f c1 c2 --project foo + inc delete -f c1 c2 --project foo - lxc project delete foo + inc project delete foo - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" - lxc remote rm cluster + inc remote rm cluster } test_clustering_events() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML has weird rules... - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node. setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node. setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" # Spawn a fourth node. setup_clustering_netns 4 - LXD_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FOUR_DIR}" + INCUS_FOUR_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FOUR_DIR}" ns4="${prefix}4" - spawn_lxd_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${LXD_FOUR_DIR}" + spawn_incus_and_join_cluster "${ns4}" "${bridge}" "${cert}" 4 1 "${INCUS_FOUR_DIR}" # Spawn a firth node. setup_clustering_netns 5 - LXD_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FIVE_DIR}" + INCUS_FIVE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FIVE_DIR}" ns5="${prefix}5" - spawn_lxd_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 1 "${LXD_FIVE_DIR}" + spawn_incus_and_join_cluster "${ns5}" "${bridge}" "${cert}" 5 1 "${INCUS_FIVE_DIR}" - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_THREE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_FOUR_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_FIVE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_THREE_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info | grep -F "server_event_mode: full-mesh" ensure_import_testimage # c1 should go to node1. - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c1 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node1" - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c2 --target=node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c1 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c2 --target=node2 - LXD_DIR="${LXD_ONE_DIR}" stdbuf -oL lxc monitor --type=lifecycle > "${TEST_DIR}/node1.log" & + INCUS_DIR="${INCUS_ONE_DIR}" stdbuf -oL inc monitor --type=lifecycle > "${TEST_DIR}/node1.log" & monitorNode1PID=$! - LXD_DIR="${LXD_TWO_DIR}" stdbuf -oL lxc monitor --type=lifecycle > "${TEST_DIR}/node2.log" & + INCUS_DIR="${INCUS_TWO_DIR}" stdbuf -oL inc monitor --type=lifecycle > "${TEST_DIR}/node2.log" & monitorNode2PID=$! - LXD_DIR="${LXD_THREE_DIR}" stdbuf -oL lxc monitor --type=lifecycle > "${TEST_DIR}/node3.log" & + INCUS_DIR="${INCUS_THREE_DIR}" stdbuf -oL inc monitor --type=lifecycle > "${TEST_DIR}/node3.log" & monitorNode3PID=$! # Restart instance generating restart lifecycle event. - LXD_DIR="${LXD_ONE_DIR}" lxc restart -f c1 - LXD_DIR="${LXD_THREE_DIR}" lxc restart -f c2 + INCUS_DIR="${INCUS_ONE_DIR}" inc restart -f c1 + INCUS_DIR="${INCUS_THREE_DIR}" inc restart -f c2 sleep 2 # Check events were distributed. @@ -3609,10 +3609,10 @@ test_clustering_events() { done # Switch into event-hub mode. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster role add node1 event-hub - LXD_DIR="${LXD_TWO_DIR}" lxc cluster role add node2 event-hub - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -Fc event-hub | grep -Fx 2 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster role add node1 event-hub + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster role add node2 event-hub + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -Fc event-hub | grep -Fx 2 # Check events were distributed. for i in 1 2 3; do @@ -3620,15 +3620,15 @@ test_clustering_events() { done sleep 2 # Wait for notification heartbeat to distribute new roles. - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -F "server_event_mode: hub-server" - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -F "server_event_mode: hub-server" - LXD_DIR="${LXD_THREE_DIR}" lxc info | grep -F "server_event_mode: hub-client" - LXD_DIR="${LXD_FOUR_DIR}" lxc info | grep -F "server_event_mode: hub-client" - LXD_DIR="${LXD_FIVE_DIR}" lxc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -F "server_event_mode: hub-server" + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -F "server_event_mode: hub-server" + INCUS_DIR="${INCUS_THREE_DIR}" inc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info | grep -F "server_event_mode: hub-client" # Restart instance generating restart lifecycle event. - LXD_DIR="${LXD_ONE_DIR}" lxc restart -f c1 - LXD_DIR="${LXD_THREE_DIR}" lxc restart -f c2 + INCUS_DIR="${INCUS_ONE_DIR}" inc restart -f c1 + INCUS_DIR="${INCUS_THREE_DIR}" inc restart -f c2 sleep 2 # Check events were distributed. @@ -3638,22 +3638,22 @@ test_clustering_events() { done # Launch container on node3 to check image distribution events work during event-hub mode. - LXD_DIR="${LXD_THREE_DIR}" lxc launch testimage c3 --target=node3 + INCUS_DIR="${INCUS_THREE_DIR}" inc launch testimage c3 --target=node3 for i in 1 2 3; do grep -Fc "instance-created" "${TEST_DIR}/node${i}.log" | grep -Fx 1 done # Switch into full-mesh mode by removing one event-hub role so there is <2 in the cluster. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster role remove node1 event-hub - LXD_DIR="${LXD_ONE_DIR}" lxc cluster list | grep -Fc event-hub | grep -Fx 1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster role remove node1 event-hub + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster list | grep -Fc event-hub | grep -Fx 1 sleep 1 # Wait for notification heartbeat to distribute new roles. - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_THREE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_FOUR_DIR}" lxc info | grep -F "server_event_mode: full-mesh" - LXD_DIR="${LXD_FIVE_DIR}" lxc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_THREE_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info | grep -F "server_event_mode: full-mesh" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info | grep -F "server_event_mode: full-mesh" # Check events were distributed. for i in 1 2 3; do @@ -3661,8 +3661,8 @@ test_clustering_events() { done # Restart instance generating restart lifecycle event. - LXD_DIR="${LXD_ONE_DIR}" lxc restart -f c1 - LXD_DIR="${LXD_THREE_DIR}" lxc restart -f c2 + INCUS_DIR="${INCUS_ONE_DIR}" inc restart -f c1 + INCUS_DIR="${INCUS_THREE_DIR}" inc restart -f c2 sleep 2 # Check events were distributed. @@ -3672,30 +3672,30 @@ test_clustering_events() { done # Switch back into event-hub mode by giving the role to node4 and node5. - LXD_DIR="${LXD_TWO_DIR}" lxc cluster role remove node2 event-hub - LXD_DIR="${LXD_FOUR_DIR}" lxc cluster role add node4 event-hub - LXD_DIR="${LXD_FIVE_DIR}" lxc cluster role add node5 event-hub + INCUS_DIR="${INCUS_TWO_DIR}" inc cluster role remove node2 event-hub + INCUS_DIR="${INCUS_FOUR_DIR}" inc cluster role add node4 event-hub + INCUS_DIR="${INCUS_FIVE_DIR}" inc cluster role add node5 event-hub sleep 2 # Wait for notification heartbeat to distribute new roles. - LXD_DIR="${LXD_ONE_DIR}" lxc info | grep -F "server_event_mode: hub-client" - LXD_DIR="${LXD_TWO_DIR}" lxc info | grep -F "server_event_mode: hub-client" - LXD_DIR="${LXD_THREE_DIR}" lxc info | grep -F "server_event_mode: hub-client" - LXD_DIR="${LXD_FOUR_DIR}" lxc info | grep -F "server_event_mode: hub-server" - LXD_DIR="${LXD_FIVE_DIR}" lxc info | grep -F "server_event_mode: hub-server" + INCUS_DIR="${INCUS_ONE_DIR}" inc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_TWO_DIR}" inc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_THREE_DIR}" inc info | grep -F "server_event_mode: hub-client" + INCUS_DIR="${INCUS_FOUR_DIR}" inc info | grep -F "server_event_mode: hub-server" + INCUS_DIR="${INCUS_FIVE_DIR}" inc info | grep -F "server_event_mode: hub-server" # Shutdown the hub servers. - LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 11 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster ls + INCUS_DIR="${INCUS_ONE_DIR}" inc config set cluster.offline_threshold 11 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster ls - LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown - LXD_DIR="${LXD_FIVE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_FOUR_DIR}" incus shutdown + INCUS_DIR="${INCUS_FIVE_DIR}" incus shutdown sleep 12 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster ls + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster ls # Confirm that local operations are not blocked by having no event hubs running, but that events are not being # distributed. - LXD_DIR="${LXD_ONE_DIR}" lxc restart -f c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc restart -f c1 sleep 2 grep -Fc "instance-restarted" "${TEST_DIR}/node1.log" | grep -Fx 7 @@ -3710,64 +3710,64 @@ test_clustering_events() { kill -9 ${monitorNode3PID} || true # Cleanup. - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 - LXD_DIR="${LXD_TWO_DIR}" lxc delete -f c2 - LXD_DIR="${LXD_THREE_DIR}" lxc delete -f c3 - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 + INCUS_DIR="${INCUS_TWO_DIR}" inc delete -f c2 + INCUS_DIR="${INCUS_THREE_DIR}" inc delete -f c3 + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_FIVE_DIR}/unix.socket" - rm -f "${LXD_FOUR_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_FIVE_DIR}/unix.socket" + rm -f "${INCUS_FOUR_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" - kill_lxd "${LXD_FOUR_DIR}" - kill_lxd "${LXD_FIVE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" + kill_incus "${INCUS_FOUR_DIR}" + kill_incus "${INCUS_FIVE_DIR}" } test_clustering_uuid() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # create two cluster nodes setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" ensure_import_testimage - # spawn an instance on the first LXD node - LXD_DIR="${LXD_ONE_DIR}" lxc launch testimage c1 --target=node1 + # spawn an instance on the first Incus node + INCUS_DIR="${INCUS_ONE_DIR}" inc launch testimage c1 --target=node1 # get its volatile.uuid - uuid_before_move=$(LXD_DIR="${LXD_ONE_DIR}" lxc config get c1 volatile.uuid) + uuid_before_move=$(INCUS_DIR="${INCUS_ONE_DIR}" inc config get c1 volatile.uuid) # stop the instance - LXD_DIR="${LXD_ONE_DIR}" lxc stop -f c1 - # move the instance to the second LXD node - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc stop -f c1 + # move the instance to the second Incus node + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=node2 # get the volatile.uuid of the moved instance on the second node - uuid_after_move=$(LXD_DIR="${LXD_TWO_DIR}" lxc config get c1 volatile.uuid) + uuid_after_move=$(INCUS_DIR="${INCUS_TWO_DIR}" inc config get c1 volatile.uuid) # check that the uuid have not changed, else return an error if [ "${uuid_before_move}" != "${uuid_after_move}" ]; then @@ -3776,16 +3776,16 @@ test_clustering_uuid() { fi # cleanup - LXD_DIR="${LXD_TWO_DIR}" lxc delete c1 -f - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_TWO_DIR}" inc delete c1 -f + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" } diff --git a/test/suites/clustering_instance_placement_scriptlet.sh b/test/suites/clustering_instance_placement_scriptlet.sh index 337c7964e25..1e2bee31849 100644 --- a/test/suites/clustering_instance_placement_scriptlet.sh +++ b/test/suites/clustering_instance_placement_scriptlet.sh @@ -1,51 +1,51 @@ test_clustering_instance_placement_scriptlet() { # shellcheck disable=2039,3043,SC2034 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" # The random storage backend is not supported in clustering tests, # since we need to have the same storage driver on all nodes, so use the driver chosen for the standalone pool. - poolDriver=$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}') + poolDriver=$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}') # Spawn first node setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" "${poolDriver}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" "${poolDriver}" # The state of the preseeded storage pool shows up as CREATED - LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep data | grep -q CREATED + INCUS_DIR="${INCUS_ONE_DIR}" inc storage list | grep data | grep -q CREATED # Add a newline at the end of each line. YAML has weird rules. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" "${poolDriver}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" "${poolDriver}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" "${poolDriver}" - LXD_DIR="${LXD_ONE_DIR}" ensure_import_testimage + INCUS_DIR="${INCUS_ONE_DIR}" ensure_import_testimage # Check only valid scriptlets are accepted. - ! lxc config set instances.placement.scriptlet=foo || false + ! inc config set instances.placement.scriptlet=foo || false # Set basic instance placement scriptlet that logs member info and statically targets to 2nd node. # And by extension checks each of the scriptlet environment functions are callable. # Also checks that the instance_resources are provided as expected. - cat << EOF | lxc config set instances.placement.scriptlet=- + cat << EOF | inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): instance_resources = get_instance_resources() log_info("instance placement started: ", request, ", ", instance_resources) @@ -84,44 +84,44 @@ EOF # Send each request to a different cluster member to test scriptlet replication to other members. # Create instance with limits set on instance to appease intance_resources checks. - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 -c limits.memory=512MiB -c limits.cpu=1 -d root,size=200MiB + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 -c limits.memory=512MiB -c limits.cpu=1 -d root,size=200MiB # Create instances with limits set on a profile to test expansion and to appease intance_resources checks. - LXD_DIR="${LXD_TWO_DIR}" lxc profile create foo - LXD_DIR="${LXD_TWO_DIR}" lxc profile show default | lxc profile edit foo - LXD_DIR="${LXD_TWO_DIR}" lxc profile set foo limits.cpu=1 limits.memory=512MiB - LXD_DIR="${LXD_TWO_DIR}" lxc profile device set foo root size=200MiB - LXD_DIR="${LXD_TWO_DIR}" lxc init testimage c2 -p foo - LXD_DIR="${LXD_THREE_DIR}" lxc init testimage c3 -p foo - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node2" - LXD_DIR="${LXD_ONE_DIR}" lxc info c2 | grep -q "Location: node2" - LXD_DIR="${LXD_ONE_DIR}" lxc info c3 | grep -q "Location: node2" - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 c2 c3 - LXD_DIR="${LXD_ONE_DIR}" lxc profile delete foo + INCUS_DIR="${INCUS_TWO_DIR}" inc profile create foo + INCUS_DIR="${INCUS_TWO_DIR}" inc profile show default | inc profile edit foo + INCUS_DIR="${INCUS_TWO_DIR}" inc profile set foo limits.cpu=1 limits.memory=512MiB + INCUS_DIR="${INCUS_TWO_DIR}" inc profile device set foo root size=200MiB + INCUS_DIR="${INCUS_TWO_DIR}" inc init testimage c2 -p foo + INCUS_DIR="${INCUS_THREE_DIR}" inc init testimage c3 -p foo + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc info c2 | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc info c3 | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 c2 c3 + INCUS_DIR="${INCUS_ONE_DIR}" inc profile delete foo # Set instance placement scriptlet that returns an error and test instance creation fails. - cat << EOF | lxc config set instances.placement.scriptlet=- + cat << EOF | inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): log_error("instance placement not allowed") # Log placement error. fail("Instance not allowed") # Fail to prevent instance creation. EOF - ! LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 || false # Set instance placement scriptlet containing runtime error in it and test instance creation fails. - cat << EOF | lxc config set instances.placement.scriptlet=- + cat << EOF | inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): log_info("Accessing invalid field ", candidate_members[4]) return EOF - ! LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 || false # Set instance placement scriptlet to one that sets an invalid cluster member target. - # Check that instance placement uses LXD's built in logic instead (as if setTarget hadn't been called at all). - cat << EOF | lxc config set instances.placement.scriptlet=- + # Check that instance placement uses Incus's built in logic instead (as if setTarget hadn't been called at all). + cat << EOF | inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): # Set invalid member target. result = set_target("foo") @@ -130,11 +130,11 @@ def instance_placement(request, candidate_members): return EOF - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 -c cluster.evacuate=migrate - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 -c cluster.evacuate=migrate + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node1" # Set basic instance placement scriptlet that statically targets to 3rd member. - cat << EOF | lxc config set instances.placement.scriptlet=- + cat << EOF | inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): log_info("instance placement started: ", request) @@ -154,31 +154,31 @@ def instance_placement(request, candidate_members): EOF # Evacuate member with instance and check its moved to 2nd member. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster evacuate node1 --force - LXD_DIR="${LXD_ONE_DIR}" lxc cluster show node1 | grep -q "status: Evacuated" - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node3" - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster evacuate node1 --force + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster show node1 | grep -q "status: Evacuated" + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 # Delete the storage pool - printf 'config: {}\ndevices: {}' | LXD_DIR="${LXD_ONE_DIR}" lxc profile edit default - LXD_DIR="${LXD_ONE_DIR}" lxc storage delete data + printf 'config: {}\ndevices: {}' | INCUS_DIR="${INCUS_ONE_DIR}" inc profile edit default + INCUS_DIR="${INCUS_ONE_DIR}" inc storage delete data # Shut down cluster - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_ONE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_THREE_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" # shellcheck disable=SC2034 - LXD_NETNS= + INCUS_NETNS= } diff --git a/test/suites/clustering_move.sh b/test/suites/clustering_move.sh index 80a70b53d30..61148b8a4a0 100644 --- a/test/suites/clustering_move.sh +++ b/test/suites/clustering_move.sh @@ -1,68 +1,68 @@ test_clustering_move() { # shellcheck disable=2039,3043,SC2034 - local LXD_DIR + local INCUS_DIR setup_clustering_bridge - prefix="lxd$$" + prefix="inc$$" bridge="${prefix}" setup_clustering_netns 1 - LXD_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_ONE_DIR}" + INCUS_ONE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_ONE_DIR}" ns1="${prefix}1" - spawn_lxd_and_bootstrap_cluster "${ns1}" "${bridge}" "${LXD_ONE_DIR}" + spawn_incus_and_bootstrap_cluster "${ns1}" "${bridge}" "${INCUS_ONE_DIR}" # Add a newline at the end of each line. YAML as weird rules.. - cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${LXD_ONE_DIR}/cluster.crt") + cert=$(sed ':a;N;$!ba;s/\n/\n\n/g' "${INCUS_ONE_DIR}/cluster.crt") # Spawn a second node setup_clustering_netns 2 - LXD_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_TWO_DIR}" + INCUS_TWO_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_TWO_DIR}" ns2="${prefix}2" - spawn_lxd_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${LXD_TWO_DIR}" + spawn_incus_and_join_cluster "${ns2}" "${bridge}" "${cert}" 2 1 "${INCUS_TWO_DIR}" # Spawn a third node setup_clustering_netns 3 - LXD_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_THREE_DIR}" + INCUS_THREE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_THREE_DIR}" ns3="${prefix}3" - spawn_lxd_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${LXD_THREE_DIR}" + spawn_incus_and_join_cluster "${ns3}" "${bridge}" "${cert}" 3 1 "${INCUS_THREE_DIR}" ensure_import_testimage # Preparation - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group create foobar1 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group assign node1 foobar1,default + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group create foobar1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group assign node1 foobar1,default - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group create foobar2 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group assign node2 foobar2,default + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group create foobar2 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group assign node2 foobar2,default - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group create foobar3 - LXD_DIR="${LXD_ONE_DIR}" lxc cluster group assign node3 foobar3,default + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group create foobar3 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster group assign node3 foobar3,default - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c1 --target node1 - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c2 --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc init testimage c3 --target node3 + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c1 --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c2 --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc init testimage c3 --target node3 # Perform default move tests falling back to the built in logic of choosing the node # with the least number of instances when targeting a cluster group. - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar1 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node1" # c1 can be moved within the same cluster group if it has multiple members - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@default - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@default + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@default + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@default # c1 cannot be moved within the same cluster group if it has a single member - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@foobar3 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node3" - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@foobar3 || false + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@foobar3 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node3" + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@foobar3 || false # Perform standard move tests using the `scheduler.instance` cluster member setting. - LXD_DIR="${LXD_ONE_DIR}" lxc cluster set node2 scheduler.instance=group - LXD_DIR="${LXD_ONE_DIR}" lxc cluster set node3 scheduler.instance=manual + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster set node2 scheduler.instance=group + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster set node3 scheduler.instance=manual # At this stage we have: # - node1 in group foobar1,default accepting all instances @@ -73,35 +73,35 @@ test_clustering_move() { # - c3 is deployed on node3 # c1 can be moved to node2 by group targeting. - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@foobar2 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node2" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@foobar2 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node2" # c2 can be moved to node1 by manual targeting. - LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info c2 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c2 | grep -q "Location: node1" # c1 cannot be moved to node3 by group targeting. - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target=@foobar3 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target=@foobar3 || false # c2 can be moved to node2 by manual targeting. - LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target=node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target=node2 # c3 can be moved to node1 by manual targeting. - LXD_DIR="${LXD_ONE_DIR}" lxc move c3 --target=node1 - LXD_DIR="${LXD_ONE_DIR}" lxc info c3 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c3 --target=node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c3 | grep -q "Location: node1" # c3 can be moved back to node by by manual targeting. - LXD_DIR="${LXD_ONE_DIR}" lxc move c3 --target=node3 - LXD_DIR="${LXD_ONE_DIR}" lxc info c3 | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c3 --target=node3 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c3 | grep -q "Location: node3" # Clean up - LXD_DIR="${LXD_ONE_DIR}" lxc cluster unset node2 scheduler.instance - LXD_DIR="${LXD_ONE_DIR}" lxc cluster unset node3 scheduler.instance - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster unset node2 scheduler.instance + INCUS_DIR="${INCUS_ONE_DIR}" inc cluster unset node3 scheduler.instance + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target node1 # Perform extended scheduler tests involving the `instance.placement.scriptlet` global setting. # Start by statically targeting node3 (index 0). - cat << EOF | LXD_DIR="${LXD_ONE_DIR}" lxc config set instances.placement.scriptlet=- + cat << EOF | INCUS_DIR="${INCUS_ONE_DIR}" inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): if request.reason != "relocation": return "Expecting reason relocation" @@ -112,16 +112,16 @@ def instance_placement(request, candidate_members): return EOF - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar3 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node3" - LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target @foobar3 - LXD_DIR="${LXD_ONE_DIR}" lxc info c2 | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar3 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node3" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target @foobar3 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c2 | grep -q "Location: node3" # Ensure that setting an invalid target won't interrupt the move and fall back to the built in behavior. # Equally distribute the instances beforehand so that node1 will get selected. - LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target node2 - cat << EOF | LXD_DIR="${LXD_ONE_DIR}" lxc config set instances.placement.scriptlet=- + cat << EOF | INCUS_DIR="${INCUS_ONE_DIR}" inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): # Set invalid member target. result = set_target("foo") @@ -130,11 +130,11 @@ def instance_placement(request, candidate_members): return EOF - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar1 - LXD_DIR="${LXD_ONE_DIR}" lxc info c1 | grep -q "Location: node1" + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar1 + INCUS_DIR="${INCUS_ONE_DIR}" inc info c1 | grep -q "Location: node1" # If the scriptlet produces a runtime error, the move fails. - cat << EOF | LXD_DIR="${LXD_ONE_DIR}" lxc config set instances.placement.scriptlet=- + cat << EOF | INCUS_DIR="${INCUS_ONE_DIR}" inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): # Try to access an invalid index (non existing member) log_info("Accessing invalid field ", candidate_members[42]) @@ -142,20 +142,20 @@ def instance_placement(request, candidate_members): return EOF - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar2 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar2 || false # If the scriptlet intentionally runs into an error, the move fails. - cat << EOF | LXD_DIR="${LXD_ONE_DIR}" lxc config set instances.placement.scriptlet=- + cat << EOF | INCUS_DIR="${INCUS_ONE_DIR}" inc config set instances.placement.scriptlet=- def instance_placement(request, candidate_members): log_error("instance placement not allowed") # Log placement error. fail("Instance not allowed") # Fail to prevent instance creation. EOF - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar2 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar2 || false # Cleanup - LXD_DIR="${LXD_ONE_DIR}" lxc config unset instances.placement.scriptlet + INCUS_DIR="${INCUS_ONE_DIR}" inc config unset instances.placement.scriptlet # Perform project restriction tests. # At this stage we have: @@ -166,34 +166,34 @@ EOF # - c2 is deployed on node2 # - c3 is deployed on node3 # - default project restricted to cluster groups foobar1,foobar2 - LXD_DIR="${LXD_ONE_DIR}" lxc project set default restricted=true - LXD_DIR="${LXD_ONE_DIR}" lxc project set default restricted.cluster.groups=foobar1,foobar2 + INCUS_DIR="${INCUS_ONE_DIR}" inc project set default restricted=true + INCUS_DIR="${INCUS_ONE_DIR}" inc project set default restricted.cluster.groups=foobar1,foobar2 # Moving to a node that is not a member of foobar1 or foobar2 will fail. # The same applies for an unlisted group - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target @foobar3 || false - ! LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target node3 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target @foobar3 || false + ! INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target node3 || false # Moving instances in between the restricted groups - LXD_DIR="${LXD_ONE_DIR}" lxc move c1 --target node2 - LXD_DIR="${LXD_ONE_DIR}" lxc move c2 --target @foobar1 - LXD_DIR="${LXD_ONE_DIR}" lxc move c3 --target node1 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c1 --target node2 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c2 --target @foobar1 + INCUS_DIR="${INCUS_ONE_DIR}" inc move c3 --target node1 # Cleanup - LXD_DIR="${LXD_ONE_DIR}" lxc delete -f c1 c2 c3 + INCUS_DIR="${INCUS_ONE_DIR}" inc delete -f c1 c2 c3 - LXD_DIR="${LXD_THREE_DIR}" lxd shutdown - LXD_DIR="${LXD_TWO_DIR}" lxd shutdown - LXD_DIR="${LXD_ONE_DIR}" lxd shutdown + INCUS_DIR="${INCUS_THREE_DIR}" incus shutdown + INCUS_DIR="${INCUS_TWO_DIR}" incus shutdown + INCUS_DIR="${INCUS_ONE_DIR}" incus shutdown sleep 0.5 - rm -f "${LXD_THREE_DIR}/unix.socket" - rm -f "${LXD_TWO_DIR}/unix.socket" - rm -f "${LXD_ONE_DIR}/unix.socket" + rm -f "${INCUS_THREE_DIR}/unix.socket" + rm -f "${INCUS_TWO_DIR}/unix.socket" + rm -f "${INCUS_ONE_DIR}/unix.socket" teardown_clustering_netns teardown_clustering_bridge - kill_lxd "${LXD_ONE_DIR}" - kill_lxd "${LXD_TWO_DIR}" - kill_lxd "${LXD_THREE_DIR}" + kill_incus "${INCUS_ONE_DIR}" + kill_incus "${INCUS_TWO_DIR}" + kill_incus "${INCUS_THREE_DIR}" } diff --git a/test/suites/concurrent.sh b/test/suites/concurrent.sh index 9cc24a7e46c..cd2d37ff3a9 100644 --- a/test/suites/concurrent.sh +++ b/test/suites/concurrent.sh @@ -1,6 +1,6 @@ test_concurrent() { - if [ -z "${LXD_CONCURRENT:-}" ]; then - echo "==> SKIP: LXD_CONCURRENT isn't set" + if [ -z "${INCUS_CONCURRENT:-}" ]; then + echo "==> SKIP: INCUS_CONCURRENT isn't set" return fi @@ -11,17 +11,17 @@ test_concurrent() { name=concurrent-${1} - lxc launch testimage "${name}" - lxc info "${name}" | grep RUNNING - echo abc | lxc exec "${name}" -- cat | grep abc - lxc stop "${name}" --force - lxc delete "${name}" + inc launch testimage "${name}" + inc info "${name}" | grep RUNNING + echo abc | inc exec "${name}" -- cat | grep abc + inc stop "${name}" --force + inc delete "${name}" } PIDS="" for id in $(seq $(($(find /sys/bus/cpu/devices/ -type l | wc -l)*8))); do - spawn_container "${id}" 2>&1 | tee "${LXD_DIR}/lxc-${id}.out" & + spawn_container "${id}" 2>&1 | tee "${INCUS_DIR}/incus-${id}.out" & PIDS="${PIDS} $!" done @@ -29,5 +29,5 @@ test_concurrent() { wait "${pid}" done - ! lxc list | grep -q concurrent || false + ! inc list | grep -q concurrent || false } diff --git a/test/suites/config.sh b/test/suites/config.sh index 1d75b7077b8..0ff93143b2e 100644 --- a/test/suites/config.sh +++ b/test/suites/config.sh @@ -1,6 +1,6 @@ ensure_removed() { bad=0 - lxc exec foo -- stat /dev/ttyS0 && bad=1 + inc exec foo -- stat /dev/ttyS0 && bad=1 if [ "${bad}" -eq 1 ]; then echo "device should have been removed; $*" false @@ -8,16 +8,16 @@ ensure_removed() { } dounixdevtest() { - lxc start foo - lxc config device add foo tty unix-char "$@" - lxc exec foo -- stat /dev/ttyS0 - lxc restart foo --force - lxc exec foo -- stat /dev/ttyS0 - lxc config device remove foo tty + inc start foo + inc config device add foo tty unix-char "$@" + inc exec foo -- stat /dev/ttyS0 + inc restart foo --force + inc exec foo -- stat /dev/ttyS0 + inc config device remove foo tty ensure_removed "was not hot-removed" - lxc restart foo --force + inc restart foo --force ensure_removed "removed device re-appeared after container reboot" - lxc stop foo --force + inc stop foo --force } testunixdevs() { @@ -44,7 +44,7 @@ testunixdevs() { ensure_fs_unmounted() { bad=0 - lxc exec foo -- stat /mnt/hello && bad=1 + inc exec foo -- stat /mnt/hello && bad=1 if [ "${bad}" -eq 1 ]; then echo "device should have been removed; $*" false @@ -67,21 +67,21 @@ testloopmounts() { mount "${lpath}" "${TEST_DIR}/mnt" || { echo "loop mount failed"; return; } touch "${TEST_DIR}/mnt/hello" umount -l "${TEST_DIR}/mnt" - lxc start foo - lxc config device add foo mnt disk source="${lpath}" path=/mnt - lxc exec foo stat /mnt/hello + inc start foo + inc config device add foo mnt disk source="${lpath}" path=/mnt + inc exec foo stat /mnt/hello # Note - we need to add a set_running_config_item to lxc # or work around its absence somehow. Once that's done, we # can run the following two lines: - #lxc exec foo reboot - #lxc exec foo stat /mnt/hello - lxc restart foo --force - lxc exec foo stat /mnt/hello - lxc config device remove foo mnt + #inc exec foo reboot + #inc exec foo stat /mnt/hello + inc restart foo --force + inc exec foo stat /mnt/hello + inc config device remove foo mnt ensure_fs_unmounted "fs should have been hot-unmounted" - lxc restart foo --force + inc restart foo --force ensure_fs_unmounted "removed fs re-appeared after restart" - lxc stop foo --force + inc stop foo --force losetup -d "${lpath}" sed -i "\\|^${lpath}|d" "${TEST_DIR}/loops" } @@ -96,73 +96,73 @@ test_mount_order() { # it won't depending on whether the devices below are processed in order or # not. This should not be racy, and they should *always* be processed in path # order, so the filler file should always be there. - lxc config device add foo order disk source="${TEST_DIR}/order" path=/mnt - lxc config device add foo orderFull disk source="${TEST_DIR}/order/full" path=/mnt/empty + inc config device add foo order disk source="${TEST_DIR}/order" path=/mnt + inc config device add foo orderFull disk source="${TEST_DIR}/order/full" path=/mnt/empty - lxc start foo - lxc exec foo -- cat /mnt/empty/filler - lxc stop foo --force + inc start foo + inc exec foo -- cat /mnt/empty/filler + inc stop foo --force } test_config_profiles() { - # Unset LXD_DEVMONITOR_DIR as this test uses devices in /dev instead of TEST_DIR. - unset LXD_DEVMONITOR_DIR - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true + # Unset INCUS_DEVMONITOR_DIR as this test uses devices in /dev instead of TEST_DIR. + unset INCUS_DEVMONITOR_DIR + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true ensure_import_testimage - lxc init testimage foo -s "lxdtest-$(basename "${LXD_DIR}")" - lxc profile list | grep default + inc init testimage foo -s "incustest-$(basename "${INCUS_DIR}")" + inc profile list | grep default - # let's check that 'lxc config profile' still works while it's deprecated - lxc config profile list | grep default + # let's check that 'inc config profile' still works while it's deprecated + inc config profile list | grep default # setting an invalid config item should error out when setting it, not get # into the database and never let the user edit the container again. - ! lxc config set foo raw.lxc lxc.notaconfigkey=invalid || false + ! inc config set foo raw.lxc lxc.notaconfigkey=invalid || false # validate unsets - lxc profile set default user.foo bar - lxc profile show default | grep -q user.foo - lxc profile unset default user.foo - ! lxc profile show default | grep -q user.foo || false + inc profile set default user.foo bar + inc profile show default | grep -q user.foo + inc profile unset default user.foo + ! inc profile show default | grep -q user.foo || false - lxc profile device set default eth0 limits.egress 100Mbit - lxc profile show default | grep -q limits.egress - lxc profile device unset default eth0 limits.egress - ! lxc profile show default | grep -q limits.egress || false + inc profile device set default eth0 limits.egress 100Mbit + inc profile show default | grep -q limits.egress + inc profile device unset default eth0 limits.egress + ! inc profile show default | grep -q limits.egress || false # check that various profile application mechanisms work - lxc profile create one - lxc profile create two - lxc profile assign foo one,two - [ "$(lxc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one two" ] - lxc profile assign foo "" - [ "$(lxc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "" ] - lxc profile apply foo one # backwards compat check with `lxc profile apply` - [ "$(lxc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one" ] - lxc profile assign foo "" - lxc profile add foo one - [ "$(lxc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one" ] - lxc profile remove foo one - [ "$(lxc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "" ] - - lxc profile create stdintest - echo "BADCONF" | lxc profile set stdintest user.user_data - - lxc profile show stdintest | grep BADCONF - lxc profile delete stdintest - - echo "BADCONF" | lxc config set foo user.user_data - - lxc config show foo | grep BADCONF - lxc config unset foo user.user_data + inc profile create one + inc profile create two + inc profile assign foo one,two + [ "$(inc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one two" ] + inc profile assign foo "" + [ "$(inc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "" ] + inc profile apply foo one # backwards compat check with `inc profile apply` + [ "$(inc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one" ] + inc profile assign foo "" + inc profile add foo one + [ "$(inc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "one" ] + inc profile remove foo one + [ "$(inc list -f json foo | jq -r '.[0].profiles | join(" ")')" = "" ] + + inc profile create stdintest + echo "BADCONF" | inc profile set stdintest user.user_data - + inc profile show stdintest | grep BADCONF + inc profile delete stdintest + + echo "BADCONF" | inc config set foo user.user_data - + inc config show foo | grep BADCONF + inc config unset foo user.user_data mkdir -p "${TEST_DIR}/mnt1" - lxc config device add foo mnt1 disk source="${TEST_DIR}/mnt1" path=/mnt1 readonly=true - lxc profile create onenic - lxc profile device add onenic eth0 nic nictype=p2p - lxc profile assign foo onenic - lxc profile create unconfined + inc config device add foo mnt1 disk source="${TEST_DIR}/mnt1" path=/mnt1 readonly=true + inc profile create onenic + inc profile device add onenic eth0 nic nictype=p2p + inc profile assign foo onenic + inc profile create unconfined # Look at the LXC version to decide whether to use the new # or the new config key for apparmor. @@ -170,73 +170,73 @@ test_config_profiles() { lxc_major=$(echo "${lxc_version}" | cut -d. -f1) lxc_minor=$(echo "${lxc_version}" | cut -d. -f2) if [ "${lxc_major}" -lt 2 ] || { [ "${lxc_major}" = "2" ] && [ "${lxc_minor}" -lt "1" ]; }; then - lxc profile set unconfined raw.lxc "lxc.aa_profile=unconfined" + inc profile set unconfined raw.lxc "lxc.aa_profile=unconfined" else - lxc profile set unconfined raw.lxc "lxc.apparmor.profile=unconfined" + inc profile set unconfined raw.lxc "lxc.apparmor.profile=unconfined" fi - lxc profile assign foo onenic,unconfined + inc profile assign foo onenic,unconfined # test profile rename - lxc profile create foo - lxc profile rename foo bar - lxc profile list | grep -qv foo # the old name is gone - lxc profile delete bar - - lxc config device list foo | grep mnt1 - lxc config device show foo | grep "/mnt1" - lxc config show foo | grep "onenic" -A1 | grep "unconfined" - lxc profile list | grep onenic - lxc profile device list onenic | grep eth0 - lxc profile device show onenic | grep p2p + inc profile create foo + inc profile rename foo bar + inc profile list | grep -qv foo # the old name is gone + inc profile delete bar + + inc config device list foo | grep mnt1 + inc config device show foo | grep "/mnt1" + inc config show foo | grep "onenic" -A1 | grep "unconfined" + inc profile list | grep onenic + inc profile device list onenic | grep eth0 + inc profile device show onenic | grep p2p # test live-adding a nic veth_host_name="veth$$" - lxc start foo - lxc exec foo -- cat /proc/self/mountinfo | grep -q "/mnt1.*ro," - ! lxc config show foo | grep -q "raw.lxc" || false - lxc config show foo --expanded | grep -q "raw.lxc" - ! lxc config show foo | grep -v "volatile.eth0" | grep -q "eth0" || false - lxc config show foo --expanded | grep -v "volatile.eth0" | grep -q "eth0" - lxc config device add foo eth2 nic nictype=p2p name=eth10 host_name="${veth_host_name}" - lxc exec foo -- /sbin/ifconfig -a | grep eth0 - lxc exec foo -- /sbin/ifconfig -a | grep eth10 - lxc config device list foo | grep eth2 - lxc config device remove foo eth2 + inc start foo + inc exec foo -- cat /proc/self/mountinfo | grep -q "/mnt1.*ro," + ! inc config show foo | grep -q "raw.lxc" || false + inc config show foo --expanded | grep -q "raw.lxc" + ! inc config show foo | grep -v "volatile.eth0" | grep -q "eth0" || false + inc config show foo --expanded | grep -v "volatile.eth0" | grep -q "eth0" + inc config device add foo eth2 nic nictype=p2p name=eth10 host_name="${veth_host_name}" + inc exec foo -- /sbin/ifconfig -a | grep eth0 + inc exec foo -- /sbin/ifconfig -a | grep eth10 + inc config device list foo | grep eth2 + inc config device remove foo eth2 # test live-adding a disk mkdir "${TEST_DIR}/mnt2" touch "${TEST_DIR}/mnt2/hosts" - lxc config device add foo mnt2 disk source="${TEST_DIR}/mnt2" path=/mnt2 readonly=true - lxc exec foo -- cat /proc/self/mountinfo | grep -q "/mnt2.*ro," - lxc exec foo -- ls /mnt2/hosts - lxc stop foo --force - lxc start foo - lxc exec foo -- ls /mnt2/hosts - lxc config device remove foo mnt2 - ! lxc exec foo -- ls /mnt2/hosts || false - lxc stop foo --force - lxc start foo - ! lxc exec foo -- ls /mnt2/hosts || false - lxc stop foo --force - - lxc config set foo user.prop value - lxc list user.prop=value | grep foo - lxc config unset foo user.prop + inc config device add foo mnt2 disk source="${TEST_DIR}/mnt2" path=/mnt2 readonly=true + inc exec foo -- cat /proc/self/mountinfo | grep -q "/mnt2.*ro," + inc exec foo -- ls /mnt2/hosts + inc stop foo --force + inc start foo + inc exec foo -- ls /mnt2/hosts + inc config device remove foo mnt2 + ! inc exec foo -- ls /mnt2/hosts || false + inc stop foo --force + inc start foo + ! inc exec foo -- ls /mnt2/hosts || false + inc stop foo --force + + inc config set foo user.prop value + inc list user.prop=value | grep foo + inc config unset foo user.prop # Test for invalid raw.lxc - ! lxc config set foo raw.lxc a || false - ! lxc profile set default raw.lxc a || false + ! inc config set foo raw.lxc a || false + ! inc profile set default raw.lxc a || false bad=0 - lxc list user.prop=value | grep foo && bad=1 + inc list user.prop=value | grep foo && bad=1 if [ "${bad}" -eq 1 ]; then echo "property unset failed" false fi bad=0 - lxc config set foo user.prop 2>/dev/null && bad=1 + inc config set foo user.prop 2>/dev/null && bad=1 if [ "${bad}" -eq 1 ]; then echo "property set succeeded when it shouldn't have" false @@ -248,19 +248,19 @@ test_config_profiles() { test_mount_order - lxc delete foo + inc delete foo - lxc init testimage foo -s "lxdtest-$(basename "${LXD_DIR}")" - lxc profile assign foo onenic,unconfined - lxc start foo + inc init testimage foo -s "incustest-$(basename "${INCUS_DIR}")" + inc profile assign foo onenic,unconfined + inc start foo if [ -e /sys/module/apparmor ]; then - lxc exec foo -- grep -xF unconfined /proc/self/attr/current + inc exec foo -- grep -xF unconfined /proc/self/attr/current fi - lxc exec foo -- ls /sys/class/net | grep eth0 + inc exec foo -- ls /sys/class/net | grep eth0 - lxc stop foo --force - lxc delete foo + inc stop foo --force + inc delete foo } @@ -272,127 +272,127 @@ test_config_edit() { ensure_import_testimage - lxc init testimage foo -s "lxdtest-$(basename "${LXD_DIR}")" - lxc config show foo | sed 's/^description:.*/description: bar/' | lxc config edit foo - lxc config show foo | grep -q 'description: bar' + inc init testimage foo -s "incustest-$(basename "${INCUS_DIR}")" + inc config show foo | sed 's/^description:.*/description: bar/' | inc config edit foo + inc config show foo | grep -q 'description: bar' # Check instance name is included in edit screen. - cmd=$(unset -f lxc; command -v lxc) + cmd=$(unset -f inc; command -v inc) output=$(EDITOR="cat" timeout --foreground 120 "${cmd}" config edit foo) echo "${output}" | grep "name: foo" # Check expanded config isn't included in edit screen. ! echo "${output}" | grep "expanded" || false - lxc delete foo + inc delete foo } test_property() { ensure_import_testimage - lxc init testimage foo -s "lxdtest-$(basename "${LXD_DIR}")" + inc init testimage foo -s "incustest-$(basename "${INCUS_DIR}")" # Set a property of an instance - lxc config set foo description="a new description" --property + inc config set foo description="a new description" --property # Check that the property is set - lxc config show foo | grep -q "description: a new description" + inc config show foo | grep -q "description: a new description" # Unset a property of an instance - lxc config unset foo description --property + inc config unset foo description --property # Check that the property is unset - ! lxc config show foo | grep -q "description: a new description" || false + ! inc config show foo | grep -q "description: a new description" || false # Set a property of an instance (bool) - lxc config set foo ephemeral=true --property + inc config set foo ephemeral=true --property # Check that the property is set - lxc config show foo | grep -q "ephemeral: true" + inc config show foo | grep -q "ephemeral: true" # Unset a property of an instance (bool) - lxc config unset foo ephemeral --property + inc config unset foo ephemeral --property # Check that the property is unset (i.e false) - lxc config show foo | grep -q "ephemeral: false" + inc config show foo | grep -q "ephemeral: false" # Create a snap of the instance to set its expiration timestamp - lxc snapshot foo s1 - lxc config set foo/s1 expires_at="2024-03-23T17:38:37.753398689-04:00" --property - lxc config show foo/s1 | grep -q "expires_at: 2024-03-23T17:38:37.753398689-04:00" - lxc config unset foo/s1 expires_at --property - lxc config show foo/s1 | grep -q "expires_at: 0001-01-01T00:00:00Z" + inc snapshot foo s1 + inc config set foo/s1 expires_at="2024-03-23T17:38:37.753398689-04:00" --property + inc config show foo/s1 | grep -q "expires_at: 2024-03-23T17:38:37.753398689-04:00" + inc config unset foo/s1 expires_at --property + inc config show foo/s1 | grep -q "expires_at: 0001-01-01T00:00:00Z" # Create a storage volume, create a volume snapshot and set its expiration timestamp # shellcheck disable=2039,3043 local storage_pool - storage_pool="lxdtest-$(basename "${LXD_DIR}")" + storage_pool="incustest-$(basename "${INCUS_DIR}")" storage_volume="${storage_pool}-vol" - lxc storage volume create "${storage_pool}" "${storage_volume}" - lxc launch testimage c1 -s "${storage_pool}" + inc storage volume create "${storage_pool}" "${storage_volume}" + inc launch testimage c1 -s "${storage_pool}" # This will create a snapshot named 'snap0' - lxc storage volume snapshot "${storage_pool}" "${storage_volume}" + inc storage volume snapshot "${storage_pool}" "${storage_volume}" - lxc storage volume set "${storage_pool}" "${storage_volume}"/snap0 expires_at="2024-03-23T17:38:37.753398689-04:00" --property - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 2024-03-23T17:38:37.753398689-04:00' - lxc storage volume unset "${storage_pool}" "${storage_volume}"/snap0 expires_at --property - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z' + inc storage volume set "${storage_pool}" "${storage_volume}"/snap0 expires_at="2024-03-23T17:38:37.753398689-04:00" --property + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 2024-03-23T17:38:37.753398689-04:00' + inc storage volume unset "${storage_pool}" "${storage_volume}"/snap0 expires_at --property + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z' - lxc delete -f c1 - lxc storage volume delete "${storage_pool}" "${storage_volume}" - lxc delete -f foo + inc delete -f c1 + inc storage volume delete "${storage_pool}" "${storage_volume}" + inc delete -f foo } test_config_edit_container_snapshot_pool_config() { # shellcheck disable=2034,2039,2155,3043 - local storage_pool="lxdtest-$(basename "${LXD_DIR}")" + local storage_pool="incustest-$(basename "${INCUS_DIR}")" ensure_import_testimage - lxc init testimage c1 -s "$storage_pool" - lxc snapshot c1 s1 + inc init testimage c1 -s "$storage_pool" + inc snapshot c1 s1 # edit the container volume name - lxc storage volume show "$storage_pool" container/c1 | \ + inc storage volume show "$storage_pool" container/c1 | \ sed 's/^description:.*/description: bar/' | \ - lxc storage volume edit "$storage_pool" container/c1 - lxc storage volume show "$storage_pool" container/c1 | grep -q 'description: bar' + inc storage volume edit "$storage_pool" container/c1 + inc storage volume show "$storage_pool" container/c1 | grep -q 'description: bar' # edit the container snapshot volume name - lxc storage volume show "$storage_pool" container/c1/s1 | \ + inc storage volume show "$storage_pool" container/c1/s1 | \ sed 's/^description:.*/description: baz/' | \ - lxc storage volume edit "$storage_pool" container/c1/s1 - lxc storage volume show "$storage_pool" container/c1/s1 | grep -q 'description: baz' - lxc delete c1 + inc storage volume edit "$storage_pool" container/c1/s1 + inc storage volume show "$storage_pool" container/c1/s1 | grep -q 'description: baz' + inc delete c1 } test_container_metadata() { ensure_import_testimage - lxc init testimage c + inc init testimage c # metadata for the container are printed - lxc config metadata show c | grep -q BusyBox + inc config metadata show c | grep -q BusyBox # metadata can be edited - lxc config metadata show c | sed 's/BusyBox/BB/' | lxc config metadata edit c - lxc config metadata show c | grep -q BB + inc config metadata show c | sed 's/BusyBox/BB/' | inc config metadata edit c + inc config metadata show c | grep -q BB # templates can be listed - lxc config template list c | grep -q template.tpl + inc config template list c | grep -q template.tpl # template content can be returned - lxc config template show c template.tpl | grep -q "name:" + inc config template show c template.tpl | grep -q "name:" # templates can be added - lxc config template create c my.tpl - lxc config template list c | grep -q my.tpl + inc config template create c my.tpl + inc config template list c | grep -q my.tpl # template content can be updated - echo "some content" | lxc config template edit c my.tpl - lxc config template show c my.tpl | grep -q "some content" + echo "some content" | inc config template edit c my.tpl + inc config template show c my.tpl | grep -q "some content" # templates can be removed - lxc config template delete c my.tpl - ! lxc config template list c | grep -q my.tpl || false + inc config template delete c my.tpl + ! inc config template list c | grep -q my.tpl || false - lxc delete c + inc delete c } test_container_snapshot_config() { @@ -403,31 +403,31 @@ test_container_snapshot_config() { ensure_import_testimage - lxc init testimage foo -s "lxdtest-$(basename "${LXD_DIR}")" - lxc snapshot foo - lxc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' + inc init testimage foo -s "incustest-$(basename "${INCUS_DIR}")" + inc snapshot foo + inc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' - echo 'expires_at: 2100-01-01T00:00:00Z' | lxc config edit foo/snap0 - lxc config show foo/snap0 | grep -q 'expires_at: 2100-01-01T00:00:00Z' + echo 'expires_at: 2100-01-01T00:00:00Z' | inc config edit foo/snap0 + inc config show foo/snap0 | grep -q 'expires_at: 2100-01-01T00:00:00Z' # Remove expiry date using zero time - echo 'expires_at: 0001-01-01T00:00:00Z' | lxc config edit foo/snap0 - lxc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' + echo 'expires_at: 0001-01-01T00:00:00Z' | inc config edit foo/snap0 + inc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' - echo 'expires_at: 2100-01-01T00:00:00Z' | lxc config edit foo/snap0 - lxc config show foo/snap0 | grep -q 'expires_at: 2100-01-01T00:00:00Z' + echo 'expires_at: 2100-01-01T00:00:00Z' | inc config edit foo/snap0 + inc config show foo/snap0 | grep -q 'expires_at: 2100-01-01T00:00:00Z' # Remove expiry date using empty value - echo 'expires_at:' | lxc config edit foo/snap0 - lxc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' + echo 'expires_at:' | inc config edit foo/snap0 + inc config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' # Check instance name is included in edit screen. - cmd=$(unset -f lxc; command -v lxc) + cmd=$(unset -f inc; command -v inc) output=$(EDITOR="cat" timeout --foreground 120 "${cmd}" config edit foo/snap0) echo "${output}" | grep "name: snap0" # Check expanded config isn't included in edit screen. ! echo "${output}" | grep "expanded" || false - lxc delete -f foo + inc delete -f foo } diff --git a/test/suites/console.sh b/test/suites/console.sh index 83abff1921f..b77ed2af391 100644 --- a/test/suites/console.sh +++ b/test/suites/console.sh @@ -1,5 +1,5 @@ test_console() { - lxc_version=$(lxc info | awk '/driver_version:/ {print $NF}') + lxc_version=$(inc info | awk '/driver_version:/ {print $NF}') lxc_major=$(echo "${lxc_version}" | cut -d. -f1) if [ "${lxc_major}" -lt 3 ]; then @@ -11,21 +11,21 @@ test_console() { ensure_import_testimage - lxc init testimage cons1 + inc init testimage cons1 - lxc start cons1 + inc start cons1 # Make sure there's something in the console ringbuffer. - echo 'some content' | lxc exec cons1 -- tee /dev/console - echo 'some more content' | lxc exec cons1 -- tee /dev/console + echo 'some content' | inc exec cons1 -- tee /dev/console + echo 'some more content' | inc exec cons1 -- tee /dev/console # Retrieve the ringbuffer contents. - lxc console cons1 --show-log | grep 'some content' + inc console cons1 --show-log | grep 'some content' - lxc stop --force cons1 + inc stop --force cons1 # Retrieve on-disk representation of the console ringbuffer. - lxc console cons1 --show-log | grep 'some more content' + inc console cons1 --show-log | grep 'some more content' - lxc delete --force cons1 + inc delete --force cons1 } diff --git a/test/suites/container_devices_disk.sh b/test/suites/container_devices_disk.sh index 1f4f8c0b051..3709e2d48d6 100644 --- a/test/suites/container_devices_disk.sh +++ b/test/suites/container_devices_disk.sh @@ -1,8 +1,8 @@ test_container_devices_disk() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - lxc init testimage foo + inc init testimage foo test_container_devices_disk_shift test_container_devices_raw_mount_options @@ -11,11 +11,11 @@ test_container_devices_disk() { test_container_devices_disk_socket test_container_devices_disk_char - lxc delete -f foo + inc delete -f foo } test_container_devices_disk_shift() { - if ! grep -q shiftfs /proc/filesystems || [ -n "${LXD_SHIFTFS_DISABLE:-}" ]; then + if ! grep -q shiftfs /proc/filesystems || [ -n "${INCUS_SHIFTFS_DISABLE:-}" ]; then return fi @@ -24,46 +24,46 @@ test_container_devices_disk_shift() { touch "${TEST_DIR}/shift-source/a" chown 123:456 "${TEST_DIR}/shift-source/a" - lxc start foo - lxc config device add foo shiftfs disk source="${TEST_DIR}/shift-source" path=/mnt - [ "$(lxc exec foo -- stat /mnt/a -c '%u:%g')" = "65534:65534" ] || false - lxc config device remove foo shiftfs + inc start foo + inc config device add foo shiftfs disk source="${TEST_DIR}/shift-source" path=/mnt + [ "$(inc exec foo -- stat /mnt/a -c '%u:%g')" = "65534:65534" ] || false + inc config device remove foo shiftfs - lxc config device add foo shiftfs disk source="${TEST_DIR}/shift-source" path=/mnt shift=true - [ "$(lxc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + inc config device add foo shiftfs disk source="${TEST_DIR}/shift-source" path=/mnt shift=true + [ "$(inc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - lxc stop foo -f - lxc start foo - [ "$(lxc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - lxc config device remove foo shiftfs - lxc stop foo -f + inc stop foo -f + inc start foo + [ "$(inc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + inc config device remove foo shiftfs + inc stop foo -f # Test shifted custom volumes - POOL=$(lxc profile device get default root pool) - lxc storage volume create "${POOL}" foo-shift security.shifted=true - - lxc start foo - lxc launch testimage foo-priv -c security.privileged=true - lxc launch testimage foo-isol1 -c security.idmap.isolated=true - lxc launch testimage foo-isol2 -c security.idmap.isolated=true - - lxc config device add foo shifted disk pool="${POOL}" source=foo-shift path=/mnt - lxc config device add foo-priv shifted disk pool="${POOL}" source=foo-shift path=/mnt - lxc config device add foo-isol1 shifted disk pool="${POOL}" source=foo-shift path=/mnt - lxc config device add foo-isol2 shifted disk pool="${POOL}" source=foo-shift path=/mnt - - lxc exec foo -- touch /mnt/a - lxc exec foo -- chown 123:456 /mnt/a - - [ "$(lxc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - [ "$(lxc exec foo-priv -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - [ "$(lxc exec foo-isol1 -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - [ "$(lxc exec foo-isol2 -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false - - lxc delete -f foo-priv foo-isol1 foo-isol2 - lxc config device remove foo shifted - lxc storage volume delete "${POOL}" foo-shift - lxc stop foo -f + POOL=$(inc profile device get default root pool) + inc storage volume create "${POOL}" foo-shift security.shifted=true + + inc start foo + inc launch testimage foo-priv -c security.privileged=true + inc launch testimage foo-isol1 -c security.idmap.isolated=true + inc launch testimage foo-isol2 -c security.idmap.isolated=true + + inc config device add foo shifted disk pool="${POOL}" source=foo-shift path=/mnt + inc config device add foo-priv shifted disk pool="${POOL}" source=foo-shift path=/mnt + inc config device add foo-isol1 shifted disk pool="${POOL}" source=foo-shift path=/mnt + inc config device add foo-isol2 shifted disk pool="${POOL}" source=foo-shift path=/mnt + + inc exec foo -- touch /mnt/a + inc exec foo -- chown 123:456 /mnt/a + + [ "$(inc exec foo -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + [ "$(inc exec foo-priv -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + [ "$(inc exec foo-isol1 -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + [ "$(inc exec foo-isol2 -- stat /mnt/a -c '%u:%g')" = "123:456" ] || false + + inc delete -f foo-priv foo-isol1 foo-isol2 + inc config device remove foo shifted + inc storage volume delete "${POOL}" foo-shift + inc stop foo -f } test_container_devices_raw_mount_options() { @@ -71,88 +71,88 @@ test_container_devices_raw_mount_options() { # shellcheck disable=SC2154 mkfs.vfat "${loop_device_1}" - lxc launch testimage foo-priv -c security.privileged=true + inc launch testimage foo-priv -c security.privileged=true - lxc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt - [ "$(lxc exec foo-priv -- stat /mnt -c '%u:%g')" = "0:0" ] || false - lxc exec foo-priv -- touch /mnt/foo - lxc config device remove foo-priv loop_raw_mount_options + inc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt + [ "$(inc exec foo-priv -- stat /mnt -c '%u:%g')" = "0:0" ] || false + inc exec foo-priv -- touch /mnt/foo + inc config device remove foo-priv loop_raw_mount_options - lxc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt raw.mount.options=uid=123,gid=456,ro - [ "$(lxc exec foo-priv -- stat /mnt -c '%u:%g')" = "123:456" ] || false - ! lxc exec foo-priv -- touch /mnt/foo || false - lxc config device remove foo-priv loop_raw_mount_options + inc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt raw.mount.options=uid=123,gid=456,ro + [ "$(inc exec foo-priv -- stat /mnt -c '%u:%g')" = "123:456" ] || false + ! inc exec foo-priv -- touch /mnt/foo || false + inc config device remove foo-priv loop_raw_mount_options - lxc stop foo-priv -f - lxc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt raw.mount.options=uid=123,gid=456,ro - lxc start foo-priv - [ "$(lxc exec foo-priv -- stat /mnt -c '%u:%g')" = "123:456" ] || false - ! lxc exec foo-priv -- touch /mnt/foo || false - lxc config device remove foo-priv loop_raw_mount_options + inc stop foo-priv -f + inc config device add foo-priv loop_raw_mount_options disk source="${loop_device_1}" path=/mnt raw.mount.options=uid=123,gid=456,ro + inc start foo-priv + [ "$(inc exec foo-priv -- stat /mnt -c '%u:%g')" = "123:456" ] || false + ! inc exec foo-priv -- touch /mnt/foo || false + inc config device remove foo-priv loop_raw_mount_options - lxc delete -f foo-priv + inc delete -f foo-priv # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_1}" "${loop_device_1}" } test_container_devices_disk_ceph() { # shellcheck disable=SC2039,3043 - local LXD_BACKEND + local INCUS_BACKEND - LXD_BACKEND=$(storage_backend "$LXD_DIR") - if ! [ "${LXD_BACKEND}" = "ceph" ]; then + INCUS_BACKEND=$(storage_backend "$INCUS_DIR") + if ! [ "${INCUS_BACKEND}" = "ceph" ]; then return fi - RBD_POOL_NAME=lxdtest-$(basename "${LXD_DIR}")-disk + RBD_POOL_NAME=incustest-$(basename "${INCUS_DIR}")-disk ceph osd pool create "${RBD_POOL_NAME}" 1 rbd create --pool "${RBD_POOL_NAME}" --size 50M my-volume RBD_DEVICE=$(rbd map --pool "${RBD_POOL_NAME}" my-volume) mkfs.ext4 -m0 "${RBD_DEVICE}" rbd unmap "${RBD_DEVICE}" - lxc launch testimage ceph-disk -c security.privileged=true - lxc config device add ceph-disk rbd disk source=ceph:"${RBD_POOL_NAME}"/my-volume ceph.user_name=admin ceph.cluster_name=ceph path=/ceph - lxc exec ceph-disk -- stat /ceph/lost+found - lxc restart ceph-disk --force - lxc exec ceph-disk -- stat /ceph/lost+found - lxc delete -f ceph-disk + inc launch testimage ceph-disk -c security.privileged=true + inc config device add ceph-disk rbd disk source=ceph:"${RBD_POOL_NAME}"/my-volume ceph.user_name=admin ceph.cluster_name=ceph path=/ceph + inc exec ceph-disk -- stat /ceph/lost+found + inc restart ceph-disk --force + inc exec ceph-disk -- stat /ceph/lost+found + inc delete -f ceph-disk ceph osd pool rm "${RBD_POOL_NAME}" "${RBD_POOL_NAME}" --yes-i-really-really-mean-it } test_container_devices_disk_cephfs() { # shellcheck disable=SC2039,3043 - local LXD_BACKEND + local INCUS_BACKEND - LXD_BACKEND=$(storage_backend "$LXD_DIR") - if [ "${LXD_BACKEND}" != "ceph" ] || [ -z "${LXD_CEPH_CEPHFS:-}" ]; then + INCUS_BACKEND=$(storage_backend "$INCUS_DIR") + if [ "${INCUS_BACKEND}" != "ceph" ] || [ -z "${INCUS_CEPH_CEPHFS:-}" ]; then return fi - lxc launch testimage ceph-fs -c security.privileged=true - lxc config device add ceph-fs fs disk source=cephfs:"${LXD_CEPH_CEPHFS}"/ ceph.user_name=admin ceph.cluster_name=ceph path=/cephfs - lxc exec ceph-fs -- stat /cephfs - lxc restart ceph-fs --force - lxc exec ceph-fs -- stat /cephfs - lxc delete -f ceph-fs + inc launch testimage ceph-fs -c security.privileged=true + inc config device add ceph-fs fs disk source=cephfs:"${INCUS_CEPH_CEPHFS}"/ ceph.user_name=admin ceph.cluster_name=ceph path=/cephfs + inc exec ceph-fs -- stat /cephfs + inc restart ceph-fs --force + inc exec ceph-fs -- stat /cephfs + inc delete -f ceph-fs } test_container_devices_disk_socket() { - lxc start foo - lxc config device add foo unix-socket disk source="${LXD_DIR}/unix.socket" path=/root/lxd.sock - [ "$(lxc exec foo -- stat /root/lxd.sock -c '%F')" = "socket" ] || false - lxc restart -f foo - [ "$(lxc exec foo -- stat /root/lxd.sock -c '%F')" = "socket" ] || false - lxc config device remove foo unix-socket - lxc stop foo -f + inc start foo + inc config device add foo unix-socket disk source="${INCUS_DIR}/unix.socket" path=/root/incus.sock + [ "$(inc exec foo -- stat /root/incus.sock -c '%F')" = "socket" ] || false + inc restart -f foo + [ "$(inc exec foo -- stat /root/incus.sock -c '%F')" = "socket" ] || false + inc config device remove foo unix-socket + inc stop foo -f } test_container_devices_disk_char() { - lxc start foo - lxc config device add foo char disk source=/dev/zero path=/root/zero - [ "$(lxc exec foo -- stat /root/zero -c '%F')" = "character special file" ] || false - lxc restart -f foo - [ "$(lxc exec foo -- stat /root/zero -c '%F')" = "character special file" ] || false - lxc config device remove foo char - lxc stop foo -f + inc start foo + inc config device add foo char disk source=/dev/zero path=/root/zero + [ "$(inc exec foo -- stat /root/zero -c '%F')" = "character special file" ] || false + inc restart -f foo + [ "$(inc exec foo -- stat /root/zero -c '%F')" = "character special file" ] || false + inc config device remove foo char + inc stop foo -f } diff --git a/test/suites/container_devices_disk_restricted.sh b/test/suites/container_devices_disk_restricted.sh index 305e6cac737..20013427f3d 100644 --- a/test/suites/container_devices_disk_restricted.sh +++ b/test/suites/container_devices_disk_restricted.sh @@ -1,6 +1,6 @@ test_container_devices_disk_restricted() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Create directory for use as basis for restricted disk source tests. testRoot="${TEST_DIR}/restricted" @@ -11,7 +11,7 @@ test_container_devices_disk_restricted() { mkdir "${testRoot}/allowed2" touch "${testRoot}/allowed1/foo1" touch "${testRoot}/allowed1/foo2" - ln "${LXD_DIR}/unix.socket" "${testRoot}/allowed1/lxd.sock" + ln "${INCUS_DIR}/unix.socket" "${testRoot}/allowed1/incus.sock" chown 1000:1000 "${testRoot}/allowed1/foo1" chown 1001:1001 "${testRoot}/allowed1/foo2" mkdir "${testRoot}/not-allowed1" @@ -20,88 +20,88 @@ test_container_devices_disk_restricted() { (cd "${testRoot}/allowed1" || false; ln -s foo1 foolink) # Create project with restricted disk source path. - lxc project create restricted \ + inc project create restricted \ -c features.images=false \ -c restricted=true \ -c restricted.devices.disk=allow \ -c restricted.devices.disk.paths="${testRoot}/allowed1,${testRoot}/allowed2" - lxc project switch restricted - pool="lxdtest-$(basename "${LXD_DIR}")" - lxc profile device add default root disk path="/" pool="${pool}" - lxc profile show default + inc project switch restricted + pool="incustest-$(basename "${INCUS_DIR}")" + inc profile device add default root disk path="/" pool="${pool}" + inc profile show default # Create instance and add check relative source paths are not allowed. - lxc init testimage c1 - ! lxc config device add c1 d1 disk source=foo path=/mnt || false + inc init testimage c1 + ! inc config device add c1 d1 disk source=foo path=/mnt || false # Check adding a disk with a source path above the restricted parent source path isn't allowed. - ! lxc config device add c1 d1 disk source="${testRoot}/not-allowed1" path=/mnt || false + ! inc config device add c1 d1 disk source="${testRoot}/not-allowed1" path=/mnt || false # Check adding a disk with a source path that is a symlink above the restricted parent source path isn't allowed # at start time (check that openat2 restrictions are doing their job). - lxc config device add c1 d1 disk source="${testRoot}/allowed1/not-allowed1" path=/mnt - ! lxc start c1 || false + inc config device add c1 d1 disk source="${testRoot}/allowed1/not-allowed1" path=/mnt + ! inc start c1 || false # Check some rudimentary work arounds to allowed path checks don't work. - ! lxc config device set c1 d1 source="${testRoot}/../not-allowed1" || false + ! inc config device set c1 d1 source="${testRoot}/../not-allowed1" || false # Check adding a disk from a restricted source path cannot use shifting at start time. This is not safe as we # cannot prevent creation of files with setuid, which would allow a root executable to be created. - lxc config device set c1 d1 source="${testRoot}/allowed1" shift=true - ! lxc start c1 || false + inc config device set c1 d1 source="${testRoot}/allowed1" shift=true + ! inc start c1 || false # Check adding a disk with a source path that is allowed is allowed. - lxc config device set c1 d1 source="${testRoot}/allowed1" shift=false - lxc start c1 - lxc exec c1 --project restricted -- ls /mnt/foo1 + inc config device set c1 d1 source="${testRoot}/allowed1" shift=false + inc start c1 + inc exec c1 --project restricted -- ls /mnt/foo1 # Check adding a disk with a source path that is allowed that symlinks to another allowed source path isn't # allowed at start time. - ! lxc config device set c1 d1 source="${testRoot}/allowed1/not-allowed2" || false + ! inc config device set c1 d1 source="${testRoot}/allowed1/not-allowed2" || false # Check relative symlink inside allowed parent path is allowed. - lxc stop -f c1 - lxc config device set c1 d1 source="${testRoot}/allowed1/foolink" path=/mnt/foolink - lxc start c1 - [ "$(lxc exec c1 --project restricted -- stat /mnt/foolink -c '%u:%g')" = "65534:65534" ] || false - lxc stop -f c1 + inc stop -f c1 + inc config device set c1 d1 source="${testRoot}/allowed1/foolink" path=/mnt/foolink + inc start c1 + [ "$(inc exec c1 --project restricted -- stat /mnt/foolink -c '%u:%g')" = "65534:65534" ] || false + inc stop -f c1 # Check usage of raw.idmap is restricted. - ! lxc config set c1 raw.idmap="both 1000 1000" || false + ! inc config set c1 raw.idmap="both 1000 1000" || false # Allow specific raw.idmap host UID/GID. - lxc project set restricted restricted.idmap.uid=1000 - ! lxc config set c1 raw.idmap="both 1000 1000" || false - ! lxc config set c1 raw.idmap="gid 1000 1000" || false - lxc config set c1 raw.idmap="uid 1000 1000" + inc project set restricted restricted.idmap.uid=1000 + ! inc config set c1 raw.idmap="both 1000 1000" || false + ! inc config set c1 raw.idmap="gid 1000 1000" || false + inc config set c1 raw.idmap="uid 1000 1000" - lxc project set restricted restricted.idmap.gid=1000 - lxc config set c1 raw.idmap="gid 1000 1000" - lxc config set c1 raw.idmap="both 1000 1000" + inc project set restricted restricted.idmap.gid=1000 + inc config set c1 raw.idmap="gid 1000 1000" + inc config set c1 raw.idmap="both 1000 1000" # Check conflict detection works. - ! lxc project unset restricted restricted.idmap.uid || false - ! lxc project unset restricted restricted.idmap.gid || false + ! inc project unset restricted restricted.idmap.uid || false + ! inc project unset restricted restricted.idmap.gid || false # Check single entry raw.idmap has taken effect on disk share. - lxc config device set c1 d1 source="${testRoot}/allowed1" path=/mnt - lxc start c1 || (lxc info --show-log c1 ; false) - [ "$(lxc exec c1 --project restricted -- stat /mnt/foo1 -c '%u:%g')" = "1000:1000" ] || false - [ "$(lxc exec c1 --project restricted -- stat /mnt/foo2 -c '%u:%g')" = "65534:65534" ] || false + inc config device set c1 d1 source="${testRoot}/allowed1" path=/mnt + inc start c1 || (inc info --show-log c1 ; false) + [ "$(inc exec c1 --project restricted -- stat /mnt/foo1 -c '%u:%g')" = "1000:1000" ] || false + [ "$(inc exec c1 --project restricted -- stat /mnt/foo2 -c '%u:%g')" = "65534:65534" ] || false # Check adding unix socket is allowed. - lxc config device add c1 unix-socket disk source="${testRoot}/allowed1/lxd.sock" path=/root/lxd.sock - [ "$(lxc exec c1 --project restricted -- stat /root/lxd.sock -c '%F')" = "socket" ] || false + inc config device add c1 unix-socket disk source="${testRoot}/allowed1/incus.sock" path=/root/incus.sock + [ "$(inc exec c1 --project restricted -- stat /root/incus.sock -c '%F')" = "socket" ] || false - lxc delete -f c1 - lxc project switch default - lxc project delete restricted + inc delete -f c1 + inc project switch default + inc project delete restricted rm "${testRoot}/allowed1/not-allowed1" rm "${testRoot}/allowed1/not-allowed2" rm "${testRoot}/allowed1/foo1" rm "${testRoot}/allowed1/foo2" rm "${testRoot}/allowed1/foolink" - rm "${testRoot}/allowed1/lxd.sock" + rm "${testRoot}/allowed1/incus.sock" rmdir "${testRoot}/allowed1" rmdir "${testRoot}/allowed2" rmdir "${testRoot}/not-allowed1" diff --git a/test/suites/container_devices_gpu.sh b/test/suites/container_devices_gpu.sh index ce496f8b946..a763eb164b5 100644 --- a/test/suites/container_devices_gpu.sh +++ b/test/suites/container_devices_gpu.sh @@ -1,6 +1,6 @@ test_container_devices_gpu() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" if [ ! -c /dev/dri/card0 ]; then echo "==> SKIP: No /dev/dri/card0 device found" @@ -8,18 +8,18 @@ test_container_devices_gpu() { fi ctName="ct$$" - lxc launch testimage "${ctName}" + inc launch testimage "${ctName}" # Check adding all cards creates the correct device mounts and cleans up on removal. - startMountCount=$(lxc exec "${ctName}" -- mount | wc -l) - startDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) - lxc config device add "${ctName}" gpu-basic gpu mode=0600 id=0 - lxc exec "${ctName}" -- mount | grep "/dev/dri/card0" - lxc exec "${ctName}" -- stat -c '%a' /dev/dri/card0 | grep 600 - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--basic.dev-dri-card0 | grep 600 - lxc config device remove "${ctName}" gpu-basic - endMountCount=$(lxc exec "${ctName}" -- mount | wc -l) - endDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + startMountCount=$(inc exec "${ctName}" -- mount | wc -l) + startDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) + inc config device add "${ctName}" gpu-basic gpu mode=0600 id=0 + inc exec "${ctName}" -- mount | grep "/dev/dri/card0" + inc exec "${ctName}" -- stat -c '%a' /dev/dri/card0 | grep 600 + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--basic.dev-dri-card0 | grep 600 + inc config device remove "${ctName}" gpu-basic + endMountCount=$(inc exec "${ctName}" -- mount | wc -l) + endDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$startMountCount" != "$endMountCount" ]; then echo "leftover container mounts detected" @@ -32,56 +32,56 @@ test_container_devices_gpu() { fi # Check adding non-existent card fails. - ! lxc config device add "${ctName}" gpu-missing gpu id=9999 + ! inc config device add "${ctName}" gpu-missing gpu id=9999 # Check default create mode is 0660. - lxc config device add "${ctName}" gpu-default gpu - lxc exec "${ctName}" -- stat -c '%a' /dev/dri/card0 | grep 660 - lxc config device remove "${ctName}" gpu-default + inc config device add "${ctName}" gpu-default gpu + inc exec "${ctName}" -- stat -c '%a' /dev/dri/card0 | grep 660 + inc config device remove "${ctName}" gpu-default # Check if nvidia GPU exists. if [ ! -c /dev/nvidia0 ]; then echo "==> SKIP: /dev/nvidia0 does not exist, skipping nvidia tests" - lxc delete -f "${ctName}" + inc delete -f "${ctName}" return fi # Check /usr/bin/nvidia-container-cli exists (requires libnvidia-container-tools be installed). if [ ! -f /usr/bin/nvidia-container-cli ]; then echo "==> SKIP: /usr/bin/nvidia-container-cli not available (please install libnvidia-container-tools)" - lxc delete -f "${ctName}" + inc delete -f "${ctName}" return fi # Check the Nvidia specific devices are mounted correctly. - lxc config device add "${ctName}" gpu-nvidia gpu mode=0600 + inc config device add "${ctName}" gpu-nvidia gpu mode=0600 - lxc exec "${ctName}" -- mount | grep /dev/nvidia0 - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-dri-card0 | grep 600 + inc exec "${ctName}" -- mount | grep /dev/nvidia0 + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-dri-card0 | grep 600 - lxc exec "${ctName}" -- mount | grep /dev/nvidia-modeset - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--modeset | grep 600 + inc exec "${ctName}" -- mount | grep /dev/nvidia-modeset + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--modeset | grep 600 - lxc exec "${ctName}" -- mount | grep /dev/nvidia-uvm - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--uvm | grep 600 + inc exec "${ctName}" -- mount | grep /dev/nvidia-uvm + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--uvm | grep 600 - lxc exec "${ctName}" -- mount | grep /dev/nvidia-uvm-tools - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--uvm--tools | grep 600 + inc exec "${ctName}" -- mount | grep /dev/nvidia-uvm-tools + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidia--uvm--tools | grep 600 - lxc exec "${ctName}" -- mount | grep /dev/nvidiactl - stat -c '%a' "${LXD_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidiactl | grep 600 + inc exec "${ctName}" -- mount | grep /dev/nvidiactl + stat -c '%a' "${INCUS_DIR}"/devices/"${ctName}"/unix.gpu--nvidia.dev-nvidiactl | grep 600 - lxc config device remove "${ctName}" gpu-nvidia + inc config device remove "${ctName}" gpu-nvidia # Check support for nvidia runtime - lxc stop -f "${ctName}" - lxc config set "${ctName}" nvidia.runtime true - lxc start "${ctName}" - nvidiaMountCount=$(lxc exec "${ctName}" -- mount | grep -c nvidia) + inc stop -f "${ctName}" + inc config set "${ctName}" nvidia.runtime true + inc start "${ctName}" + nvidiaMountCount=$(inc exec "${ctName}" -- mount | grep -c nvidia) if [ "$nvidiaMountCount" != "16" ]; then echo "nvidia runtime mounts invalid" false fi - lxc delete -f "${ctName}" + inc delete -f "${ctName}" } diff --git a/test/suites/container_devices_infiniband_physical.sh b/test/suites/container_devices_infiniband_physical.sh index eb6f897b996..fc56456f1e8 100644 --- a/test/suites/container_devices_infiniband_physical.sh +++ b/test/suites/container_devices_infiniband_physical.sh @@ -9,9 +9,9 @@ # reboot test_container_devices_infiniband_physical() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - parent=${LXD_IB_PHYSICAL_PARENT:-""} + parent=${INCUS_IB_PHYSICAL_PARENT:-""} if [ "$parent" = "" ]; then echo "==> SKIP: No physical IB parent specified" @@ -29,30 +29,30 @@ test_container_devices_infiniband_physical() { startNicCount=$(find /sys/class/net | wc -l) # Test basic container with SR-IOV IB. - lxc init testimage "${ctName}" - lxc config device add "${ctName}" eth0 infiniband \ + inc init testimage "${ctName}" + inc config device add "${ctName}" eth0 infiniband \ nictype=physical \ parent="${parent}" \ mtu=1500 \ hwaddr="${ctMAC}" - lxc start "${ctName}" + inc start "${ctName}" # Check host devices are created. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "3" ]; then echo "unexpected IB device count after creation" false fi # Check devices are mounted inside container. - ibMountCount=$(lxc exec "${ctName}" -- mount | grep -c infiniband) + ibMountCount=$(inc exec "${ctName}" -- mount | grep -c infiniband) if [ "$ibMountCount" != "3" ]; then echo "unexpected IB mount count after creation" false fi # Check custom MAC is applied in container on boot. - if ! lxc exec "${ctName}" -- grep -i "${ctMAC}" /sys/class/net/ib0/address ; then + if ! inc exec "${ctName}" -- grep -i "${ctMAC}" /sys/class/net/ib0/address ; then echo "custom mac not applied" false fi @@ -65,13 +65,13 @@ test_container_devices_infiniband_physical() { fi # Check ownership of char devices. - nonRootDeviceCount=$(find "${LXD_DIR}"/devices/"${ctName}" ! -uid 0 -type c | wc -l) + nonRootDeviceCount=$(find "${INCUS_DIR}"/devices/"${ctName}" ! -uid 0 -type c | wc -l) if [ "$nonRootDeviceCount" != "3" ]; then echo "unexpected unprivileged non-root device ownership count after creation" false fi - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Check host dev MAC restore. if ! grep -i "${parentHostMAC}" /sys/class/net/"${parent}"/address ; then @@ -80,21 +80,21 @@ test_container_devices_infiniband_physical() { fi # Check volatile cleanup on stop. - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.name ; then + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.name ; then echo "unexpected volatile key remains" false fi # Check host devices are removed. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "0" ]; then echo "unexpected IB device count after removal" false fi # Check privileged cgroup rules and device ownership. - lxc config set "${ctName}" security.privileged true - lxc start "${ctName}" + inc config set "${ctName}" security.privileged true + inc start "${ctName}" # Check privileged cgroup device rule count. cgroupDeviceCount=$(wc -l < /sys/fs/cgroup/devices/lxc.payload/"${ctName}"/devices.list) @@ -104,47 +104,47 @@ test_container_devices_infiniband_physical() { fi # Check ownership of char devices. - rootDeviceCount=$(find "${LXD_DIR}"/devices/"${ctName}" -uid 0 -type c | wc -l) + rootDeviceCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -uid 0 -type c | wc -l) if [ "$rootDeviceCount" != "3" ]; then echo "unexpected privileged root device ownership count after creation" false fi - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Test hotplugging. - lxc config device remove "${ctName}" eth0 - lxc start "${ctName}" - lxc config device add "${ctName}" eth0 infiniband \ + inc config device remove "${ctName}" eth0 + inc start "${ctName}" + inc config device add "${ctName}" eth0 infiniband \ nictype=physical \ parent="${parent}" \ mtu=1500 # Check host devices are created. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "3" ]; then echo "unexpected IB device count after creation" false fi # Test hot unplug. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check host devices are removed. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "0" ]; then echo "unexpected IB device count after removal" false fi # Check devices are unmounted inside container. - if lxc exec "${ctName}" -- mount | grep -c infiniband ; then + if inc exec "${ctName}" -- mount | grep -c infiniband ; then echo "unexpected IB mounts remain after removal" false fi - lxc delete -f "${ctName}" + inc delete -f "${ctName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) diff --git a/test/suites/container_devices_infiniband_sriov.sh b/test/suites/container_devices_infiniband_sriov.sh index 58429022ef5..ec450124dd2 100644 --- a/test/suites/container_devices_infiniband_sriov.sh +++ b/test/suites/container_devices_infiniband_sriov.sh @@ -9,9 +9,9 @@ # reboot test_container_devices_infiniband_sriov() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - parent=${LXD_IB_SRIOV_PARENT:-""} + parent=${INCUS_IB_SRIOV_PARENT:-""} if [ "$parent" = "" ]; then echo "==> SKIP: No SR-IOV IB parent specified" @@ -29,36 +29,36 @@ test_container_devices_infiniband_sriov() { startNicCount=$(find /sys/class/net | wc -l) # Test basic container with SR-IOV IB. Add 2 devices to check reservation system works. - lxc init testimage "${ctName}" + inc init testimage "${ctName}" # Name the device eth0 rather than ib0 so that check volatile data reset. - lxc config device add "${ctName}" eth0 infiniband \ + inc config device add "${ctName}" eth0 infiniband \ nictype=sriov \ parent="${parent}" \ mtu=1500 - lxc config device add "${ctName}" ib1 infiniband \ + inc config device add "${ctName}" ib1 infiniband \ nictype=sriov \ parent="${parent}" \ mtu=1500 \ hwaddr="${ctMAC}" - lxc start "${ctName}" + inc start "${ctName}" # Check host devices are created. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "6" ]; then echo "unexpected IB device count after creation" false fi # Check devices are mounted inside container. - ibMountCount=$(lxc exec "${ctName}" -- mount | grep -c infiniband) + ibMountCount=$(inc exec "${ctName}" -- mount | grep -c infiniband) if [ "$ibMountCount" != "6" ]; then echo "unexpected IB mount count after creation" false fi # Check custom MAC is applied in container on boot. - if ! lxc exec "${ctName}" -- grep -i "${ctMAC}" /sys/class/net/ib1/address ; then + if ! inc exec "${ctName}" -- grep -i "${ctMAC}" /sys/class/net/ib1/address ; then echo "custom mac not applied" false fi @@ -71,17 +71,17 @@ test_container_devices_infiniband_sriov() { fi # Check ownership of char devices. - nonRootDeviceCount=$(find "${LXD_DIR}"/devices/"${ctName}" ! -uid 0 -type c | wc -l) + nonRootDeviceCount=$(find "${INCUS_DIR}"/devices/"${ctName}" ! -uid 0 -type c | wc -l) if [ "$nonRootDeviceCount" != "6" ]; then echo "unexpected unprivileged non-root device ownership count after creation" false fi # Get host dev name for ib1 before stop to check MAC restore. - ib1HostDev=$(lxc config get "${ctName}" volatile.ib1.host_name) - ib1HostMAC=$(lxc config get "${ctName}" volatile.ib1.last_state.hwaddr) + ib1HostDev=$(inc config get "${ctName}" volatile.ib1.host_name) + ib1HostMAC=$(inc config get "${ctName}" volatile.ib1.last_state.hwaddr) - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Check host dev MAC restore. if ! grep -i "${ib1HostMAC}" /sys/class/net/"${ib1HostDev}"/address ; then @@ -90,21 +90,21 @@ test_container_devices_infiniband_sriov() { fi # Check volatile cleanup on stop. - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.name ; then + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.name ; then echo "unexpected volatile key remains" false fi # Check host devices are removed. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "0" ]; then echo "unexpected IB device count after removal" false fi # Check privileged cgroup rules and device ownership. - lxc config set "${ctName}" security.privileged true - lxc start "${ctName}" + inc config set "${ctName}" security.privileged true + inc start "${ctName}" # Check privileged cgroup device rule count. cgroupDeviceCount=$(wc -l < /sys/fs/cgroup/devices/lxc.payload/"${ctName}"/devices.list) @@ -114,48 +114,48 @@ test_container_devices_infiniband_sriov() { fi # Check ownership of char devices. - rootDeviceCount=$(find "${LXD_DIR}"/devices/"${ctName}" -uid 0 -type c | wc -l) + rootDeviceCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -uid 0 -type c | wc -l) if [ "$rootDeviceCount" != "6" ]; then echo "unexpected privileged root device ownership count after creation" false fi - lxc stop -f "${ctName}" + inc stop -f "${ctName}" - lxc config device remove "${ctName}" eth0 - lxc config device remove "${ctName}" ib1 + inc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" ib1 # Test hotplugging. - lxc start "${ctName}" - lxc config device add "${ctName}" eth0 infiniband \ + inc start "${ctName}" + inc config device add "${ctName}" eth0 infiniband \ nictype=sriov \ parent="${parent}" \ mtu=1500 # Check host devices are created. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "3" ]; then echo "unexpected IB device count after creation" false fi # Test hot unplug. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check host devices are removed. - ibDevCount=$(find "${LXD_DIR}"/devices/"${ctName}" -type c | wc -l) + ibDevCount=$(find "${INCUS_DIR}"/devices/"${ctName}" -type c | wc -l) if [ "$ibDevCount" != "0" ]; then echo "unexpected IB device count after removal" false fi # Check devices are unmounted inside container. - if lxc exec "${ctName}" -- mount | grep -c infiniband ; then + if inc exec "${ctName}" -- mount | grep -c infiniband ; then echo "unexpected IB mounts remain after removal" false fi - lxc delete -f "${ctName}" + inc delete -f "${ctName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) diff --git a/test/suites/container_devices_nic_bridged.sh b/test/suites/container_devices_nic_bridged.sh index 8999703e95b..b75bcd4464e 100644 --- a/test/suites/container_devices_nic_bridged.sh +++ b/test/suites/container_devices_nic_bridged.sh @@ -1,67 +1,67 @@ test_container_devices_nic_bridged() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" vethHostName="veth$$" ctName="nt$$" ctMAC="0a:92:a7:0d:b7:d9" ipRand=$(shuf -i 0-9 -n 1) - brName="lxdt$$" + brName="inct$$" # Standard bridge with random subnet and a bunch of options - lxc network create "${brName}" - lxc network set "${brName}" dns.mode managed - lxc network set "${brName}" dns.domain blah - lxc network set "${brName}" ipv4.nat true - lxc network set "${brName}" ipv4.routing false - lxc network set "${brName}" ipv6.routing false - lxc network set "${brName}" ipv6.dhcp.stateful true - lxc network set "${brName}" bridge.hwaddr 00:11:22:33:44:55 - lxc network set "${brName}" ipv4.address 192.0.2.1/24 - lxc network set "${brName}" ipv6.address 2001:db8::1/64 - lxc network set "${brName}" ipv4.routes 192.0.3.0/24 - lxc network set "${brName}" ipv6.routes 2001:db7::/64 + inc network create "${brName}" + inc network set "${brName}" dns.mode managed + inc network set "${brName}" dns.domain blah + inc network set "${brName}" ipv4.nat true + inc network set "${brName}" ipv4.routing false + inc network set "${brName}" ipv6.routing false + inc network set "${brName}" ipv6.dhcp.stateful true + inc network set "${brName}" bridge.hwaddr 00:11:22:33:44:55 + inc network set "${brName}" ipv4.address 192.0.2.1/24 + inc network set "${brName}" ipv6.address 2001:db8::1/64 + inc network set "${brName}" ipv4.routes 192.0.3.0/24 + inc network set "${brName}" ipv6.routes 2001:db7::/64 [ "$(cat /sys/class/net/${brName}/address)" = "00:11:22:33:44:55" ] # Record how many nics we started with. startNicCount=$(find /sys/class/net | wc -l) # Test pre-launch profile config is applied at launch - lxc profile copy default "${ctName}" + inc profile copy default "${ctName}" # Modify profile nictype and parent in atomic operation to ensure validation passes. - lxc profile show "${ctName}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${brName}/" | lxc profile edit "${ctName}" + inc profile show "${ctName}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${brName}/" | inc profile edit "${ctName}" - lxc profile device set "${ctName}" eth0 ipv4.routes "192.0.2.1${ipRand}/32" - lxc profile device set "${ctName}" eth0 ipv6.routes "2001:db8::1${ipRand}/128" - lxc profile device set "${ctName}" eth0 limits.ingress 1Mbit - lxc profile device set "${ctName}" eth0 limits.egress 2Mbit - lxc profile device set "${ctName}" eth0 host_name "${vethHostName}" - lxc profile device set "${ctName}" eth0 mtu "1400" - lxc profile device set "${ctName}" eth0 queue.tx.length "1200" - lxc profile device set "${ctName}" eth0 hwaddr "${ctMAC}" + inc profile device set "${ctName}" eth0 ipv4.routes "192.0.2.1${ipRand}/32" + inc profile device set "${ctName}" eth0 ipv6.routes "2001:db8::1${ipRand}/128" + inc profile device set "${ctName}" eth0 limits.ingress 1Mbit + inc profile device set "${ctName}" eth0 limits.egress 2Mbit + inc profile device set "${ctName}" eth0 host_name "${vethHostName}" + inc profile device set "${ctName}" eth0 mtu "1400" + inc profile device set "${ctName}" eth0 queue.tx.length "1200" + inc profile device set "${ctName}" eth0 hwaddr "${ctMAC}" - lxc init testimage "${ctName}" -p "${ctName}" + inc init testimage "${ctName}" -p "${ctName}" # Check that adding another NIC to the same network fails because it triggers duplicate instance DNS name checks. # Because this would effectively cause 2 NICs with the same instance name to be connected to the same network. - ! lxc config device add "${ctName}" eth1 nic network=${brName} || false + ! inc config device add "${ctName}" eth1 nic network=${brName} || false # Test device name validation (use vlan=1 to avoid trigger instance DNS name conflict detection). - lxc config device add "${ctName}" 127.0.0.1 nic network=${brName} vlan=1 - lxc config device remove "${ctName}" 127.0.0.1 - lxc config device add "${ctName}" ::1 nic network=${brName} vlan=1 - lxc config device remove "${ctName}" ::1 - lxc config device add "${ctName}" _valid-name nic network=${brName} vlan=1 - lxc config device remove "${ctName}" _valid-name - lxc config device add "${ctName}" /foo nic network=${brName} vlan=1 - lxc config device remove "${ctName}" /foo - ! lxc config device add "${ctName}" .invalid nic network=${brName} vlan=1 || false - ! lxc config device add "${ctName}" ./invalid nic network=${brName} vlan=1 || false - ! lxc config device add "${ctName}" ../invalid nic network=${brName} vlan=1 || false + inc config device add "${ctName}" 127.0.0.1 nic network=${brName} vlan=1 + inc config device remove "${ctName}" 127.0.0.1 + inc config device add "${ctName}" ::1 nic network=${brName} vlan=1 + inc config device remove "${ctName}" ::1 + inc config device add "${ctName}" _valid-name nic network=${brName} vlan=1 + inc config device remove "${ctName}" _valid-name + inc config device add "${ctName}" /foo nic network=${brName} vlan=1 + inc config device remove "${ctName}" /foo + ! inc config device add "${ctName}" .invalid nic network=${brName} vlan=1 || false + ! inc config device add "${ctName}" ./invalid nic network=${brName} vlan=1 || false + ! inc config device add "${ctName}" ../invalid nic network=${brName} vlan=1 || false # Start instance. - lxc start "${ctName}" + inc start "${ctName}" # Check profile routes are applied on boot. if ! ip -4 r list dev "${brName}" | grep "192.0.2.1${ipRand}" ; then @@ -84,7 +84,7 @@ test_container_devices_nic_bridged() { fi # Check profile custom MTU is applied in container on boot. - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -96,7 +96,7 @@ test_container_devices_nic_bridged() { fi # Check profile custom txqueuelen is applied in container on boot. - if ! lxc exec "${ctName}" -- grep "1200" /sys/class/net/eth0/tx_queue_len ; then + if ! inc exec "${ctName}" -- grep "1200" /sys/class/net/eth0/tx_queue_len ; then echo "container veth txqueuelen invalid" false fi @@ -108,21 +108,21 @@ test_container_devices_nic_bridged() { fi # Check profile custom MAC is applied in container on boot. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Add IP alias to container and check routes actually work. - lxc exec "${ctName}" -- ip -4 addr add "192.0.2.1${ipRand}/32" dev eth0 - lxc exec "${ctName}" -- ip -4 route add default dev eth0 + inc exec "${ctName}" -- ip -4 addr add "192.0.2.1${ipRand}/32" dev eth0 + inc exec "${ctName}" -- ip -4 route add default dev eth0 ping -c2 -W5 "192.0.2.1${ipRand}" - lxc exec "${ctName}" -- ip -6 addr add "2001:db8::1${ipRand}/128" dev eth0 + inc exec "${ctName}" -- ip -6 addr add "2001:db8::1${ipRand}/128" dev eth0 wait_for_dad "${ctName}" eth0 ping6 -c2 -W5 "2001:db8::1${ipRand}" # Test hot plugging a container nic with different settings to profile with the same name. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=bridged \ name=eth0 \ parent=${brName} \ @@ -165,7 +165,7 @@ test_container_devices_nic_bridged() { fi # Check custom MTU is applied on hot-plug. - if ! lxc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -177,13 +177,13 @@ test_container_devices_nic_bridged() { fi # Check custom MAC is applied on hot-plug. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Test removing hot plugged device and check profile nic is restored. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check routes are removed on hot-plug. if ip -4 r list dev "${brName}" | grep "192.0.2.2${ipRand}" ; then @@ -216,7 +216,7 @@ test_container_devices_nic_bridged() { fi # Check profile custom MTU is applied on hot-removal. - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -228,7 +228,7 @@ test_container_devices_nic_bridged() { fi # Test hot plugging a container nic then updating it. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=bridged \ name=eth0 \ parent=${brName} \ @@ -237,35 +237,35 @@ test_container_devices_nic_bridged() { ipv6.routes="2001:db8::1${ipRand}/128" # Check removing a required option fails. - if lxc config device unset "${ctName}" eth0 parent ; then + if inc config device unset "${ctName}" eth0 parent ; then echo "shouldnt be able to unset invalrequiredid option" false fi # Check updating an invalid option fails. - if lxc config device set "${ctName}" eth0 invalid.option "invalid value" ; then + if inc config device set "${ctName}" eth0 invalid.option "invalid value" ; then echo "shouldnt be able to set invalid option" false fi # Check setting invalid IPv4 route. - if lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.1/33" ; then + if inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.1/33" ; then echo "shouldnt be able to set invalid ipv4.routes value" false fi # Check setting invalid IPv6 route. - if lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::1/129" ; then + if inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::1/129" ; then echo "shouldnt be able to set invalid ipv6.routes value" false fi - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" - lxc config device set "${ctName}" eth0 limits.ingress 3Mbit - lxc config device set "${ctName}" eth0 limits.egress 4Mbit - lxc config device set "${ctName}" eth0 mtu 1402 - lxc config device set "${ctName}" eth0 hwaddr "${ctMAC}" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" + inc config device set "${ctName}" eth0 limits.ingress 3Mbit + inc config device set "${ctName}" eth0 limits.egress 4Mbit + inc config device set "${ctName}" eth0 mtu 1402 + inc config device set "${ctName}" eth0 hwaddr "${ctMAC}" # Check original routes are removed on hot-plug. if ip -4 r list dev "${brName}" | grep "192.0.2.1${ipRand}" ; then @@ -298,36 +298,36 @@ test_container_devices_nic_bridged() { fi # Check custom MTU is applied update. - if ! lxc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then echo "mtu invalid" false fi # Check custom MAC is applied update. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Check that MTU is inherited from parent device when not specified on device. - lxc stop "${ctName}" --force - lxc config device unset "${ctName}" eth0 mtu - lxc network set "${brName}" bridge.mtu "1405" - lxc start "${ctName}" - if ! lxc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then + inc stop "${ctName}" --force + inc config device unset "${ctName}" eth0 mtu + inc network set "${brName}" bridge.mtu "1405" + inc start "${ctName}" + if ! inc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then echo "mtu not inherited from parent" false fi - lxc stop "${ctName}" --force - lxc network unset "${brName}" bridge.mtu - lxc start "${ctName}" + inc stop "${ctName}" --force + inc network unset "${brName}" bridge.mtu + inc start "${ctName}" # Add an external 3rd party route to the bridge interface and check that it and the container # routes remain when the network is reconfigured. ip -4 route add 192.0.2"${ipRand}".0/24 via 192.0.2.1"${ipRand}" dev "${brName}" # Now change something that will trigger a network restart - lxc network set "${brName}" ipv4.nat false + inc network set "${brName}" ipv4.nat false # Check external routes are applied on update. if ! ip -4 r list dev "${brName}" | grep "192.0.2${ipRand}.0/24 via 192.0.2.1${ipRand}" ; then @@ -348,21 +348,21 @@ test_container_devices_nic_bridged() { fi # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 ; then echo "unexpected volatile key remains" false fi # Test DHCP lease clearance. - lxc delete "${ctName}" -f - lxc launch testimage "${ctName}" -p "${ctName}" + inc delete "${ctName}" -f + inc launch testimage "${ctName}" -p "${ctName}" # Request DHCPv4 lease with custom name (to check managed name is allocated instead). - lxc exec "${ctName}" -- udhcpc -f -i eth0 -n -q -t5 -F "${ctName}custom" + inc exec "${ctName}" -- udhcpc -f -i eth0 -n -q -t5 -F "${ctName}custom" # Check DHCPv4 lease is allocated. - if ! grep -i "${ctMAC}" "${LXD_DIR}/networks/${brName}/dnsmasq.leases" ; then + if ! grep -i "${ctMAC}" "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" ; then echo "DHCPv4 lease not allocated" false fi @@ -375,113 +375,113 @@ test_container_devices_nic_bridged() { # Request DHCPv6 lease (if udhcpc6 is in busybox image). busyboxUdhcpc6=1 - if ! lxc exec "${ctName}" -- busybox --list | grep udhcpc6 ; then + if ! inc exec "${ctName}" -- busybox --list | grep udhcpc6 ; then busyboxUdhcpc6=0 fi if [ "$busyboxUdhcpc6" = "1" ]; then - lxc exec "${ctName}" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' + inc exec "${ctName}" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' fi - # Delete container, check LXD releases lease. - lxc delete "${ctName}" -f + # Delete container, check Incus releases lease. + inc delete "${ctName}" -f # Wait for DHCP release to be processed. sleep 2 # Check DHCPv4 lease is released (space before the MAC important to avoid mismatching IPv6 lease). - if grep -i " ${ctMAC}" "${LXD_DIR}/networks/${brName}/dnsmasq.leases" ; then + if grep -i " ${ctMAC}" "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" ; then echo "DHCPv4 lease not released" false fi # Check DHCPv6 lease is released. - if grep -i " ${ctName}" "${LXD_DIR}/networks/${brName}/dnsmasq.leases" ; then + if grep -i " ${ctName}" "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" ; then echo "DHCPv6 lease not released" false fi # Check dnsmasq host config file is removed. - if [ -f "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then + if [ -f "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then echo "dnsmasq host config file not removed" false fi # Check dnsmasq host file is updated on new device. - lxc init testimage "${ctName}" -p "${ctName}" - lxc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 ipv4.address=192.0.2.200 ipv6.address=2001:db8::200 + inc init testimage "${ctName}" -p "${ctName}" + inc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 ipv4.address=192.0.2.200 ipv6.address=2001:db8::200 - ls -lR "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/" + ls -lR "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/" - if ! grep "192.0.2.200" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then + if ! grep "192.0.2.200" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then echo "dnsmasq host config not updated with IPv4 address" false fi - if ! grep "2001:db8::200" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then + if ! grep "2001:db8::200" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then echo "dnsmasq host config not updated with IPv6 address" false fi - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 - if grep "192.0.2.200" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then + if grep "192.0.2.200" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then echo "dnsmasq host config still has old IPv4 address" false fi - if grep "2001:db8::200" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then + if grep "2001:db8::200" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ; then echo "dnsmasq host config still has old IPv6 address" false fi # Check dnsmasq leases file removed if DHCP disabled and that device can be removed. - lxc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 - lxc start "${ctName}" - lxc exec "${ctName}" -- udhcpc -f -i eth0 -n -q -t5 - lxc network set "${brName}" ipv4.address none - lxc network set "${brName}" ipv6.address none + inc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 + inc start "${ctName}" + inc exec "${ctName}" -- udhcpc -f -i eth0 -n -q -t5 + inc network set "${brName}" ipv4.address none + inc network set "${brName}" ipv6.address none # Confirm IPv6 is disabled. [ "$(cat /proc/sys/net/ipv6/conf/${brName}/disable_ipv6)" = "1" ] - if [ -f "${LXD_DIR}/networks/${brName}/dnsmasq.leases" ] ; then + if [ -f "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" ] ; then echo "dnsmasq.leases file still present after disabling DHCP" false fi - if [ -f "${LXD_DIR}/networks/${brName}/dnsmasq.pid" ] ; then + if [ -f "${INCUS_DIR}/networks/${brName}/dnsmasq.pid" ] ; then echo "dnsmasq.pid file still present after disabling DHCP" false fi - lxc profile device unset "${ctName}" eth0 ipv6.routes - lxc config device remove "${ctName}" eth0 - lxc stop -f "${ctName}" - if [ -f "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then + inc profile device unset "${ctName}" eth0 ipv6.routes + inc config device remove "${ctName}" eth0 + inc stop -f "${ctName}" + if [ -f "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then echo "dnsmasq host config file not removed from network" false fi # Re-enable DHCP on network. - lxc network set "${brName}" ipv4.address 192.0.2.1/24 - lxc network set "${brName}" ipv6.address 2001:db8::1/64 - lxc profile device set "${ctName}" eth0 ipv6.routes "2001:db8::1${ipRand}/128" + inc network set "${brName}" ipv4.address 192.0.2.1/24 + inc network set "${brName}" ipv6.address 2001:db8::1/64 + inc profile device set "${ctName}" eth0 ipv6.routes "2001:db8::1${ipRand}/128" # Confirm IPv6 is re-enabled. [ "$(cat /proc/sys/net/ipv6/conf/${brName}/disable_ipv6)" = "0" ] # Check dnsmasq host file is created on add. - lxc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 - if [ ! -f "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then + inc config device add "${ctName}" eth0 nic nictype=bridged parent="${brName}" name=eth0 + if [ ! -f "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then echo "dnsmasq host config file not created" false fi # Check connecting device to non-managed bridged. ip link add "${ctName}" type dummy - lxc config device set "${ctName}" eth0 parent "${ctName}" - if [ -f "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then + inc config device set "${ctName}" eth0 parent "${ctName}" + if [ -f "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" ] ; then echo "dnsmasq host config file not removed from old network" false fi @@ -490,29 +490,29 @@ test_container_devices_nic_bridged() { # Linked network tests. # Can't use network property when parent is set. - ! lxc profile device set "${ctName}" eth0 network="${brName}" + ! inc profile device set "${ctName}" eth0 network="${brName}" # Remove mtu, nictype and parent settings and assign network in one command. - lxc profile device set "${ctName}" eth0 mtu="" parent="" nictype="" network="${brName}" + inc profile device set "${ctName}" eth0 mtu="" parent="" nictype="" network="${brName}" # Can't remove network if parent not specified. - ! lxc profile device unset "${ctName}" eth0 network + ! inc profile device unset "${ctName}" eth0 network # Can't use some settings when network is set. - ! lxc profile device set "${ctName}" eth0 nictype="bridged" - ! lxc profile device set "${ctName}" eth0 mtu="1400" - ! lxc profile device set "${ctName}" eth0 maas.subnet.ipv4="test" - ! lxc profile device set "${ctName}" eth0 maas.subnet.ipv6="test" + ! inc profile device set "${ctName}" eth0 nictype="bridged" + ! inc profile device set "${ctName}" eth0 mtu="1400" + ! inc profile device set "${ctName}" eth0 maas.subnet.ipv4="test" + ! inc profile device set "${ctName}" eth0 maas.subnet.ipv6="test" # Can't set static IP that isn't part of network's subnet. - ! lxc profile device set "${ctName}" eth0 ipv4.address="192.0.4.2" - ! lxc profile device set "${ctName}" eth0 ipv6.address="2001:db8:2::2" + ! inc profile device set "${ctName}" eth0 ipv4.address="192.0.4.2" + ! inc profile device set "${ctName}" eth0 ipv6.address="2001:db8:2::2" # Test bridge MTU is inherited. - lxc network set "${brName}" bridge.mtu 1400 - lxc config device remove "${ctName}" eth0 - lxc start "${ctName}" - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + inc network set "${brName}" bridge.mtu 1400 + inc config device remove "${ctName}" eth0 + inc start "${ctName}" + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "container mtu has not been inherited from network" false fi @@ -527,138 +527,138 @@ test_container_devices_nic_bridged() { false fi - lxc stop -f "${ctName}" - lxc network unset "${brName}" bridge.mtu + inc stop -f "${ctName}" + inc network unset "${brName}" bridge.mtu # Test stateful DHCP static IP checks. - ! lxc config device override "${ctName}" eth0 ipv4.address="192.0.4.2" + ! inc config device override "${ctName}" eth0 ipv4.address="192.0.4.2" - lxc network set "${brName}" ipv4.dhcp false - ! lxc config device override "${ctName}" eth0 ipv4.address="192.0.2.2" - lxc network unset "${brName}" ipv4.dhcp - lxc config device override "${ctName}" eth0 ipv4.address="192.0.2.2" + inc network set "${brName}" ipv4.dhcp false + ! inc config device override "${ctName}" eth0 ipv4.address="192.0.2.2" + inc network unset "${brName}" ipv4.dhcp + inc config device override "${ctName}" eth0 ipv4.address="192.0.2.2" - ! lxc config device set "${ctName}" eth0 ipv6.address="2001:db8:2::2" + ! inc config device set "${ctName}" eth0 ipv6.address="2001:db8:2::2" - lxc network set "${brName}" ipv6.dhcp=false ipv6.dhcp.stateful=false - ! lxc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" - lxc network set "${brName}" ipv6.dhcp=true ipv6.dhcp.stateful=false - ! lxc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" - lxc network set "${brName}" ipv6.dhcp=false ipv6.dhcp.stateful=true - ! lxc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" + inc network set "${brName}" ipv6.dhcp=false ipv6.dhcp.stateful=false + ! inc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" + inc network set "${brName}" ipv6.dhcp=true ipv6.dhcp.stateful=false + ! inc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" + inc network set "${brName}" ipv6.dhcp=false ipv6.dhcp.stateful=true + ! inc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" - lxc network unset "${brName}" ipv6.dhcp - lxc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" + inc network unset "${brName}" ipv6.dhcp + inc config device set "${ctName}" eth0 ipv6.address="2001:db8::2" # Test port isolation. if bridge link set help 2>&1 | grep isolated ; then - lxc config device set "${ctName}" eth0 security.port_isolation true - lxc start "${ctName}" + inc config device set "${ctName}" eth0 security.port_isolation true + inc start "${ctName}" bridge -d link show dev "${vethHostName}" | grep "isolated on" - lxc stop -f "${ctName}" + inc stop -f "${ctName}" else echo "bridge command doesn't support port isolation, skipping port isolation checks" fi # Test interface naming scheme. - lxc init testimage test-naming - lxc start test-naming - lxc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^veth - lxc stop -f test-naming + inc init testimage test-naming + inc start test-naming + inc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^veth + inc stop -f test-naming - lxc config set instances.nic.host_name random - lxc start test-naming - lxc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^veth - lxc stop -f test-naming + inc config set instances.nic.host_name random + inc start test-naming + inc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^veth + inc stop -f test-naming - lxc config set instances.nic.host_name mac - lxc start test-naming - lxc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^lxd - lxc stop -f test-naming + inc config set instances.nic.host_name mac + inc start test-naming + inc query "/1.0/instances/test-naming/state" | jq -r .network.eth0.host_name | grep ^inc + inc stop -f test-naming - lxc config unset instances.nic.host_name - lxc delete -f test-naming + inc config unset instances.nic.host_name + inc delete -f test-naming # Test new container with conflicting addresses can be created as a copy. - lxc config device set "${ctName}" eth0 \ + inc config device set "${ctName}" eth0 \ ipv4.address=192.0.2.232 \ hwaddr="" # Remove static MAC so that copies use new MAC (as changing MAC triggers device remove/add on snapshot restore). - grep -F "192.0.2.232" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" - lxc copy "${ctName}" foo # Gets new MAC address but IPs still conflict. - ! stat "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false - lxc snapshot foo - lxc export foo foo.tar.gz - ! lxc start foo || false - lxc config device set foo eth0 \ + grep -F "192.0.2.232" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0" + inc copy "${ctName}" foo # Gets new MAC address but IPs still conflict. + ! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false + inc snapshot foo + inc export foo foo.tar.gz + ! inc start foo || false + inc config device set foo eth0 \ ipv4.address=192.0.2.233 \ ipv6.address=2001:db8::3 - grep -F "192.0.2.233" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" - lxc start foo - lxc stop -f foo + grep -F "192.0.2.233" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" + inc start foo + inc stop -f foo # Test container snapshot with conflicting addresses can be restored. - lxc restore foo snap0 # Test restore, IPs conflict on config device update (due to only IPs changing). - ! stat "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to non-user requested update failing). - lxc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' - ! lxc start foo || false - lxc config device set foo eth0 \ + inc restore foo snap0 # Test restore, IPs conflict on config device update (due to only IPs changing). + ! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to non-user requested update failing). + inc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' + ! inc start foo || false + inc config device set foo eth0 \ hwaddr="0a:92:a7:0d:b7:c9" \ ipv4.address=192.0.2.233 \ ipv6.address=2001:db8::3 - lxc start foo - lxc stop -f foo - - lxc restore foo snap0 # Test restore, IPs conflict on config device remove/add (due to MAC change). - ! stat "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to MAC change). - lxc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' - ! lxc start foo || false - lxc config device set foo eth0 \ + inc start foo + inc stop -f foo + + inc restore foo snap0 # Test restore, IPs conflict on config device remove/add (due to MAC change). + ! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to MAC change). + inc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' + ! inc start foo || false + inc config device set foo eth0 \ hwaddr="0a:92:a7:0d:b7:c9" \ ipv4.address=192.0.2.233 \ ipv6.address=2001:db8::3 - grep -F "192.0.2.233" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" - lxc start foo - lxc delete -f foo + grep -F "192.0.2.233" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" + inc start foo + inc delete -f foo # Test container with conflicting addresses can be restored from backup. - lxc import foo.tar.gz - ! stat "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false - ! lxc start foo || false - lxc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' - lxc config show foo/snap0 | grep -F 'ipv4.address: 192.0.2.232' - lxc config device set foo eth0 \ + inc import foo.tar.gz + ! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false + ! inc start foo || false + inc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232' + inc config show foo/snap0 | grep -F 'ipv4.address: 192.0.2.232' + inc config device set foo eth0 \ hwaddr="0a:92:a7:0d:b7:c9" \ ipv4.address=192.0.2.233 \ ipv6.address=2001:db8::3 - grep -F "192.0.2.233" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" - lxc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.233' - lxc start foo + grep -F "192.0.2.233" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" + inc config device get foo eth0 ipv4.address | grep -Fx '192.0.2.233' + inc start foo # Check MAC conflict detection: - ! lxc config device set "${ctName}" eth0 hwaddr="0a:92:a7:0d:b7:c9" || false + ! inc config device set "${ctName}" eth0 hwaddr="0a:92:a7:0d:b7:c9" || false # Test container with conflicting addresses rebuilds DHCP lease if original conflicting instance is removed. - lxc delete -f foo - ! stat "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false - lxc import foo.tar.gz + inc delete -f foo + ! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false + inc import foo.tar.gz rm foo.tar.gz - ! lxc start foo || false - lxc delete "${ctName}" -f - lxc start foo - grep -F "192.0.2.232" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" - lxc delete -f foo + ! inc start foo || false + inc delete "${ctName}" -f + inc start foo + grep -F "192.0.2.232" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" + inc delete -f foo # Test container without extra network configuration can be restored from backup. - lxc init testimage foo -p "${ctName}" - lxc export foo foo.tar.gz - lxc import foo.tar.gz foo2 + inc init testimage foo -p "${ctName}" + inc export foo foo.tar.gz + inc import foo.tar.gz foo2 rm foo.tar.gz - lxc profile assign foo2 "${ctName}" + inc profile assign foo2 "${ctName}" # Test container start will fail due to volatile MAC conflict. - lxc config get foo volatile.eth0.hwaddr | grep -Fx "$(lxc config get foo2 volatile.eth0.hwaddr)" - ! lxc start foo2 || false - lxc delete -f foo foo2 + inc config get foo volatile.eth0.hwaddr | grep -Fx "$(inc config get foo2 volatile.eth0.hwaddr)" + ! inc start foo2 || false + inc delete -f foo foo2 # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) @@ -668,6 +668,6 @@ test_container_devices_nic_bridged() { fi # Cleanup. - lxc profile delete "${ctName}" - lxc network delete "${brName}" + inc profile delete "${ctName}" + inc network delete "${brName}" } diff --git a/test/suites/container_devices_nic_bridged_acl.sh b/test/suites/container_devices_nic_bridged_acl.sh index 7d7dcd265e0..d3769601c3a 100644 --- a/test/suites/container_devices_nic_bridged_acl.sh +++ b/test/suites/container_devices_nic_bridged_acl.sh @@ -1,8 +1,8 @@ test_container_devices_nic_bridged_acl() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - firewallDriver=$(lxc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') + firewallDriver=$(inc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') if [ "$firewallDriver" != "xtables" ] && [ "$firewallDriver" != "nftables" ]; then echo "Unrecognised firewall driver: ${firewallDriver}" @@ -10,69 +10,69 @@ test_container_devices_nic_bridged_acl() { fi ctPrefix="nt$$" - brName="lxdt$$" + brName="inct$$" # Standard bridge. - lxc network create "${brName}" \ + inc network create "${brName}" \ ipv6.dhcp.stateful=true \ ipv4.address=192.0.2.1/24 \ ipv6.address=2001:db8::1/64 # Create empty ACL and apply to network. - lxc network acl create "${brName}A" - lxc network set "${brName}" security.acls="${brName}A" + inc network acl create "${brName}A" + inc network set "${brName}" security.acls="${brName}A" # Check ACL jump rules, and chain with default reject rules created. if [ "$firewallDriver" = "xtables" ]; then - iptables -S | grep -c "\-j lxd_acl_${brName}" | grep 4 - iptables -S "lxd_acl_${brName}" | grep -c "\-j REJECT" | grep 2 + iptables -S | grep -c "\-j incus_acl_${brName}" | grep 4 + iptables -S "incus_acl_${brName}" | grep -c "\-j REJECT" | grep 2 else - nft -nn list chain inet lxd "aclin.${brName}" | grep -c "jump acl.${brName}" | grep 1 - nft -nn list chain inet lxd "aclout.${brName}" | grep -c "jump acl.${brName}" | grep 1 - nft -nn list chain inet lxd "aclfwd.${brName}" | grep -c "jump acl.${brName}" | grep 2 - nft -nn list chain inet lxd "acl.${brName}" | grep -c "reject" | grep 2 + nft -nn list chain inet incus "aclin.${brName}" | grep -c "jump acl.${brName}" | grep 1 + nft -nn list chain inet incus "aclout.${brName}" | grep -c "jump acl.${brName}" | grep 1 + nft -nn list chain inet incus "aclfwd.${brName}" | grep -c "jump acl.${brName}" | grep 2 + nft -nn list chain inet incus "acl.${brName}" | grep -c "reject" | grep 2 fi # Unset ACLs and check the firewall config is cleaned up. - lxc network unset "${brName}" security.acls + inc network unset "${brName}" security.acls if [ "$firewallDriver" = "xtables" ]; then - ! iptables -S | grep "\-j lxd_acl_${brName}" || false - ! iptables -S "lxd_acl_${brName}" || false + ! iptables -S | grep "\-j incus_acl_${brName}" || false + ! iptables -S "incus_acl_${brName}" || false else - ! nft -nn list chain inet lxd "aclin.${brName}" || false - ! nft -nn list chain inet lxd "aclout.${brName}" || false - ! nft -nn list chain inet lxd "aclfwd.${brName}" || false - ! nft -nn list chain inet lxd "acl.${brName}" || false + ! nft -nn list chain inet incus "aclin.${brName}" || false + ! nft -nn list chain inet incus "aclout.${brName}" || false + ! nft -nn list chain inet incus "aclfwd.${brName}" || false + ! nft -nn list chain inet incus "acl.${brName}" || false fi # Set ACLs, then delete network and check the firewall config is cleaned up. - lxc network set "${brName}" security.acls="${brName}A" + inc network set "${brName}" security.acls="${brName}A" # Check ACL jump rules, and chain with default reject rules created. if [ "$firewallDriver" = "xtables" ]; then - iptables -S | grep -c "\-j lxd_acl_${brName}" | grep 4 - iptables -S "lxd_acl_${brName}" | grep -c "\-j REJECT" | grep 2 + iptables -S | grep -c "\-j incus_acl_${brName}" | grep 4 + iptables -S "incus_acl_${brName}" | grep -c "\-j REJECT" | grep 2 else - nft -nn list chain inet lxd "aclin.${brName}" | grep -c "jump acl.${brName}" | grep 1 - nft -nn list chain inet lxd "aclout.${brName}" | grep -c "jump acl.${brName}" | grep 1 - nft -nn list chain inet lxd "aclfwd.${brName}" | grep -c "jump acl.${brName}" | grep 2 - nft -nn list chain inet lxd "acl.${brName}" | grep -c "reject" | grep 2 + nft -nn list chain inet incus "aclin.${brName}" | grep -c "jump acl.${brName}" | grep 1 + nft -nn list chain inet incus "aclout.${brName}" | grep -c "jump acl.${brName}" | grep 1 + nft -nn list chain inet incus "aclfwd.${brName}" | grep -c "jump acl.${brName}" | grep 2 + nft -nn list chain inet incus "acl.${brName}" | grep -c "reject" | grep 2 fi # Delete network and check the firewall config is cleaned up. - lxc network delete "${brName}" + inc network delete "${brName}" if [ "$firewallDriver" = "xtables" ]; then - ! iptables -S | grep "\-j lxd_acl_${brName}" || false - ! iptables -S "lxd_acl_${brName}" || false + ! iptables -S | grep "\-j incus_acl_${brName}" || false + ! iptables -S "incus_acl_${brName}" || false else - ! nft -nn list chain inet lxd "aclin.${brName}" || false - ! nft -nn list chain inet lxd "aclout.${brName}" || false - ! nft -nn list chain inet lxd "aclfwd.${brName}" || false - ! nft -nn list chain inet lxd "acl.${brName}" || false + ! nft -nn list chain inet incus "aclin.${brName}" || false + ! nft -nn list chain inet incus "aclout.${brName}" || false + ! nft -nn list chain inet incus "aclfwd.${brName}" || false + ! nft -nn list chain inet incus "acl.${brName}" || false fi # Create network and specify ACL at create time. - lxc network create "${brName}" \ + inc network create "${brName}" \ ipv6.dhcp.stateful=true \ ipv4.address=192.0.2.1/24 \ ipv6.address=2001:db8::1/64 \ @@ -80,114 +80,114 @@ test_container_devices_nic_bridged_acl() { raw.dnsmasq='host-record=testhost.test,192.0.2.1,2001:db8::1' # Change default actions to drop. - lxc network set "${brName}" \ + inc network set "${brName}" \ security.acls.default.ingress.action=drop \ security.acls.default.egress.action=drop # Check default reject rules changed to drop. if [ "$firewallDriver" = "xtables" ]; then - iptables -S "lxd_acl_${brName}" | grep -c "\-j DROP" | grep 2 + iptables -S "incus_acl_${brName}" | grep -c "\-j DROP" | grep 2 else - nft -nn list chain inet lxd "acl.${brName}" | grep -c "drop" | grep 2 + nft -nn list chain inet incus "acl.${brName}" | grep -c "drop" | grep 2 fi # Change default actions to reject. - lxc network set "${brName}" \ + inc network set "${brName}" \ security.acls.default.ingress.action=reject \ security.acls.default.egress.action=reject # Check default reject rules changed to reject. if [ "$firewallDriver" = "xtables" ]; then - iptables -S "lxd_acl_${brName}" | grep -c "\-j REJECT" | grep 2 + iptables -S "incus_acl_${brName}" | grep -c "\-j REJECT" | grep 2 else - nft -nn list chain inet lxd "acl.${brName}" | grep -c "reject" | grep 2 + nft -nn list chain inet incus "acl.${brName}" | grep -c "reject" | grep 2 fi # Create profile for new containers. - lxc profile copy default "${ctPrefix}" + inc profile copy default "${ctPrefix}" # Modify profile nictype and parent in atomic operation to ensure validation passes. - lxc profile show "${ctPrefix}" | sed "s/nictype: p2p/network: ${brName}/" | lxc profile edit "${ctPrefix}" + inc profile show "${ctPrefix}" | sed "s/nictype: p2p/network: ${brName}/" | inc profile edit "${ctPrefix}" - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc start "${ctPrefix}A" + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc start "${ctPrefix}A" # Check DHCP works for baseline rules. - lxc exec "${ctPrefix}A" -- udhcpc -f -i eth0 -n -q -t5 2>&1 | grep 'obtained' + inc exec "${ctPrefix}A" -- udhcpc -f -i eth0 -n -q -t5 2>&1 | grep 'obtained' # Request DHCPv6 lease (if udhcpc6 is in busybox image). busyboxUdhcpc6=1 - if ! lxc exec "${ctPrefix}A" -- busybox --list | grep udhcpc6 ; then + if ! inc exec "${ctPrefix}A" -- busybox --list | grep udhcpc6 ; then busyboxUdhcpc6=0 fi if [ "$busyboxUdhcpc6" = "1" ]; then - lxc exec "${ctPrefix}A" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' + inc exec "${ctPrefix}A" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' fi # Add static IPs to container. - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 + inc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 # Check ICMP to bridge is blocked. - ! lxc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 || false - ! lxc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 || false # Allow ICMP to bridge host. - lxc network acl rule add "${brName}A" egress action=allow destination=192.0.2.1/32 protocol=icmp4 icmp_type=8 - lxc network acl rule add "${brName}A" egress action=allow destination=2001:db8::1/128 protocol=icmp6 icmp_type=128 - lxc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 + inc network acl rule add "${brName}A" egress action=allow destination=192.0.2.1/32 protocol=icmp4 icmp_type=8 + inc network acl rule add "${brName}A" egress action=allow destination=2001:db8::1/128 protocol=icmp6 icmp_type=128 + inc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 # Check DNS resolution (and connection tracking in the process). - lxc exec "${ctPrefix}A" -- nslookup -type=a testhost.test 192.0.2.1 - lxc exec "${ctPrefix}A" -- nslookup -type=aaaa testhost.test 192.0.2.1 - lxc exec "${ctPrefix}A" -- nslookup -type=a testhost.test 2001:db8::1 - lxc exec "${ctPrefix}A" -- nslookup -type=aaaa testhost.test 2001:db8::1 + inc exec "${ctPrefix}A" -- nslookup -type=a testhost.test 192.0.2.1 + inc exec "${ctPrefix}A" -- nslookup -type=aaaa testhost.test 192.0.2.1 + inc exec "${ctPrefix}A" -- nslookup -type=a testhost.test 2001:db8::1 + inc exec "${ctPrefix}A" -- nslookup -type=aaaa testhost.test 2001:db8::1 # Add new ACL to network with drop rule that prevents ICMP ping to check drop rules get higher priority. - lxc network acl create "${brName}B" - lxc network acl rule add "${brName}B" egress action=drop protocol=icmp4 icmp_type=8 - lxc network acl rule add "${brName}B" egress action=drop protocol=icmp6 icmp_type=128 + inc network acl create "${brName}B" + inc network acl rule add "${brName}B" egress action=drop protocol=icmp4 icmp_type=8 + inc network acl rule add "${brName}B" egress action=drop protocol=icmp6 icmp_type=128 - lxc network set "${brName}" security.acls="${brName}A,${brName}B" + inc network set "${brName}" security.acls="${brName}A,${brName}B" # Check egress ICMP ping to bridge is blocked. - ! lxc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 || false - ! lxc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -4 -W5 192.0.2.1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -6 -W5 2001:db8::1 || false # Check ingress ICMPv4 ping is blocked. ! ping -c1 -4 192.0.2.2 || false # Allow ingress ICMPv4 ping. - lxc network acl rule add "${brName}A" ingress action=allow destination=192.0.2.2/32 protocol=icmp4 icmp_type=8 + inc network acl rule add "${brName}A" ingress action=allow destination=192.0.2.2/32 protocol=icmp4 icmp_type=8 ping -c1 -4 192.0.2.2 # Check egress ICMPv6 ping from host to bridge is allowed by default (for dnsmasq probing). ping -c1 -6 2001:db8::2 # Check egress TCP. - lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 53 - lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 53 + inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 53 + inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 53 nc -l -p 8080 -q0 -s 192.0.2.1 /dev/null & nc -l -p 8080 -q0 -s 2001:db8::1 /dev/null & - ! lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 8080 || false - ! lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 8080 || false + ! inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 8080 || false + ! inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 8080 || false - lxc network acl rule add "${brName}A" egress action=allow destination=192.0.2.1/32 protocol=tcp destination_port=8080 - lxc network acl rule add "${brName}A" egress action=allow destination=2001:db8::1/128 protocol=tcp destination_port=8080 + inc network acl rule add "${brName}A" egress action=allow destination=192.0.2.1/32 protocol=tcp destination_port=8080 + inc network acl rule add "${brName}A" egress action=allow destination=2001:db8::1/128 protocol=tcp destination_port=8080 - lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 8080 - lxc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 8080 + inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 192.0.2.1 8080 + inc exec "${ctPrefix}A" --disable-stdin -- nc -w2 2001:db8::1 8080 # Check can't delete ACL that is in use. - ! lxc network acl delete "${brName}A" || false + ! inc network acl delete "${brName}A" || false - lxc delete -f "${ctPrefix}A" - lxc profile delete "${ctPrefix}" - lxc network delete "${brName}" - lxc network acl delete "${brName}A" - lxc network acl delete "${brName}B" + inc delete -f "${ctPrefix}A" + inc profile delete "${ctPrefix}" + inc network delete "${brName}" + inc network acl delete "${brName}A" + inc network acl delete "${brName}B" } diff --git a/test/suites/container_devices_nic_bridged_filtering.sh b/test/suites/container_devices_nic_bridged_filtering.sh index e4aae07a8fd..fba030c9913 100644 --- a/test/suites/container_devices_nic_bridged_filtering.sh +++ b/test/suites/container_devices_nic_bridged_filtering.sh @@ -1,8 +1,8 @@ test_container_devices_nic_bridged_filtering() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - firewallDriver=$(lxc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') + firewallDriver=$(inc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') if [ "$firewallDriver" != "xtables" ] && [ "$firewallDriver" != "nftables" ]; then echo "Unrecognised firewall driver: ${firewallDriver}" @@ -20,53 +20,53 @@ test_container_devices_nic_bridged_filtering() { startNicCount=$(find /sys/class/net | wc -l) ctPrefix="nt$$" - brName="lxdt$$" + brName="inct$$" # Standard bridge with random subnet and a bunch of options. - lxc network create "${brName}" - lxc network set "${brName}" dns.mode managed - lxc network set "${brName}" dns.domain blah - lxc network set "${brName}" ipv4.nat true + inc network create "${brName}" + inc network set "${brName}" dns.mode managed + inc network set "${brName}" dns.domain blah + inc network set "${brName}" ipv4.nat true # Routing is required for container to container traffic as filtering requires br_netfilter module. # This then causes bridged traffic to go through the FORWARD chain in iptables. - lxc network set "${brName}" ipv4.routing true - lxc network set "${brName}" ipv6.routing true + inc network set "${brName}" ipv4.routing true + inc network set "${brName}" ipv6.routing true - lxc network set "${brName}" ipv6.dhcp.stateful true - lxc network set "${brName}" bridge.hwaddr 00:11:22:33:44:55 - lxc network set "${brName}" ipv4.address 192.0.2.1/24 - lxc network set "${brName}" ipv6.address 2001:db8:1::1/64 + inc network set "${brName}" ipv6.dhcp.stateful true + inc network set "${brName}" bridge.hwaddr 00:11:22:33:44:55 + inc network set "${brName}" ipv4.address 192.0.2.1/24 + inc network set "${brName}" ipv6.address 2001:db8:1::1/64 [ "$(cat /sys/class/net/${brName}/address)" = "00:11:22:33:44:55" ] # Create profile for new containers. - lxc profile copy default "${ctPrefix}" + inc profile copy default "${ctPrefix}" # Modify profile nictype and parent in atomic operation to ensure validation passes. - lxc profile show "${ctPrefix}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${brName}/" | lxc profile edit "${ctPrefix}" + inc profile show "${ctPrefix}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${brName}/" | inc profile edit "${ctPrefix}" # Launch first container. - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc config device add "${ctPrefix}A" eth0 nic nictype=nic name=eth0 nictype=bridged parent="${brName}" - lxc start "${ctPrefix}A" - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc config device add "${ctPrefix}A" eth0 nic nictype=nic name=eth0 nictype=bridged parent="${brName}" + inc start "${ctPrefix}A" + inc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 # Launch second container. - lxc init testimage "${ctPrefix}B" -p "${ctPrefix}" - lxc config device add "${ctPrefix}B" eth0 nic nictype=nic name=eth0 nictype=bridged parent="${brName}" - lxc start "${ctPrefix}B" - lxc exec "${ctPrefix}B" -- ip a add 192.0.2.3/24 dev eth0 + inc init testimage "${ctPrefix}B" -p "${ctPrefix}" + inc config device add "${ctPrefix}B" eth0 nic nictype=nic name=eth0 nictype=bridged parent="${brName}" + inc start "${ctPrefix}B" + inc exec "${ctPrefix}B" -- ip a add 192.0.2.3/24 dev eth0 # Check basic connectivity without any filtering. - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 # Enable MAC filtering on CT A and test. - lxc config device set "${ctPrefix}A" eth0 security.mac_filtering true - ctAMAC=$(lxc config get "${ctPrefix}A" volatile.eth0.hwaddr) + inc config device set "${ctPrefix}A" eth0 security.mac_filtering true + ctAMAC=$(inc config get "${ctPrefix}A" volatile.eth0.hwaddr) # Check MAC filter is present in firewall. - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) if [ "$firewallDriver" = "xtables" ]; then if ! ebtables --concurrent -L --Lmac2 --Lx | grep -e "-s ! ${ctAMAC} -i ${ctAHost} -j DROP" ; then echo "MAC filter not applied as part of mac_filtering in ebtables" @@ -79,7 +79,7 @@ test_container_devices_nic_bridged_filtering() { for table in "in" "fwd" do - rules=$(nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0") + rules=$(nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0") if ! echo "${rules}" | grep -e "iifname \"${ctAHost}\" ether saddr != ${ctAMAC} drop"; then echo "MAC filter not applied as part of mac_filtering in nftables (${table}.${ctPrefix}A.eth0)" @@ -97,29 +97,29 @@ test_container_devices_nic_bridged_filtering() { fi # Setup fake MAC inside container. - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address 00:11:22:33:44:56 up + inc exec "${ctPrefix}A" -- ip link set dev eth0 address 00:11:22:33:44:56 up # Check that ping is no longer working (i.e its filtered after fake MAC setup). - if lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then + if inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then echo "MAC filter not working to host" false fi # Check that ping is no longer working (i.e its filtered after fake MAC setup). - if lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then + if inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then echo "MAC filter not working to other container" false fi # Restore real MAC - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up + inc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up # Check basic connectivity with MAC filtering but real MAC configured. - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 # Stop CT A and check filters are cleaned up. - lxc stop -f "${ctPrefix}A" + inc stop -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "-s ! ${ctAMAC} -i ${ctAHost} -j DROP" ; then echo "MAC filter still applied as part of mac_filtering in ebtables" @@ -128,7 +128,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "MAC filter still applied as part of mac_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -136,21 +136,21 @@ test_container_devices_nic_bridged_filtering() { fi # Add a fake IPv4 and check connectivity - lxc start "${ctPrefix}A" - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.254/24 dev eth0 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 + inc start "${ctPrefix}A" + inc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up + inc exec "${ctPrefix}A" -- ip a add 192.0.2.254/24 dev eth0 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 # Enable IPv4 filtering on CT A and test (disable security.mac_filtering to check its applied too). - lxc config device set "${ctPrefix}A" eth0 ipv4.address 192.0.2.2 - lxc config device set "${ctPrefix}A" eth0 security.mac_filtering false - lxc config device set "${ctPrefix}A" eth0 security.ipv4_filtering true - lxc config device set "${ctPrefix}A" eth0 ipv4.routes 198.51.100.0/24 - lxc config device set "${ctPrefix}A" eth0 ipv4.routes.external 203.0.113.0/24 + inc config device set "${ctPrefix}A" eth0 ipv4.address 192.0.2.2 + inc config device set "${ctPrefix}A" eth0 security.mac_filtering false + inc config device set "${ctPrefix}A" eth0 security.ipv4_filtering true + inc config device set "${ctPrefix}A" eth0 ipv4.routes 198.51.100.0/24 + inc config device set "${ctPrefix}A" eth0 ipv4.routes.external 203.0.113.0/24 # Check MAC and IPv4 filter is present in firewall. - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) if [ "$firewallDriver" = "xtables" ]; then if ! ebtables --concurrent -L --Lmac2 --Lx | grep -e "-s ! ${ctAMAC} -i ${ctAHost} -j DROP" ; then echo "MAC filter not applied as part of ipv4_filtering in ebtables" @@ -171,35 +171,35 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether saddr != ${ctAMAC} drop"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether saddr != ${ctAMAC} drop"; then echo "MAC filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ether != ${ctAMAC} drop"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ether != ${ctAMAC} drop"; then echo "MAC ARP filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 192.0.2.2 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 192.0.2.2 accept"; then echo "IPv4 filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 192.0.2.2 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 192.0.2.2 accept"; then echo "IPv4 ARP filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 198.51.100.0/24 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 198.51.100.0/24 accept"; then echo "IPv4 filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 198.51.100.0/24 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 198.51.100.0/24 accept"; then echo "IPv4 ARP filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 203.0.113.0/24 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ip saddr 203.0.113.0/24 accept"; then echo "IPv4 filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi - if ! nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 203.0.113.0/24 accept"; then + if ! nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" arp saddr ip 203.0.113.0/24 accept"; then echo "IPv4 ARP filter not applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -207,69 +207,69 @@ test_container_devices_nic_bridged_filtering() { fi # Check DHCPv4 allocation still works. - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up - lxc exec "${ctPrefix}A" -- udhcpc -f -i eth0 -n -q -t5 - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up + inc exec "${ctPrefix}A" -- udhcpc -f -i eth0 -n -q -t5 + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 # Check basic connectivity with IPv4 filtering and real IPs configured. - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3 # Add a fake IP - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.254/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 192.0.2.254/24 dev eth0 # Check that ping is no longer working (i.e its filtered after fake IP setup). - if lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then + if inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then echo "IPv4 filter not working to host" false fi # Check that ping is no longer working (i.e its filtered after fake IP setup). - if lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then + if inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then echo "IPv4 filter not working to other container" false fi # Add a fake IP within ipv4.routes range (198.51.100.0/24) - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 198.51.100.1/32 dev eth0 - lxc exec "${ctPrefix}A" -- ip r add 192.0.2.0/24 dev eth0 - lxc exec "${ctPrefix}B" -- ip r add 198.51.100.0/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 198.51.100.1/32 dev eth0 + inc exec "${ctPrefix}A" -- ip r add 192.0.2.0/24 dev eth0 + inc exec "${ctPrefix}B" -- ip r add 198.51.100.0/24 dev eth0 # Check that ping is still working (i.e the filter did not apply to the ipv4.routes subnet). - if ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then + if ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then echo "IPv4 filter is preventing traffic from within ipv4.routes" false fi # Check that ping is still working (i.e the filter did not apply to the ipv4.routes subnet). - if ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then + if ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then echo "IPv4 filter is preventing traffic from within ipv4.routes" false fi # Add a fake IP within ipv4.routes.external range (203.0.113.0/24) - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 203.0.113.1/32 dev eth0 - lxc exec "${ctPrefix}A" -- ip r add 192.0.2.0/24 dev eth0 - lxc exec "${ctPrefix}B" -- ip r add 203.0.113.0/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 203.0.113.1/32 dev eth0 + inc exec "${ctPrefix}A" -- ip r add 192.0.2.0/24 dev eth0 + inc exec "${ctPrefix}B" -- ip r add 203.0.113.0/24 dev eth0 # Check that ping is still working (i.e the filter did not apply to the ipv4.routes.external subnet). - if ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then + if ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1; then echo "IPv4 filter is preventing traffic from within ipv4.routes.external" false fi # Check that ping is still working (i.e the filter did not apply to the ipv4.routes.external subnet). - if ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then + if ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.3; then echo "IPv4 filter is preventing traffic from within ipv4.routes.external" false fi # Stop CT A and check filters are cleaned up in firewall. - lxc stop -f "${ctPrefix}A" + inc stop -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "${ctAHost}" ; then echo "IPv4 filter still applied as part of ipv4_filtering in ebtables" @@ -278,7 +278,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "IPv4 filter still applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -286,37 +286,37 @@ test_container_devices_nic_bridged_filtering() { fi # Remove static IP and check IP filter works with previous DHCP lease. - rm "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" - lxc config device unset "${ctPrefix}A" eth0 ipv4.address - lxc start "${ctPrefix}A" - if ! grep "192.0.2.2" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then + rm "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" + inc config device unset "${ctPrefix}A" eth0 ipv4.address + inc start "${ctPrefix}A" + if ! grep "192.0.2.2" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then echo "dnsmasq host config doesnt contain previous lease as static IPv4 config" false fi - lxc stop -f "${ctPrefix}A" - lxc config device set "${ctPrefix}A" eth0 security.ipv4_filtering false - rm "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" + inc stop -f "${ctPrefix}A" + inc config device set "${ctPrefix}A" eth0 security.ipv4_filtering false + rm "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" # Simulate 192.0.2.2 being used by another container, next free IP is 192.0.2.3 - kill "$(awk '/^pid/ {print $2}' "${LXD_DIR}"/networks/"${brName}"/dnsmasq.pid)" - echo "$(date --date="1hour" +%s) 00:16:3e:55:4c:fd 192.0.2.2 c1 ff:6f:c3:ab:c5:00:02:00:00:ab:11:f8:5c:3d:73:db:b2:6a:06" > "${LXD_DIR}/networks/${brName}/dnsmasq.leases" - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true - lxc config device set "${ctPrefix}A" eth0 security.ipv4_filtering true - lxc start "${ctPrefix}A" - - if ! grep "192.0.2.3" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then + kill "$(awk '/^pid/ {print $2}' "${INCUS_DIR}"/networks/"${brName}"/dnsmasq.pid)" + echo "$(date --date="1hour" +%s) 00:16:3e:55:4c:fd 192.0.2.2 c1 ff:6f:c3:ab:c5:00:02:00:00:ab:11:f8:5c:3d:73:db:b2:6a:06" > "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true + inc config device set "${ctPrefix}A" eth0 security.ipv4_filtering true + inc start "${ctPrefix}A" + + if ! grep "192.0.2.3" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then echo "dnsmasq host config doesnt contain sequentially allocated static IPv4 config" false fi # Simulate changing DHCPv4 ranges. - lxc stop -f "${ctPrefix}A" - lxc network set "${brName}" ipv4.dhcp.ranges "192.0.2.100-192.0.2.110" - lxc start "${ctPrefix}A" + inc stop -f "${ctPrefix}A" + inc network set "${brName}" ipv4.dhcp.ranges "192.0.2.100-192.0.2.110" + inc start "${ctPrefix}A" - if ! grep "192.0.2.100" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then + if ! grep "192.0.2.100" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then echo "dnsmasq host config doesnt contain sequentially range allocated static IPv4 config" false fi @@ -325,34 +325,34 @@ test_container_devices_nic_bridged_filtering() { modprobe br_netfilter || true if ! grep 1 /proc/sys/net/bridge/bridge-nf-call-ip6tables ; then echo "br_netfilter didn't load, skipping IPv6 filter checks" - lxc delete -f "${ctPrefix}A" - lxc delete -f "${ctPrefix}B" - lxc profile delete "${ctPrefix}" - lxc network delete "${brName}" + inc delete -f "${ctPrefix}A" + inc delete -f "${ctPrefix}B" + inc profile delete "${ctPrefix}" + inc network delete "${brName}" return fi # Add a fake IPv6 and check connectivity - lxc exec "${ctPrefix}B" -- ip -6 a add 2001:db8:1::3/64 dev eth0 + inc exec "${ctPrefix}B" -- ip -6 a add 2001:db8:1::3/64 dev eth0 wait_for_dad "${ctPrefix}B" eth0 - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up - lxc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::254 dev eth0 + inc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up + inc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::254 dev eth0 wait_for_dad "${ctPrefix}A" eth0 - lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1 - lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3 + inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1 + inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3 # Enable IPv6 filtering on CT A and test (disable security.mac_filtering to check its applied too). - lxc config device set "${ctPrefix}A" eth0 ipv6.address 2001:db8:1::2 - lxc config device set "${ctPrefix}A" eth0 security.mac_filtering false - lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true + inc config device set "${ctPrefix}A" eth0 ipv6.address 2001:db8:1::2 + inc config device set "${ctPrefix}A" eth0 security.mac_filtering false + inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true # Set the ipv6.routes with mask ::ffff (i.e. subnet is last four hex digits) - lxc config device set "${ctPrefix}A" eth0 ipv6.routes 2001:db8:2::/64 - lxc config device set "${ctPrefix}A" eth0 ipv6.routes.external 2001:db8:3::/64 + inc config device set "${ctPrefix}A" eth0 ipv6.routes 2001:db8:2::/64 + inc config device set "${ctPrefix}A" eth0 ipv6.routes.external 2001:db8:3::/64 # Check MAC filter is present in firewall. - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) macHex=$(echo "${ctAMAC}" |sed "s/://g") if [ "$firewallDriver" = "xtables" ]; then @@ -406,7 +406,7 @@ test_container_devices_nic_bridged_filtering() { ipv6RoutesExternalHex="0x20010db800030000" ipv6RoutesExternalDec="2306139568115744768" - rules=$(nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0") + rules=$(nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0") for table in "in" "fwd" do @@ -454,81 +454,81 @@ test_container_devices_nic_bridged_filtering() { fi # Check DHCPv6 allocation still works (if udhcpc6 is in busybox image). - lxc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up + inc exec "${ctPrefix}A" -- ip link set dev eth0 address "${ctAMAC}" up busyboxUdhcpc6=1 - if ! lxc exec "${ctPrefix}A" -- busybox --list | grep udhcpc6 ; then + if ! inc exec "${ctPrefix}A" -- busybox --list | grep udhcpc6 ; then busyboxUdhcpc6=0 fi if [ "$busyboxUdhcpc6" = "1" ]; then - lxc exec "${ctPrefix}A" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' + inc exec "${ctPrefix}A" -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' fi - lxc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::2/64 dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::2/64 dev eth0 wait_for_dad "${ctPrefix}A" eth0 # Check basic connectivity with IPv6 filtering and real IPs configured. - lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1 - lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3 + inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1 + inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3 # Add a fake IP - lxc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::254/64 dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:1::254/64 dev eth0 wait_for_dad "${ctPrefix}A" eth0 # Check that ping is no longer working (i.e its filtered after fake IP setup). - if lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then + if inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then echo "IPv6 filter not working to host" false fi # Check that ping is no longer working (i.e its filtered after fake IP setup). - if lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then + if inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then echo "IPv6 filter not working to other container" false fi # Add a fake IP within ipv6.routes range (2001:db8:2::/64) - lxc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:2::1/128 dev eth0 - lxc exec "${ctPrefix}A" -- ip -6 r add 2001:db8:1::/64 dev eth0 - lxc exec "${ctPrefix}B" -- ip -6 r add 2001:db8:2::/64 dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:2::1/128 dev eth0 + inc exec "${ctPrefix}A" -- ip -6 r add 2001:db8:1::/64 dev eth0 + inc exec "${ctPrefix}B" -- ip -6 r add 2001:db8:2::/64 dev eth0 wait_for_dad "${ctPrefix}A" eth0 # Check that ping is still working (i.e the filter did not apply to the ipv6.routes subnet). - if ! lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then + if ! inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then echo "IPv6 filter is preventing traffic from from within ipv6.routes" false fi # Check that ping is still working (i.e the filter did not apply to the ipv6.routes subnet). - if ! lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then + if ! inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then echo "IPv6 filter is preventing traffic from within ipv6.routes" false fi # Add a fake IP within ipv6.routes.external range (2001:db8:0:0:2::/96) - lxc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:3::1/128 dev eth0 - lxc exec "${ctPrefix}B" -- ip -6 r add 2001:db8:3::/64 dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a flush dev eth0 + inc exec "${ctPrefix}A" -- ip -6 a add 2001:db8:3::1/128 dev eth0 + inc exec "${ctPrefix}B" -- ip -6 r add 2001:db8:3::/64 dev eth0 wait_for_dad "${ctPrefix}A" eth0 # Check that ping is still working (i.e the filter did not apply to the ipv6.routes.external subnet). - if ! lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then + if ! inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::1; then echo "IPv6 filter is preventing traffic from within ipv6.routes.external" false fi # Check that ping is still working (i.e the filter did not apply to the ipv6.routes subnet). - if ! lxc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then + if ! inc exec "${ctPrefix}A" -- ping6 -c2 -W5 2001:db8:1::3; then echo "IPv6 filter is preventing traffic from within ipv6.routes.external" false fi # Stop CT A and check filters are cleaned up. - lxc stop -f "${ctPrefix}A" + inc stop -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "${ctAHost}" ; then echo "IPv6 filter still applied as part of ipv6_filtering in ebtables" @@ -537,7 +537,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "IPv6 filter still applied as part of ipv4_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -545,48 +545,48 @@ test_container_devices_nic_bridged_filtering() { fi # Check volatile cleanup on stop. - if lxc config show "${ctPrefix}A" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then + if inc config show "${ctPrefix}A" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then echo "unexpected volatile key remains" false fi # Set static MAC so that SLAAC address is derived predictably and check it is applied to static config. - lxc config device unset "${ctPrefix}A" eth0 ipv6.address - lxc config device set "${ctPrefix}A" eth0 hwaddr 00:16:3e:92:f3:c1 - lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering false - rm "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" - lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true - lxc start "${ctPrefix}A" - if ! grep "\\[2001:db8:1:0:216:3eff:fe92:f3c1\\]" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then + inc config device unset "${ctPrefix}A" eth0 ipv6.address + inc config device set "${ctPrefix}A" eth0 hwaddr 00:16:3e:92:f3:c1 + inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering false + rm "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" + inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true + inc start "${ctPrefix}A" + if ! grep "\\[2001:db8:1:0:216:3eff:fe92:f3c1\\]" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then echo "dnsmasq host config doesnt contain dynamically allocated static IPv6 config" false fi - lxc stop -f "${ctPrefix}A" - lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering false - rm "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" + inc stop -f "${ctPrefix}A" + inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering false + rm "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" # Simulate SLAAC 2001:db8:1::216:3eff:fe92:f3c1 being used by another container, next free IP is 2001:db8:1::2 - kill "$(awk '/^pid/ {print $2}' "${LXD_DIR}"/networks/"${brName}"/dnsmasq.pid)" - echo "$(date --date="1hour" +%s) 1875094469 2001:db8:1::216:3eff:fe92:f3c1 c1 00:02:00:00:ab:11:f8:5c:3d:73:db:b2:6a:06" > "${LXD_DIR}/networks/${brName}/dnsmasq.leases" - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true - lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true - lxc start "${ctPrefix}A" - if ! grep "\\[2001:db8:1::2\\]" "${LXD_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then + kill "$(awk '/^pid/ {print $2}' "${INCUS_DIR}"/networks/"${brName}"/dnsmasq.pid)" + echo "$(date --date="1hour" +%s) 1875094469 2001:db8:1::216:3eff:fe92:f3c1 c1 00:02:00:00:ab:11:f8:5c:3d:73:db:b2:6a:06" > "${INCUS_DIR}/networks/${brName}/dnsmasq.leases" + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true + inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering true + inc start "${ctPrefix}A" + if ! grep "\\[2001:db8:1::2\\]" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctPrefix}A.eth0" ; then echo "dnsmasq host config doesnt contain sequentially allocated static IPv6 config" false fi - lxc stop -f "${ctPrefix}A" - lxc stop -f "${ctPrefix}B" + inc stop -f "${ctPrefix}A" + inc stop -f "${ctPrefix}B" - lxc delete -f "${ctPrefix}A" - lxc delete -f "${ctPrefix}B" + inc delete -f "${ctPrefix}A" + inc delete -f "${ctPrefix}B" # Check filtering works when ipv4 and ipv6 addresses are set to none on the nic device and the parent network is managed. - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc config device add "${ctPrefix}A" eth0 nic \ + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc config device add "${ctPrefix}A" eth0 nic \ name=eth0 \ nictype=bridged \ parent="${brName}" \ @@ -594,8 +594,8 @@ test_container_devices_nic_bridged_filtering() { security.ipv6_filtering=true \ ipv4.address=none \ ipv6.address=none - lxc start "${ctPrefix}A" - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) + inc start "${ctPrefix}A" + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) # When IPv{n} addresses are "none", every packet should be dropped. if [ "$firewallDriver" = "xtables" ]; then @@ -608,24 +608,24 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0806 drop" # ARP - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0800 drop" # IPv4 - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x86dd drop" # IPv6 + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0806 drop" # ARP + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0800 drop" # IPv4 + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x86dd drop" # IPv6 done fi - lxc delete -f "${ctPrefix}A" + inc delete -f "${ctPrefix}A" # Check filtering works with non-DHCP statically defined IPs and a bridge with no IP address and DHCP disabled. - lxc network set "${brName}" ipv4.dhcp false - lxc network set "${brName}" ipv4.address none + inc network set "${brName}" ipv4.dhcp false + inc network set "${brName}" ipv4.address none - lxc network set "${brName}" ipv6.dhcp false - lxc network set "${brName}" ipv6.address none + inc network set "${brName}" ipv6.dhcp false + inc network set "${brName}" ipv6.address none - lxc network set "${brName}" ipv6.dhcp.stateful false - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc config device add "${ctPrefix}A" eth0 nic \ + inc network set "${brName}" ipv6.dhcp.stateful false + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc config device add "${ctPrefix}A" eth0 nic \ nictype=nic \ name=eth0 \ nictype=bridged \ @@ -634,11 +634,11 @@ test_container_devices_nic_bridged_filtering() { ipv6.address=2001:db8::2 \ security.ipv4_filtering=true \ security.ipv6_filtering=true - lxc start "${ctPrefix}A" + inc start "${ctPrefix}A" # Check MAC filter is present in ebtables. - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) - ctAMAC=$(lxc config get "${ctPrefix}A" volatile.eth0.hwaddr) + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) + ctAMAC=$(inc config get "${ctPrefix}A" volatile.eth0.hwaddr) macHex=$(echo "${ctAMAC}" |sed "s/://g") if [ "$firewallDriver" = "xtables" ]; then @@ -678,7 +678,7 @@ test_container_devices_nic_bridged_filtering() { ipv6Hex="0x20010db8000000000000000000000002" ipv6Dec="42540766411282592856903984951653826562" - rules=$(nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0") + rules=$(nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0") for table in "in" "fwd" do @@ -706,16 +706,16 @@ test_container_devices_nic_bridged_filtering() { fi # Check that you cannot remove static IPs with filtering enabled and DHCP disabled. - if lxc config device unset "${ctPrefix}A" eth0 ipv4.address ; then + if inc config device unset "${ctPrefix}A" eth0 ipv4.address ; then echo "Shouldn't be able to unset IPv4 address with ipv4_filtering enabled and DHCPv4 disabled" fi - if lxc config device unset "${ctPrefix}A" eth0 ipv6.address ; then + if inc config device unset "${ctPrefix}A" eth0 ipv6.address ; then echo "Shouldn't be able to unset IPv6 address with ipv4_filtering enabled and DHCPv6 disabled" fi # Delete container and check filters are cleaned up. - lxc delete -f "${ctPrefix}A" + inc delete -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "${ctAHost}" ; then echo "ebtables filter still applied after delete" @@ -724,7 +724,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "nftables filter still applied after delete (${table}.${ctPrefix}A.eth0)" false fi @@ -737,18 +737,18 @@ test_container_devices_nic_bridged_filtering() { ip a add 2001:db8::1/64 dev "${brName}2" ip link set "${brName}2" up - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc config device add "${ctPrefix}A" eth0 nic \ + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc config device add "${ctPrefix}A" eth0 nic \ nictype=nic \ name=eth0 \ nictype=bridged \ parent="${brName}2" \ security.mac_filtering=true - lxc start "${ctPrefix}A" + inc start "${ctPrefix}A" # Check MAC filter is present in firewall. - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) - ctAMAC=$(lxc config get "${ctPrefix}A" volatile.eth0.hwaddr) + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) + ctAMAC=$(inc config get "${ctPrefix}A" volatile.eth0.hwaddr) if [ "$firewallDriver" = "xtables" ]; then if ! ebtables --concurrent -L --Lmac2 --Lx | grep -e "-s ! ${ctAMAC} -i ${ctAHost} -j DROP" ; then @@ -760,7 +760,7 @@ test_container_devices_nic_bridged_filtering() { macDec=$(printf "%d" 0x"${macHex}") macHex=$(printf "0x%x" "${macDec}") - rules=$(nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0") + rules=$(nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0") for table in "in" "fwd" do @@ -781,7 +781,7 @@ test_container_devices_nic_bridged_filtering() { fi # Stop container and check filters are cleaned up. - lxc stop -f "${ctPrefix}A" + inc stop -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "${ctAHost}" ; then echo "MAC filter still applied as part of mac_filtering in ebtables" @@ -790,7 +790,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "MAC filter still applied as part of mac_filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -798,60 +798,60 @@ test_container_devices_nic_bridged_filtering() { fi # Check manual IPs cannot be specified on an unmanaged bridged without using IP filtering. - ! lxc config device set "${ctPrefix}A" eth0 ipv4.address=192.0.2.2 || false - ! lxc config device set "${ctPrefix}A" eth0 ipv6.address=2001:db8::2 || false + ! inc config device set "${ctPrefix}A" eth0 ipv4.address=192.0.2.2 || false + ! inc config device set "${ctPrefix}A" eth0 ipv6.address=2001:db8::2 || false - # Check IP filtering cannot be enabled without manual IP assigned in LXD config. - ! lxc config device set "${ctPrefix}A" eth0 security.ipv4_filtering=true || false - lxc config device set "${ctPrefix}A" eth0 ipv4.address=192.0.2.2 security.ipv4_filtering=true - ! lxc config device set "${ctPrefix}A" eth0 security.ipv6_filtering=true || false - lxc config device set "${ctPrefix}A" eth0 ipv6.address=2001:db8::2 security.ipv6_filtering=true + # Check IP filtering cannot be enabled without manual IP assigned in Incus config. + ! inc config device set "${ctPrefix}A" eth0 security.ipv4_filtering=true || false + inc config device set "${ctPrefix}A" eth0 ipv4.address=192.0.2.2 security.ipv4_filtering=true + ! inc config device set "${ctPrefix}A" eth0 security.ipv6_filtering=true || false + inc config device set "${ctPrefix}A" eth0 ipv6.address=2001:db8::2 security.ipv6_filtering=true - lxc start "${ctPrefix}A" - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 + inc start "${ctPrefix}A" + inc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 # Check basic connectivity without any filtering. - lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 - lxc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 + inc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 # Check fraudulent IPs are blocked. - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.3/24 dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 2001:db8::3/64 dev eth0 - - ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 || false - ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 || false - - # Check IP filtering can be enabled with IP assigned as none in LXD config. - lxc config device set "${ctPrefix}A" eth0 ipv4.address=none security.ipv4_filtering=true - lxc config device set "${ctPrefix}A" eth0 ipv6.address=none security.ipv6_filtering=true - lxc exec "${ctPrefix}A" -- ip a flush dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 - lxc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 - ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 || false - ! lxc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 || false - - lxc delete -f "${ctPrefix}A" + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 192.0.2.3/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a add 2001:db8::3/64 dev eth0 + + ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 || false + + # Check IP filtering can be enabled with IP assigned as none in Incus config. + inc config device set "${ctPrefix}A" eth0 ipv4.address=none security.ipv4_filtering=true + inc config device set "${ctPrefix}A" eth0 ipv6.address=none security.ipv6_filtering=true + inc exec "${ctPrefix}A" -- ip a flush dev eth0 + inc exec "${ctPrefix}A" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${ctPrefix}A" -- ip a add 2001:db8::2/64 dev eth0 + ! inc exec "${ctPrefix}A" -- ping -c2 -W5 192.0.2.1 || false + ! inc exec "${ctPrefix}A" -- ping -c2 -W5 2001:db8::1 || false + + inc delete -f "${ctPrefix}A" ip link delete "${brName}2" # Check filtering works with no IP addresses (total protocol blocking). - lxc network set "${brName}" ipv4.dhcp false - lxc network set "${brName}" ipv4.address none - lxc network set "${brName}" ipv6.dhcp false - lxc network set "${brName}" ipv6.address none - lxc network set "${brName}" ipv6.dhcp.stateful false - - lxc init testimage "${ctPrefix}A" -p "${ctPrefix}" - lxc config device add "${ctPrefix}A" eth0 nic \ + inc network set "${brName}" ipv4.dhcp false + inc network set "${brName}" ipv4.address none + inc network set "${brName}" ipv6.dhcp false + inc network set "${brName}" ipv6.address none + inc network set "${brName}" ipv6.dhcp.stateful false + + inc init testimage "${ctPrefix}A" -p "${ctPrefix}" + inc config device add "${ctPrefix}A" eth0 nic \ nictype=nic \ name=eth0 \ nictype=bridged \ parent="${brName}" \ security.ipv4_filtering=true \ security.ipv6_filtering=true - lxc start "${ctPrefix}A" - ctAHost=$(lxc config get "${ctPrefix}A" volatile.eth0.host_name) + inc start "${ctPrefix}A" + ctAHost=$(inc config get "${ctPrefix}A" volatile.eth0.host_name) if [ "$firewallDriver" = "xtables" ]; then ebtables --concurrent -L --Lmac2 --Lx | grep -e "-A INPUT -p ARP -i ${ctAHost} -j DROP" @@ -863,14 +863,14 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0806 drop" # ARP - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0800 drop" # IPv4 - nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x86dd drop" # IPv6 + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0806 drop" # ARP + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x0800 drop" # IPv4 + nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "iifname \"${ctAHost}\" ether type 0x86dd drop" # IPv6 done fi # Delete container and check filters are cleaned up. - lxc delete -f "${ctPrefix}A" + inc delete -f "${ctPrefix}A" if [ "$firewallDriver" = "xtables" ]; then if ebtables --concurrent -L --Lmac2 --Lx | grep -e "${ctAHost}" ; then echo "Filters still applied as part of IP filter in ebtables" @@ -879,7 +879,7 @@ test_container_devices_nic_bridged_filtering() { else for table in "in" "fwd" do - if nft -nn list chain bridge lxd "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then + if nft -nn list chain bridge incus "${table}.${ctPrefix}A.eth0" | grep -e "${ctAHost}"; then echo "Filters still applied as part of IP filtering in nftables (${table}.${ctPrefix}A.eth0)" false fi @@ -887,8 +887,8 @@ test_container_devices_nic_bridged_filtering() { fi # Cleanup. - lxc profile delete "${ctPrefix}" - lxc network delete "${brName}" + inc profile delete "${ctPrefix}" + inc network delete "${brName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) diff --git a/test/suites/container_devices_nic_bridged_vlan.sh b/test/suites/container_devices_nic_bridged_vlan.sh index 16989b0178c..08e9ce08e2f 100644 --- a/test/suites/container_devices_nic_bridged_vlan.sh +++ b/test/suites/container_devices_nic_bridged_vlan.sh @@ -1,8 +1,8 @@ test_container_devices_nic_bridged_vlan() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" - prefix="lxdvlan$$" - bridgeDriver=${LXD_NIC_BRIDGED_DRIVER:-"native"} + ensure_has_localhost_remote "${INCUS_ADDR}" + prefix="incvlan$$" + bridgeDriver=${INCUS_NIC_BRIDGED_DRIVER:-"native"} if [ "$bridgeDriver" != "native" ] && [ "$bridgeDriver" != "openvswitch" ]; then echo "Unrecognised bridge driver: ${bridgeDriver}" @@ -10,8 +10,8 @@ test_container_devices_nic_bridged_vlan() { fi # Standard bridge with random subnet. - lxc network create "${prefix}" - lxc network set "${prefix}" bridge.driver "${bridgeDriver}" + inc network create "${prefix}" + inc network set "${prefix}" bridge.driver "${bridgeDriver}" if [ "$bridgeDriver" = "native" ]; then if ! grep "1" "/sys/class/net/${prefix}/bridge/vlan_filtering"; then @@ -29,124 +29,124 @@ test_container_devices_nic_bridged_vlan() { fi # Create profile for new containers. - lxc profile copy default "${prefix}" + inc profile copy default "${prefix}" # Modify profile nictype and parent in atomic operation to ensure validation passes. - lxc profile show "${prefix}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${prefix}/" | lxc profile edit "${prefix}" + inc profile show "${prefix}" | sed "s/nictype: p2p/nictype: bridged\\n parent: ${prefix}/" | inc profile edit "${prefix}" # Test tagged VLAN traffic is allowed when VLAN filtering and IP filtering are disabled. - lxc launch testimage "${prefix}-ctA" -p "${prefix}" - lxc launch testimage "${prefix}-ctB" -p "${prefix}" - lxc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctA" -- ip link set eth0.2 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 - lxc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctB" -- ip link set eth0.2 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0.2 - lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 - lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 - lxc stop -f "${prefix}-ctA" + inc launch testimage "${prefix}-ctA" -p "${prefix}" + inc launch testimage "${prefix}-ctB" -p "${prefix}" + inc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctA" -- ip link set eth0.2 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 + inc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctB" -- ip link set eth0.2 up + inc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0.2 + inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 + inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 + inc stop -f "${prefix}-ctA" # Test tagged VLAN traffic is filtered when IP filtering is enabled. if [ "$bridgeDriver" = "native" ]; then - lxc config device override "${prefix}-ctA" eth0 security.ipv4_filtering=true - lxc start "${prefix}-ctA" - lxc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctA" -- ip link set eth0.2 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 - ! lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 || false - ! lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 || false - lxc stop -f "${prefix}-ctA" - lxc config device remove "${prefix}-ctA" eth0 + inc config device override "${prefix}-ctA" eth0 security.ipv4_filtering=true + inc start "${prefix}-ctA" + inc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctA" -- ip link set eth0.2 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 + ! inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 || false + ! inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 || false + inc stop -f "${prefix}-ctA" + inc config device remove "${prefix}-ctA" eth0 fi # Test tagged VLAN traffic is filtered when using MAC filtering with spoofed MAC address. if [ "$bridgeDriver" = "native" ]; then - lxc config device override "${prefix}-ctA" eth0 security.mac_filtering=true - lxc start "${prefix}-ctA" - lxc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctA" -- ip link set eth0.2 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 - lxc exec "${prefix}-ctA" -- ip link set eth0.2 address 00:16:3e:92:f3:c1 - ! lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 || false - ! lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 || false - lxc stop -f "${prefix}-ctA" - lxc config device remove "${prefix}-ctA" eth0 + inc config device override "${prefix}-ctA" eth0 security.mac_filtering=true + inc start "${prefix}-ctA" + inc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctA" -- ip link set eth0.2 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 + inc exec "${prefix}-ctA" -- ip link set eth0.2 address 00:16:3e:92:f3:c1 + ! inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 || false + ! inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 || false + inc stop -f "${prefix}-ctA" + inc config device remove "${prefix}-ctA" eth0 fi # Test VLAN validation. - lxc config device override "${prefix}-ctA" eth0 vlan=2 # Test valid untagged VLAN ID. - lxc config device set "${prefix}-ctA" eth0 vlan.tagged="3, 4,5" # Test valid tagged VLAN ID list. - lxc config device set "${prefix}-ctA" eth0 vlan.tagged="3,4-6" # Test valid tagged VLAN ID list with range. - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged=3,2,4 # Test same tagged VLAN ID as untagged VLAN ID. - ! lxc config device set "${prefix}-ctA" eth0 security.ipv4_filtering = true # Can't use IP filtering with VLANs. - ! lxc config device set "${prefix}-ctA" eth0 security.ipv6_filtering = true # Can't use IP filtering with VLANs. - ! lxc config device set "${prefix}-ctA" eth0 vlan = invalid # Check invalid VLAN ID. - ! lxc config device set "${prefix}-ctA" eth0 vlan = 4096 # Check out of range VLAN ID. - ! lxc config device set "${prefix}-ctA" eth0 vlan = 0 # Check out of range VLAN ID. - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged = 5,invalid, 6 # Check invalid VLAN ID list. - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged=-1 # Check out of range VLAN ID list. - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged=4096 # Check out of range VLAN ID list. - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged=1,2,-3-4 # Check invalid VLAN ID range input - ! lxc config device set "${prefix}-ctA" eth0 vlan.tagged=1,2,4-3 # Check invalid VLAN ID range boundary (declining range) - lxc config device remove "${prefix}-ctA" eth0 + inc config device override "${prefix}-ctA" eth0 vlan=2 # Test valid untagged VLAN ID. + inc config device set "${prefix}-ctA" eth0 vlan.tagged="3, 4,5" # Test valid tagged VLAN ID list. + inc config device set "${prefix}-ctA" eth0 vlan.tagged="3,4-6" # Test valid tagged VLAN ID list with range. + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged=3,2,4 # Test same tagged VLAN ID as untagged VLAN ID. + ! inc config device set "${prefix}-ctA" eth0 security.ipv4_filtering = true # Can't use IP filtering with VLANs. + ! inc config device set "${prefix}-ctA" eth0 security.ipv6_filtering = true # Can't use IP filtering with VLANs. + ! inc config device set "${prefix}-ctA" eth0 vlan = invalid # Check invalid VLAN ID. + ! inc config device set "${prefix}-ctA" eth0 vlan = 4096 # Check out of range VLAN ID. + ! inc config device set "${prefix}-ctA" eth0 vlan = 0 # Check out of range VLAN ID. + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged = 5,invalid, 6 # Check invalid VLAN ID list. + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged=-1 # Check out of range VLAN ID list. + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged=4096 # Check out of range VLAN ID list. + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged=1,2,-3-4 # Check invalid VLAN ID range input + ! inc config device set "${prefix}-ctA" eth0 vlan.tagged=1,2,4-3 # Check invalid VLAN ID range boundary (declining range) + inc config device remove "${prefix}-ctA" eth0 # Test untagged VLANs (and that tagged VLANs are filtered). if [ "$bridgeDriver" = "native" ]; then echo 1 > "/sys/class/net/${prefix}/bridge/vlan_filtering" fi - lxc config device override "${prefix}-ctA" eth0 vlan=2 - lxc start "${prefix}-ctA" - lxc exec "${prefix}-ctA" -- ip link set eth0 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0 - lxc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.3 type vlan id 3 - lxc exec "${prefix}-ctA" -- ip link set eth0.3 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.3.1/24 dev eth0.3 - lxc stop -f "${prefix}-ctB" - lxc config device override "${prefix}-ctB" eth0 vlan=2 - lxc start "${prefix}-ctB" - lxc exec "${prefix}-ctB" -- ip link set eth0 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0 - lxc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.3 type vlan id 3 - lxc exec "${prefix}-ctB" -- ip link set eth0.3 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.3.2/24 dev eth0.3 - lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 - lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 - ! lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.3.2 || false - ! lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.3.1 || false - lxc stop -f "${prefix}-ctA" - lxc config device remove "${prefix}-ctA" eth0 - lxc stop -f "${prefix}-ctB" - lxc config device remove "${prefix}-ctB" eth0 + inc config device override "${prefix}-ctA" eth0 vlan=2 + inc start "${prefix}-ctA" + inc exec "${prefix}-ctA" -- ip link set eth0 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0 + inc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.3 type vlan id 3 + inc exec "${prefix}-ctA" -- ip link set eth0.3 up + inc exec "${prefix}-ctA" -- ip a add 192.0.3.1/24 dev eth0.3 + inc stop -f "${prefix}-ctB" + inc config device override "${prefix}-ctB" eth0 vlan=2 + inc start "${prefix}-ctB" + inc exec "${prefix}-ctB" -- ip link set eth0 up + inc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.3 type vlan id 3 + inc exec "${prefix}-ctB" -- ip link set eth0.3 up + inc exec "${prefix}-ctB" -- ip a add 192.0.3.2/24 dev eth0.3 + inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 + inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 + ! inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.3.2 || false + ! inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.3.1 || false + inc stop -f "${prefix}-ctA" + inc config device remove "${prefix}-ctA" eth0 + inc stop -f "${prefix}-ctB" + inc config device remove "${prefix}-ctB" eth0 # Test tagged VLANs (and that vlan=none filters untagged frames). if [ "$bridgeDriver" = "native" ]; then echo 1 > "/sys/class/net/${prefix}/bridge/vlan_filtering" fi - lxc config device override "${prefix}-ctA" eth0 vlan.tagged=2 vlan=none - lxc start "${prefix}-ctA" - lxc exec "${prefix}-ctA" -- ip link set eth0 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.3.1/24 dev eth0 - lxc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctA" -- ip link set eth0.2 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 - lxc config device override "${prefix}-ctB" eth0 vlan.tagged=2 vlan=none - lxc start "${prefix}-ctB" - lxc exec "${prefix}-ctB" -- ip link set eth0 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.3.2/24 dev eth0 - lxc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.2 type vlan id 2 - lxc exec "${prefix}-ctB" -- ip link set eth0.2 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0.2 - lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 - lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 - ! lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.3.2 || false - ! lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.3.1 || false - lxc stop -f "${prefix}-ctA" - lxc config device remove "${prefix}-ctA" eth0 - lxc stop -f "${prefix}-ctB" - lxc config device remove "${prefix}-ctB" eth0 + inc config device override "${prefix}-ctA" eth0 vlan.tagged=2 vlan=none + inc start "${prefix}-ctA" + inc exec "${prefix}-ctA" -- ip link set eth0 up + inc exec "${prefix}-ctA" -- ip a add 192.0.3.1/24 dev eth0 + inc exec "${prefix}-ctA" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctA" -- ip link set eth0.2 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0.2 + inc config device override "${prefix}-ctB" eth0 vlan.tagged=2 vlan=none + inc start "${prefix}-ctB" + inc exec "${prefix}-ctB" -- ip link set eth0 up + inc exec "${prefix}-ctB" -- ip a add 192.0.3.2/24 dev eth0 + inc exec "${prefix}-ctB" -- ip link add link eth0 name eth0.2 type vlan id 2 + inc exec "${prefix}-ctB" -- ip link set eth0.2 up + inc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0.2 + inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 + inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 + ! inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.3.2 || false + ! inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.3.1 || false + inc stop -f "${prefix}-ctA" + inc config device remove "${prefix}-ctA" eth0 + inc stop -f "${prefix}-ctB" + inc config device remove "${prefix}-ctB" eth0 # Test custom default VLAN PVID is respected on unmanaged native bridge. if [ "$bridgeDriver" = "native" ]; then @@ -154,28 +154,28 @@ test_container_devices_nic_bridged_vlan() { ip link set "${prefix}B" up echo 0 > "/sys/class/net/${prefix}B/bridge/vlan_filtering" echo 2 > "/sys/class/net/${prefix}B/bridge/default_pvid" - lxc config device override "${prefix}-ctA" eth0 parent="${prefix}B" vlan.tagged=3 - ! lxc start "${prefix}-ctA" # Check it fails to start with vlan_filtering disabled. + inc config device override "${prefix}-ctA" eth0 parent="${prefix}B" vlan.tagged=3 + ! inc start "${prefix}-ctA" # Check it fails to start with vlan_filtering disabled. echo 1 > "/sys/class/net/${prefix}B/bridge/vlan_filtering" - lxc start "${prefix}-ctA" - lxc exec "${prefix}-ctA" -- ip link set eth0 up - lxc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0 - lxc config device override "${prefix}-ctB" eth0 parent="${prefix}B" vlan=2 # Specify VLAN 2 explicitly (ctA is implicit). - lxc start "${prefix}-ctB" - lxc exec "${prefix}-ctB" -- ip link set eth0 up - lxc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0 - lxc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 - lxc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 - lxc stop -f "${prefix}-ctA" - lxc config device remove "${prefix}-ctA" eth0 - lxc stop -f "${prefix}-ctB" - lxc config device remove "${prefix}-ctB" eth0 + inc start "${prefix}-ctA" + inc exec "${prefix}-ctA" -- ip link set eth0 up + inc exec "${prefix}-ctA" -- ip a add 192.0.2.1/24 dev eth0 + inc config device override "${prefix}-ctB" eth0 parent="${prefix}B" vlan=2 # Specify VLAN 2 explicitly (ctA is implicit). + inc start "${prefix}-ctB" + inc exec "${prefix}-ctB" -- ip link set eth0 up + inc exec "${prefix}-ctB" -- ip a add 192.0.2.2/24 dev eth0 + inc exec "${prefix}-ctA" -- ping -c2 -W5 192.0.2.2 + inc exec "${prefix}-ctB" -- ping -c2 -W5 192.0.2.1 + inc stop -f "${prefix}-ctA" + inc config device remove "${prefix}-ctA" eth0 + inc stop -f "${prefix}-ctB" + inc config device remove "${prefix}-ctB" eth0 ip link delete "${prefix}B" fi # Cleanup. - lxc delete -f "${prefix}-ctA" - lxc delete -f "${prefix}-ctB" - lxc profile delete "${prefix}" - lxc network delete "${prefix}" + inc delete -f "${prefix}-ctA" + inc delete -f "${prefix}-ctB" + inc profile delete "${prefix}" + inc network delete "${prefix}" } diff --git a/test/suites/container_devices_nic_ipvlan.sh b/test/suites/container_devices_nic_ipvlan.sh index dcbbde0b839..5ca90f46164 100644 --- a/test/suites/container_devices_nic_ipvlan.sh +++ b/test/suites/container_devices_nic_ipvlan.sh @@ -1,8 +1,8 @@ test_container_devices_nic_ipvlan() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - if ! lxc info | grep 'network_ipvlan: "true"' ; then + if ! inc info | grep 'network_ipvlan: "true"' ; then echo "==> SKIP: No IPVLAN support" return fi @@ -20,8 +20,8 @@ test_container_devices_nic_ipvlan() { sysctl net.ipv6.conf."${ctName}".proxy_ndp=1 sysctl net.ipv6.conf."${ctName}".forwarding=1 sysctl net.ipv4.conf."${ctName}".forwarding=1 - lxc init testimage "${ctName}" - lxc config device add "${ctName}" eth0 nic \ + inc init testimage "${ctName}" + inc config device add "${ctName}" eth0 nic \ nictype=ipvlan \ parent=${ctName} \ ipv4.address="192.0.2.1${ipRand}" \ @@ -29,54 +29,54 @@ test_container_devices_nic_ipvlan() { ipv4.gateway=auto \ ipv6.gateway=auto \ mtu=1400 - lxc start "${ctName}" + inc start "${ctName}" # Check custom MTU is applied. - if ! lxc exec "${ctName}" -- ip link show eth0 | grep "mtu 1400" ; then + if ! inc exec "${ctName}" -- ip link show eth0 | grep "mtu 1400" ; then echo "mtu invalid" false fi - lxc stop "${ctName}" --force + inc stop "${ctName}" --force # Check that MTU is inherited from parent device when not specified on device. ip link set "${ctName}" mtu 1405 - lxc config device unset "${ctName}" eth0 mtu - lxc start "${ctName}" - if ! lxc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then + inc config device unset "${ctName}" eth0 mtu + inc start "${ctName}" + if ! inc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then echo "mtu not inherited from parent" false fi #Spin up another container with multiple IPs. - lxc init testimage "${ctName}2" - lxc config device add "${ctName}2" eth0 nic \ + inc init testimage "${ctName}2" + inc config device add "${ctName}2" eth0 nic \ nictype=ipvlan \ parent=${ctName} \ ipv4.address="192.0.2.2${ipRand}, 192.0.2.3${ipRand}" \ ipv6.address="2001:db8::2${ipRand}, 2001:db8::3${ipRand}" - lxc start "${ctName}2" + inc start "${ctName}2" # Check comms between containers. - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::3${ipRand}" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" - lxc stop -f "${ctName}2" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::3${ipRand}" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" + inc stop -f "${ctName}2" # Check IPVLAN ontop of VLAN parent with custom routing tables. - lxc stop -f "${ctName}" - lxc config device set "${ctName}" eth0 vlan 1234 - lxc config device set "${ctName}" eth0 ipv4.host_table=100 - lxc config device set "${ctName}" eth0 ipv6.host_table=101 + inc stop -f "${ctName}" + inc config device set "${ctName}" eth0 vlan 1234 + inc config device set "${ctName}" eth0 ipv4.host_table=100 + inc config device set "${ctName}" eth0 ipv6.host_table=101 # Check gateway settings don't accept IPs in default l3s mode. - ! lxc config device set "${ctName}" eth0 ipv4.gateway=192.0.2.254 - ! lxc config device set "${ctName}" eth0 ipv6.gateway=2001:db8::FFFF + ! inc config device set "${ctName}" eth0 ipv4.gateway=192.0.2.254 + ! inc config device set "${ctName}" eth0 ipv6.gateway=2001:db8::FFFF - lxc start "${ctName}" + inc start "${ctName}" # Check VLAN interface created if ! grep "1" "/sys/class/net/${ctName}.1234/carrier" ; then @@ -89,8 +89,8 @@ test_container_devices_nic_ipvlan() { ip -6 route show table 101 | grep "2001:db8::1${ipRand}" # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then echo "unexpected volatile key remains" false fi @@ -106,8 +106,8 @@ test_container_devices_nic_ipvlan() { ! ip -6 route show table 101 | grep "2001:db8::1${ipRand}" # Check ipvlan l2 mode with mixture of singular and CIDR IPs, and gateway IPs. - lxc config device remove "${ctName}" eth0 - lxc config device add "${ctName}" eth0 nic \ + inc config device remove "${ctName}" eth0 + inc config device add "${ctName}" eth0 nic \ nictype=ipvlan \ mode=l2 \ parent=${ctName} \ @@ -116,34 +116,34 @@ test_container_devices_nic_ipvlan() { ipv4.gateway=192.0.2.254 \ ipv6.gateway=2001:db8::FFFF \ mtu=1400 - lxc start "${ctName}" + inc start "${ctName}" - lxc config device remove "${ctName}2" eth0 - lxc config device add "${ctName}2" eth0 nic \ + inc config device remove "${ctName}2" eth0 + inc config device add "${ctName}2" eth0 nic \ nictype=ipvlan \ parent=${ctName} \ ipv4.address="192.0.2.3${ipRand}" \ ipv6.address="2001:db8::3${ipRand}" \ mtu=1400 - lxc start "${ctName}2" + inc start "${ctName}2" # Add an internally configured address (only possible in l2 mode). - lxc exec "${ctName}2" -- ip -4 addr add "192.0.2.4${ipRand}/32" dev eth0 - lxc exec "${ctName}2" -- ip -6 addr add "2001:db8::4${ipRand}/128" dev eth0 + inc exec "${ctName}2" -- ip -4 addr add "192.0.2.4${ipRand}/32" dev eth0 + inc exec "${ctName}2" -- ip -6 addr add "2001:db8::4${ipRand}/128" dev eth0 wait_for_dad "${ctName}2" eth0 # Check comms between containers. - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.4${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::3${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::4${ipRand}" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.2${ipRand}" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" - - lxc stop -f "${ctName}" - lxc stop -f "${ctName}2" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.4${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::3${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::4${ipRand}" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.2${ipRand}" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" + + inc stop -f "${ctName}" + inc stop -f "${ctName}2" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) @@ -153,7 +153,7 @@ test_container_devices_nic_ipvlan() { fi # Cleanup ipvlan checks - lxc delete "${ctName}" -f - lxc delete "${ctName}2" -f + inc delete "${ctName}" -f + inc delete "${ctName}2" -f ip link delete "${ctName}" type dummy } diff --git a/test/suites/container_devices_nic_macvlan.sh b/test/suites/container_devices_nic_macvlan.sh index 0202b0a6c87..b7ce23f9c03 100644 --- a/test/suites/container_devices_nic_macvlan.sh +++ b/test/suites/container_devices_nic_macvlan.sh @@ -1,6 +1,6 @@ test_container_devices_nic_macvlan() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" ctName="nt$$" ipRand=$(shuf -i 0-9 -n 1) @@ -13,68 +13,68 @@ test_container_devices_nic_macvlan() { startNicCount=$(find /sys/class/net | wc -l) # Test pre-launch profile config is applied at launch. - lxc profile copy default "${ctName}" + inc profile copy default "${ctName}" # Modifiy profile nictype and parent in atomic operation to ensure validation passes. - lxc profile show "${ctName}" | sed "s/nictype: p2p/nictype: macvlan\\n parent: ${ctName}/" | lxc profile edit "${ctName}" - lxc profile device set "${ctName}" eth0 mtu "1400" + inc profile show "${ctName}" | sed "s/nictype: p2p/nictype: macvlan\\n parent: ${ctName}/" | inc profile edit "${ctName}" + inc profile device set "${ctName}" eth0 mtu "1400" - lxc launch testimage "${ctName}" -p "${ctName}" - lxc exec "${ctName}" -- ip addr add "192.0.2.1${ipRand}/24" dev eth0 - lxc exec "${ctName}" -- ip addr add "2001:db8::1${ipRand}/64" dev eth0 + inc launch testimage "${ctName}" -p "${ctName}" + inc exec "${ctName}" -- ip addr add "192.0.2.1${ipRand}/24" dev eth0 + inc exec "${ctName}" -- ip addr add "2001:db8::1${ipRand}/64" dev eth0 - # Check custom MTU is applied if feature available in LXD. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then - if ! lxc exec "${ctName}" -- ip link show eth0 | grep "mtu 1400" ; then + # Check custom MTU is applied if feature available in Incus. + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if ! inc exec "${ctName}" -- ip link show eth0 | grep "mtu 1400" ; then echo "mtu invalid" false fi fi #Spin up another container with multiple IPs. - lxc launch testimage "${ctName}2" -p "${ctName}" - lxc exec "${ctName}2" -- ip addr add "192.0.2.2${ipRand}/24" dev eth0 - lxc exec "${ctName}2" -- ip addr add "2001:db8::2${ipRand}/64" dev eth0 + inc launch testimage "${ctName}2" -p "${ctName}" + inc exec "${ctName}2" -- ip addr add "192.0.2.2${ipRand}/24" dev eth0 + inc exec "${ctName}2" -- ip addr add "2001:db8::2${ipRand}/64" dev eth0 # Check comms between containers. - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" # Test hot plugging a container nic with different settings to profile with the same name. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=macvlan \ name=eth0 \ parent="${ctName}" \ mtu=1401 # Check custom MTU is applied on hot-plug. - if ! lxc exec "${ctName}" -- ip link show eth0 | grep "mtu 1401" ; then + if ! inc exec "${ctName}" -- ip link show eth0 | grep "mtu 1401" ; then echo "mtu invalid" false fi # Check that MTU is inherited from parent device when not specified on device. ip link set "${ctName}" mtu 1405 - lxc config device unset "${ctName}" eth0 mtu - if ! lxc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then + inc config device unset "${ctName}" eth0 mtu + if ! inc exec "${ctName}" -- grep "1405" /sys/class/net/eth0/mtu ; then echo "mtu not inherited from parent" false fi # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then echo "unexpected volatile key remains" false fi - lxc start "${ctName}" - lxc config device remove "${ctName}" eth0 + inc start "${ctName}" + inc config device remove "${ctName}" eth0 # Test hot plugging macvlan device based on vlan parent. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=macvlan \ parent="${ctName}" \ name=eth0 \ @@ -82,7 +82,7 @@ test_container_devices_nic_macvlan() { mtu=1402 # Check custom MTU is applied. - if ! lxc exec "${ctName}" -- ip link show eth0 | grep "mtu 1402" ; then + if ! inc exec "${ctName}" -- ip link show eth0 | grep "mtu 1402" ; then echo "mtu invalid" false fi @@ -94,7 +94,7 @@ test_container_devices_nic_macvlan() { fi # Remove device from container, this should also remove created VLAN parent device. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check parent device is still up. if ! grep "1" "/sys/class/net/${ctName}/carrier" ; then @@ -105,17 +105,17 @@ test_container_devices_nic_macvlan() { # Test using macvlan network. # Create macvlan network and add NIC device using that network. - lxc network create "${ctName}net" --type=macvlan parent="${ctName}" - lxc config device add "${ctName}" eth0 nic \ + inc network create "${ctName}net" --type=macvlan parent="${ctName}" + inc config device add "${ctName}" eth0 nic \ network="${ctName}net" \ name=eth0 - lxc exec "${ctName}" -- ip addr add "192.0.2.1${ipRand}/24" dev eth0 - lxc exec "${ctName}" -- ip addr add "2001:db8::1${ipRand}/64" dev eth0 - lxc exec "${ctName}" -- ip link set eth0 up - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" - lxc config device remove "${ctName}" eth0 - lxc network delete "${ctName}net" + inc exec "${ctName}" -- ip addr add "192.0.2.1${ipRand}/24" dev eth0 + inc exec "${ctName}" -- ip addr add "2001:db8::1${ipRand}/64" dev eth0 + inc exec "${ctName}" -- ip link set eth0 up + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" + inc config device remove "${ctName}" eth0 + inc network delete "${ctName}net" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) @@ -125,8 +125,8 @@ test_container_devices_nic_macvlan() { fi # Cleanup. - lxc delete "${ctName}" -f - lxc delete "${ctName}2" -f - lxc profile delete "${ctName}" + inc delete "${ctName}" -f + inc delete "${ctName}2" -f + inc profile delete "${ctName}" ip link delete "${ctName}" type dummy } diff --git a/test/suites/container_devices_nic_p2p.sh b/test/suites/container_devices_nic_p2p.sh index ba15f6c700e..949bffe5be4 100644 --- a/test/suites/container_devices_nic_p2p.sh +++ b/test/suites/container_devices_nic_p2p.sh @@ -1,6 +1,6 @@ test_container_devices_nic_p2p() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" vethHostName="veth$$" ctName="nt$$" @@ -11,16 +11,16 @@ test_container_devices_nic_p2p() { startNicCount=$(find /sys/class/net | wc -l) # Test pre-launch profile config is applied at launch. - lxc profile copy default ${ctName} - lxc profile device set ${ctName} eth0 ipv4.routes "192.0.2.1${ipRand}/32" - lxc profile device set ${ctName} eth0 ipv6.routes "2001:db8::1${ipRand}/128" - lxc profile device set ${ctName} eth0 limits.ingress 1Mbit - lxc profile device set ${ctName} eth0 limits.egress 2Mbit - lxc profile device set ${ctName} eth0 host_name "${vethHostName}" - lxc profile device set ${ctName} eth0 mtu "1400" - lxc profile device set ${ctName} eth0 hwaddr "${ctMAC}" - lxc profile device set ${ctName} eth0 nictype "p2p" - lxc launch testimage "${ctName}" -p ${ctName} + inc profile copy default ${ctName} + inc profile device set ${ctName} eth0 ipv4.routes "192.0.2.1${ipRand}/32" + inc profile device set ${ctName} eth0 ipv6.routes "2001:db8::1${ipRand}/128" + inc profile device set ${ctName} eth0 limits.ingress 1Mbit + inc profile device set ${ctName} eth0 limits.egress 2Mbit + inc profile device set ${ctName} eth0 host_name "${vethHostName}" + inc profile device set ${ctName} eth0 mtu "1400" + inc profile device set ${ctName} eth0 hwaddr "${ctMAC}" + inc profile device set ${ctName} eth0 nictype "p2p" + inc launch testimage "${ctName}" -p ${ctName} # Check profile routes are applied on boot. if ! ip -4 r list dev "${vethHostName}" | grep "192.0.2.1${ipRand}" ; then @@ -43,7 +43,7 @@ test_container_devices_nic_p2p() { fi # Check profile custom MTU is applied in container on boot. - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -55,25 +55,25 @@ test_container_devices_nic_p2p() { fi # Check profile custom MAC is applied in container on boot. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Add IP alias to container and check routes actually work. ip -4 addr add 192.0.2.1/32 dev "${vethHostName}" - lxc exec "${ctName}" -- ip -4 addr add "192.0.2.1${ipRand}/32" dev eth0 - lxc exec "${ctName}" -- ip -4 route add default dev eth0 + inc exec "${ctName}" -- ip -4 addr add "192.0.2.1${ipRand}/32" dev eth0 + inc exec "${ctName}" -- ip -4 route add default dev eth0 wait_for_dad "${ctName}" eth0 ping -c2 -W5 "192.0.2.1${ipRand}" ip -6 addr add 2001:db8::1/128 dev "${vethHostName}" - lxc exec "${ctName}" -- ip -6 addr add "2001:db8::1${ipRand}/128" dev eth0 - lxc exec "${ctName}" -- ip -6 route add default dev eth0 + inc exec "${ctName}" -- ip -6 addr add "2001:db8::1${ipRand}/128" dev eth0 + inc exec "${ctName}" -- ip -6 route add default dev eth0 wait_for_dad "${ctName}" eth0 ping6 -c2 -W5 "2001:db8::1${ipRand}" # Test hot plugging a container nic with different settings to profile with the same name. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=p2p \ name=eth0 \ ipv4.routes="192.0.2.3${ipRand}/32" \ @@ -105,7 +105,7 @@ test_container_devices_nic_p2p() { fi # Check custom MTU is applied on hot-plug. - if ! lxc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -117,13 +117,13 @@ test_container_devices_nic_p2p() { fi # Check custom MAC is applied on hot-plug. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Test removing hot plugged device and check profile nic is restored. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check profile routes are applied on hot-removal. if ! ip -4 r list dev "${vethHostName}" | grep "192.0.2.1${ipRand}" ; then @@ -146,7 +146,7 @@ test_container_devices_nic_p2p() { fi # Check profile custom MTU is applied on hot-removal. - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "container veth mtu invalid" false fi @@ -158,17 +158,17 @@ test_container_devices_nic_p2p() { fi # Test hot plugging a container nic then updating it. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=p2p \ name=eth0 \ host_name="${vethHostName}" - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" - lxc config device set "${ctName}" eth0 limits.ingress 3Mbit - lxc config device set "${ctName}" eth0 limits.egress 4Mbit - lxc config device set "${ctName}" eth0 mtu 1402 - lxc config device set "${ctName}" eth0 hwaddr "${ctMAC}" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" + inc config device set "${ctName}" eth0 limits.ingress 3Mbit + inc config device set "${ctName}" eth0 limits.egress 4Mbit + inc config device set "${ctName}" eth0 mtu 1402 + inc config device set "${ctName}" eth0 hwaddr "${ctMAC}" # Check routes are applied on update. if ! ip -4 r list dev "${vethHostName}" | grep "192.0.2.2${ipRand}" ; then @@ -191,30 +191,30 @@ test_container_devices_nic_p2p() { fi # Check custom MTU is applied update. - if ! lxc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then echo "mtu invalid" false fi # Check custom MAC is applied update. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Cleanup. - lxc config device remove "${ctName}" eth0 - lxc delete "${ctName}" -f - lxc profile delete "${ctName}" + inc config device remove "${ctName}" eth0 + inc delete "${ctName}" -f + inc profile delete "${ctName}" # Test adding a p2p device to a running container without host_name and no limits/routes. - lxc launch testimage "${ctName}" - lxc config device add "${ctName}" eth0 nic \ + inc launch testimage "${ctName}" + inc config device add "${ctName}" eth0 nic \ nictype=p2p # Now add some routes - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" # Check routes are applied on update. The host name is dynamic, so just check routes exist. if ! ip -4 r list | grep "192.0.2.2${ipRand}" ; then @@ -227,8 +227,8 @@ test_container_devices_nic_p2p() { fi # Now update routes, check old routes go and new routes added. - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.3${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::3${ipRand}/128" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.3${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::3${ipRand}/128" # Check routes are applied on update. The host name is dynamic, so just check routes exist. if ! ip -4 r list | grep "192.0.2.3${ipRand}" ; then @@ -251,7 +251,7 @@ test_container_devices_nic_p2p() { fi # Now remove device, check routes go - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 if ip -4 r list | grep "192.0.2.3${ipRand}" ; then echo "ipv4.routes invalid" @@ -263,19 +263,19 @@ test_container_devices_nic_p2p() { fi # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr ; then echo "unexpected volatile key remains" false fi # Now add a nic to a stopped container with routes. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=p2p \ ipv4.routes="192.0.2.2${ipRand}/32" \ ipv6.routes="2001:db8::2${ipRand}/128" - lxc start "${ctName}" + inc start "${ctName}" # Check routes are applied on start. The host name is dynamic, so just check routes exist. if ! ip -4 r list | grep "192.0.2.2${ipRand}" ; then @@ -288,8 +288,8 @@ test_container_devices_nic_p2p() { fi # Now update routes on boot time nic, check old routes go and new routes added. - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.3${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::3${ipRand}/128" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.3${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::3${ipRand}/128" # Check routes are applied on update. The host name is dynamic, so just check routes exist. if ! ip -4 r list | grep "192.0.2.3${ipRand}" ; then @@ -312,7 +312,7 @@ test_container_devices_nic_p2p() { fi # Now remove boot time device - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check old routes removed if ip -4 r list | grep "192.0.2.3${ipRand}" ; then @@ -325,12 +325,12 @@ test_container_devices_nic_p2p() { fi # Add hot plug device with routes. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=p2p # Now update routes on hotplug nic - lxc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" - lxc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" + inc config device set "${ctName}" eth0 ipv4.routes "192.0.2.2${ipRand}/32" + inc config device set "${ctName}" eth0 ipv6.routes "2001:db8::2${ipRand}/128" # Check routes are applied. The host name is dynamic, so just check routes exist. if ! ip -4 r list | grep "192.0.2.2${ipRand}" ; then @@ -343,7 +343,7 @@ test_container_devices_nic_p2p() { fi # Now remove hotplug device - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check old routes removed if ip -4 r list | grep "192.0.2.2${ipRand}" ; then @@ -356,9 +356,9 @@ test_container_devices_nic_p2p() { fi # Test hotplugging nic with new name (rather than updating existing nic). - lxc config device add "${ctName}" eth1 nic nictype=p2p + inc config device add "${ctName}" eth1 nic nictype=p2p - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) @@ -367,5 +367,5 @@ test_container_devices_nic_p2p() { false fi - lxc delete "${ctName}" -f + inc delete "${ctName}" -f } diff --git a/test/suites/container_devices_nic_physical.sh b/test/suites/container_devices_nic_physical.sh index 1048eb19992..21d7cae239c 100644 --- a/test/suites/container_devices_nic_physical.sh +++ b/test/suites/container_devices_nic_physical.sh @@ -1,6 +1,6 @@ test_container_devices_nic_physical() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" ctName="nt$$" dummyMAC="aa:3b:97:97:0f:d5" @@ -15,10 +15,10 @@ test_container_devices_nic_physical() { startNicCount=$(find /sys/class/net | wc -l) # Create test container from default profile. - lxc init testimage "${ctName}" + inc init testimage "${ctName}" # Add physical device to container/ - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=physical \ parent="${ctName}" \ name=eth0 \ @@ -26,31 +26,31 @@ test_container_devices_nic_physical() { hwaddr="${ctMAC}" # Launch container and check it has nic applied correctly. - lxc start "${ctName}" + inc start "${ctName}" - # Check custom MTU is applied if feature available in LXD. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then + # Check custom MTU is applied if feature available in Incus. + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth0/mtu ; then echo "mtu invalid" false fi fi # Check custom MAC is applied in container. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 ; then echo "unexpected volatile key remains" false fi # Check original MTU is restored on physical device. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then if ! grep "1500" /sys/class/net/"${ctName}"/mtu ; then echo "mtu invalid" false @@ -64,11 +64,11 @@ test_container_devices_nic_physical() { fi # Remove boot time physical device and check MTU is restored. - lxc start "${ctName}" - lxc config device remove "${ctName}" eth0 + inc start "${ctName}" + inc config device remove "${ctName}" eth0 # Check original MTU is restored on physical device. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then if ! grep "1500" /sys/class/net/"${ctName}"/mtu ; then echo "mtu invalid" false @@ -85,7 +85,7 @@ test_container_devices_nic_physical() { # Make the MTU higher than the original boot time 1400 MTU above to check that the # parent device's MTU is reset on removal to the pre-boot value on host (expect >=1500). ip link set "${ctName}" up #VLAN requires parent nic be up. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=physical \ parent="${ctName}" \ name=eth0 \ @@ -93,25 +93,25 @@ test_container_devices_nic_physical() { hwaddr="${ctMAC}" \ mtu=1401 #Higher than 1400 boot time value above - # Check custom MTU is applied if feature available in LXD. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then - if ! lxc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then + # Check custom MTU is applied if feature available in Incus. + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if ! inc exec "${ctName}" -- grep "1401" /sys/class/net/eth0/mtu ; then echo "mtu invalid" false fi fi # Check custom MAC is applied in container. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Remove hot-plugged physical device and check MTU is restored. - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check original MTU is restored on physical device. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then if ! grep "1500" /sys/class/net/"${ctName}"/mtu ; then echo "mtu invalid" false @@ -127,32 +127,32 @@ test_container_devices_nic_physical() { # Test hot-plugging physical device based on existing parent. # Make the MTU higher than the original boot time 1400 MTU above to check that the # parent device's MTU is reset on removal to the pre-boot value on host (expect >=1500). - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ nictype=physical \ parent="${ctName}" \ name=eth0 \ hwaddr="${ctMAC}" \ mtu=1402 #Higher than 1400 boot time value above - # Check custom MTU is applied if feature available in LXD. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then - if ! lxc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then + # Check custom MTU is applied if feature available in Incus. + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if ! inc exec "${ctName}" -- grep "1402" /sys/class/net/eth0/mtu ; then echo "mtu invalid" false fi fi # Check custom MAC is applied in container. - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi # Test removing a physical device an check its MTU gets restored to default 1500 mtu - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Check original MTU is restored on physical device. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then if ! grep "1500" /sys/class/net/"${ctName}"/mtu ; then echo "mtu invalid" false @@ -166,17 +166,17 @@ test_container_devices_nic_physical() { fi # Test hot-plugging physical device based on existing parent with new name that LXC doesn't know about. - lxc config device add "${ctName}" eth1 nic \ + inc config device add "${ctName}" eth1 nic \ nictype=physical \ parent="${ctName}" \ hwaddr="${ctMAC}" \ mtu=1402 #Higher than 1400 boot time value above - # Stop the container, LXC doesn't know about the nic, so we will rely on LXD to restore it. - lxc stop -f "${ctName}" + # Stop the container, LXC doesn't know about the nic, so we will rely on Incus to restore it. + inc stop -f "${ctName}" # Check original MTU is restored on physical device. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then if ! grep "1500" /sys/class/net/"${ctName}"/mtu ; then echo "mtu invalid" false @@ -190,35 +190,35 @@ test_container_devices_nic_physical() { fi # create a dummy test network of type physical - lxc network create "${networkName}" --type=physical parent="${ctName}" mtu=1400 + inc network create "${networkName}" --type=physical parent="${ctName}" mtu=1400 # remove existing device nic of the container - lxc config device remove "${ctName}" eth1 + inc config device remove "${ctName}" eth1 # Test adding a physical network to container - lxc config device add "${ctName}" eth1 nic \ + inc config device add "${ctName}" eth1 nic \ network="${networkName}" # Check that network config has been applied - if ! lxc config show "${ctName}" | grep "network: ${networkName}" ; then + if ! inc config show "${ctName}" | grep "network: ${networkName}" ; then echo "no network configuration detected" false fi # Check container can start with the physical network configuration - lxc start "${ctName}" + inc start "${ctName}" - # Check custom MTU is applied if feature available in LXD. - if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then - if ! lxc exec "${ctName}" -- grep "1400" /sys/class/net/eth1/mtu ; then + # Check custom MTU is applied if feature available in Incus. + if inc info | grep 'network_phys_macvlan_mtu: "true"' ; then + if ! inc exec "${ctName}" -- grep "1400" /sys/class/net/eth1/mtu ; then echo "mtu invalid" false fi fi - lxc delete "${ctName}" -f + inc delete "${ctName}" -f - lxc network delete "${networkName}" + inc network delete "${networkName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) @@ -229,4 +229,4 @@ test_container_devices_nic_physical() { # Remove dummy interface (should still exist). ip link delete "${ctName}" -} \ No newline at end of file +} diff --git a/test/suites/container_devices_nic_routed.sh b/test/suites/container_devices_nic_routed.sh index 1899c7c240c..e0baab6bdc2 100644 --- a/test/suites/container_devices_nic_routed.sh +++ b/test/suites/container_devices_nic_routed.sh @@ -1,8 +1,8 @@ test_container_devices_nic_routed() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - if ! lxc info | grep 'network_veth_router: "true"' ; then + if ! inc info | grep 'network_veth_router: "true"' ; then echo "==> SKIP: No veth router support" return fi @@ -11,12 +11,12 @@ test_container_devices_nic_routed() { ipRand=$(shuf -i 0-9 -n 1) # These special values are needed to be enabled in kernel. - # No need to enable IPv4 forwarding, as LXD will do this on the veth host_name interface automatically. + # No need to enable IPv4 forwarding, as Incus will do this on the veth host_name interface automatically. sysctl net.ipv6.conf.all.forwarding=1 sysctl net.ipv6.conf.all.proxy_ndp=1 # Standard bridge. - lxc network create "${ctName}" \ + inc network create "${ctName}" \ ipv4.address=192.0.2.1/24 \ ipv6.address=2001:db8::1/64 sysctl net.ipv6.conf."${ctName}".proxy_ndp=1 @@ -27,13 +27,13 @@ test_container_devices_nic_routed() { wait_for_dad "${ctName}" # Create container connected to bridge (which will be used for neighbor probe testing). - lxc init testimage "${ctName}neigh" - lxc config device add "${ctName}neigh" eth0 nic network="${ctName}" - lxc start "${ctName}neigh" - lxc exec "${ctName}neigh" -- ip -4 addr add 192.0.2.254/24 dev eth0 - lxc exec "${ctName}neigh" -- ip -4 route replace default via 192.0.2.1 dev eth0 - lxc exec "${ctName}neigh" -- ip -6 addr add 2001:db8::FFFF/64 dev eth0 - lxc exec "${ctName}neigh" -- ip -6 route replace default via 2001:db8::1 dev eth0 + inc init testimage "${ctName}neigh" + inc config device add "${ctName}neigh" eth0 nic network="${ctName}" + inc start "${ctName}neigh" + inc exec "${ctName}neigh" -- ip -4 addr add 192.0.2.254/24 dev eth0 + inc exec "${ctName}neigh" -- ip -4 route replace default via 192.0.2.1 dev eth0 + inc exec "${ctName}neigh" -- ip -6 addr add 2001:db8::FFFF/64 dev eth0 + inc exec "${ctName}neigh" -- ip -6 route replace default via 2001:db8::1 dev eth0 # Wait for IPv6 DAD to complete. wait_for_dad "${ctName}neigh" eth0 @@ -56,58 +56,58 @@ test_container_devices_nic_routed() { # Record how many nics we started with. startNicCount=$(find /sys/class/net | wc -l) - lxc init testimage "${ctName}" + inc init testimage "${ctName}" # Check vlan option not allowed without parent option. - ! lxc config device add "${ctName}" eth0 nic \ + ! inc config device add "${ctName}" eth0 nic \ name=eth0 \ nictype=routed \ vlan=1234 || false # Check VLAN parent interface creation and teardown. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ name=eth0 \ nictype=routed \ parent=${ctName} \ vlan=1235 - lxc start "${ctName}" + inc start "${ctName}" stat "/sys/class/net/${ctName}.1235" - lxc stop -f "${ctName}" + inc stop -f "${ctName}" ! stat "/sys/class/net/${ctName}.1235" || false - lxc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth0 # Add routed NIC to instance. - lxc config device add "${ctName}" eth0 nic \ + inc config device add "${ctName}" eth0 nic \ name=eth0 \ nictype=routed \ parent=${ctName} # Check starting routed NIC with IPs in use on parent network is prevented. - lxc config device set "${ctName}" eth0 ipv4.address="192.0.2.254" - ! lxc start "${ctName}" || false - lxc config device set "${ctName}" eth0 ipv4.neighbor_probe=false - lxc start "${ctName}" - lxc stop "${ctName}" -f + inc config device set "${ctName}" eth0 ipv4.address="192.0.2.254" + ! inc start "${ctName}" || false + inc config device set "${ctName}" eth0 ipv4.neighbor_probe=false + inc start "${ctName}" + inc stop "${ctName}" -f - lxc config device set "${ctName}" eth0 ipv4.address="" ipv6.address="2001:db8::FFFF" + inc config device set "${ctName}" eth0 ipv4.address="" ipv6.address="2001:db8::FFFF" - ! lxc start "${ctName}" || false - lxc config device set "${ctName}" eth0 ipv6.neighbor_probe=false - lxc start "${ctName}" - lxc stop "${ctName}" -f - lxc config device unset "${ctName}" eth0 ipv4.neighbor_probe - lxc config device unset "${ctName}" eth0 ipv6.neighbor_probe + ! inc start "${ctName}" || false + inc config device set "${ctName}" eth0 ipv6.neighbor_probe=false + inc start "${ctName}" + inc stop "${ctName}" -f + inc config device unset "${ctName}" eth0 ipv4.neighbor_probe + inc config device unset "${ctName}" eth0 ipv6.neighbor_probe # Check starting routed NIC with unused IPs. - lxc config device set "${ctName}" eth0 \ + inc config device set "${ctName}" eth0 \ ipv4.address="192.0.2.1${ipRand}" \ ipv6.address="2001:db8::1${ipRand}" \ ipv4.routes="192.0.3.0/24" \ ipv6.routes="2001:db7::/64" \ mtu=1600 - lxc start "${ctName}" + inc start "${ctName}" - ctHost=$(lxc config get "${ctName}" volatile.eth0.host_name) + ctHost=$(inc config get "${ctName}" volatile.eth0.host_name) # Check profile routes are applied if ! ip -4 r list dev "${ctHost}"| grep "192.0.3.0/24" ; then echo "ipv4.routes invalid" @@ -119,26 +119,26 @@ test_container_devices_nic_routed() { fi # Check IP is assigned and doesn't have a broadcast address set. - lxc exec "${ctName}" -- ip a | grep "inet 192.0.2.1${ipRand}/32 scope global eth0" + inc exec "${ctName}" -- ip a | grep "inet 192.0.2.1${ipRand}/32 scope global eth0" # Check neighbour proxy entries added to parent interface. ip neigh show proxy dev "${ctName}" | grep "192.0.2.1${ipRand}" ip neigh show proxy dev "${ctName}" | grep "2001:db8::1${ipRand}" # Check custom MTU is applied. - if ! lxc exec "${ctName}" -- ip link show eth0 | grep "mtu 1600" ; then + if ! inc exec "${ctName}" -- ip link show eth0 | grep "mtu 1600" ; then echo "mtu invalid" false fi # Check MAC address is applied. - ctMAC=$(lxc config get "${ctName}" volatile.eth0.hwaddr) - if ! lxc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then + ctMAC=$(inc config get "${ctName}" volatile.eth0.hwaddr) + if ! inc exec "${ctName}" -- grep -Fix "${ctMAC}" /sys/class/net/eth0/address ; then echo "mac invalid" false fi - lxc stop "${ctName}" --force + inc stop "${ctName}" --force # Check neighbour proxy entries removed from parent interface. ! ip neigh show proxy dev "${ctName}" | grep "192.0.2.1${ipRand}" || false @@ -146,66 +146,66 @@ test_container_devices_nic_routed() { # Check that MTU is inherited from parent device when not specified on device. ip link set "${ctName}" mtu 1605 - lxc config device unset "${ctName}" eth0 mtu - lxc start "${ctName}" + inc config device unset "${ctName}" eth0 mtu + inc start "${ctName}" - if ! lxc exec "${ctName}" -- grep "1605" /sys/class/net/eth0/mtu ; then + if ! inc exec "${ctName}" -- grep "1605" /sys/class/net/eth0/mtu ; then echo "mtu not inherited from parent" false fi #Spin up another container with multiple IPv4 addresses (no IPv6 to check single family operation). - lxc init testimage "${ctName}2" - lxc config device add "${ctName}2" eth0 nic \ + inc init testimage "${ctName}2" + inc config device add "${ctName}2" eth0 nic \ name=eth0 \ nictype=routed \ parent=${ctName} \ ipv4.address="192.0.2.2${ipRand}, 192.0.2.3${ipRand}" - lxc start "${ctName}2" - lxc exec "${ctName}2" -- ip -4 r | grep "169.254.0.1" - ! lxc exec "${ctName}2" -- ip -6 r | grep "fe80::1" || false - lxc stop -f "${ctName}2" + inc start "${ctName}2" + inc exec "${ctName}2" -- ip -4 r | grep "169.254.0.1" + ! inc exec "${ctName}2" -- ip -6 r | grep "fe80::1" || false + inc stop -f "${ctName}2" # Check single IPv6 family auto default gateway works. - lxc config device unset "${ctName}2" eth0 ipv4.address - lxc config device set "${ctName}2" eth0 ipv6.address="2001:db8::2${ipRand}, 2001:db8::3${ipRand}" - lxc start "${ctName}2" - ! lxc exec "${ctName}2" -- ip r | grep "169.254.0.1" || false - lxc exec "${ctName}2" -- ip -6 r | grep "fe80::1" - lxc stop -f "${ctName}2" + inc config device unset "${ctName}2" eth0 ipv4.address + inc config device set "${ctName}2" eth0 ipv6.address="2001:db8::2${ipRand}, 2001:db8::3${ipRand}" + inc start "${ctName}2" + ! inc exec "${ctName}2" -- ip r | grep "169.254.0.1" || false + inc exec "${ctName}2" -- ip -6 r | grep "fe80::1" + inc stop -f "${ctName}2" # Enable both IP families. - lxc config device set "${ctName}2" eth0 ipv4.address="192.0.2.2${ipRand}, 192.0.2.3${ipRand}" - lxc start "${ctName}2" + inc config device set "${ctName}2" eth0 ipv4.address="192.0.2.2${ipRand}, 192.0.2.3${ipRand}" + inc start "${ctName}2" # Wait for IPv6 DAD to complete. wait_for_dad "${ctName}" eth0 wait_for_dad "${ctName}2" eth0 # Check comms between containers. - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.1" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::1" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.1" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::1" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1" - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" - lxc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.2${ipRand}" + inc exec "${ctName}" -- ping -c2 -W5 "192.0.2.3${ipRand}" - lxc exec "${ctName}" -- ping6 -c3 -W5 "2001:db8::3${ipRand}" - lxc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" + inc exec "${ctName}" -- ping6 -c3 -W5 "2001:db8::3${ipRand}" + inc exec "${ctName}" -- ping6 -c2 -W5 "2001:db8::2${ipRand}" - lxc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" - lxc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" + inc exec "${ctName}2" -- ping -c2 -W5 "192.0.2.1${ipRand}" + inc exec "${ctName}2" -- ping6 -c2 -W5 "2001:db8::1${ipRand}" - lxc stop -f "${ctName}2" - lxc stop -f "${ctName}" + inc stop -f "${ctName}2" + inc stop -f "${ctName}" # Check routed ontop of VLAN parent with custom routing tables. - lxc config device set "${ctName}" eth0 vlan 1234 - lxc config device set "${ctName}" eth0 ipv4.host_table=100 - lxc config device set "${ctName}" eth0 ipv6.host_table=101 - lxc start "${ctName}" + inc config device set "${ctName}" eth0 vlan 1234 + inc config device set "${ctName}" eth0 ipv4.host_table=100 + inc config device set "${ctName}" eth0 ipv6.host_table=101 + inc start "${ctName}" # Check VLAN interface created if ! grep "1" "/sys/class/net/${ctName}.1234/carrier" ; then @@ -218,8 +218,8 @@ test_container_devices_nic_routed() { ip -6 route show table 101 | grep "2001:db8::1${ipRand}" # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then echo "unexpected volatile key remains" false fi @@ -238,10 +238,10 @@ test_container_devices_nic_routed() { fi # Cleanup routed checks - lxc delete "${ctName}" -f - lxc delete "${ctName}2" -f - lxc delete "${ctName}neigh" -f + inc delete "${ctName}" -f + inc delete "${ctName}2" -f + inc delete "${ctName}neigh" -f ip link delete "${ctName}.1234" - lxc network show "${ctName}" - lxc network delete "${ctName}" + inc network show "${ctName}" + inc network delete "${ctName}" } diff --git a/test/suites/container_devices_nic_sriov.sh b/test/suites/container_devices_nic_sriov.sh index a128404f0a9..2f2ce656377 100644 --- a/test/suites/container_devices_nic_sriov.sh +++ b/test/suites/container_devices_nic_sriov.sh @@ -8,9 +8,9 @@ # sudo modprobe igb max_vfs=2 test_container_devices_nic_sriov() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - parent=${LXD_NIC_SRIOV_PARENT:-""} + parent=${INCUS_NIC_SRIOV_PARENT:-""} if [ "$parent" = "" ]; then echo "==> SKIP: No SR-IOV NIC parent specified" @@ -29,44 +29,44 @@ test_container_devices_nic_sriov() { startNicCount=$(find /sys/class/net | wc -l) # Test basic container with SR-IOV NIC. Add 2 devices to check reservation system works. - lxc init testimage "${ctName}" - lxc config device add "${ctName}" eth0 nic \ + inc init testimage "${ctName}" + inc config device add "${ctName}" eth0 nic \ nictype=sriov \ parent="${parent}" - lxc config device add "${ctName}" eth1 nic \ + inc config device add "${ctName}" eth1 nic \ nictype=sriov \ parent="${parent}" - lxc start "${ctName}" + inc start "${ctName}" # Check spoof checking has been disabled (the default). - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ip link show "${parent}" | grep "vf ${vfID}" | grep "spoof checking on"; then echo "spoof checking is still enabled" false fi - lxc config device set "${ctName}" eth0 vlan 1234 + inc config device set "${ctName}" eth0 vlan 1234 # Check custom vlan has been enabled. - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "vlan 1234"; then echo "vlan not set" false fi - lxc config device set "${ctName}" eth0 security.mac_filtering true + inc config device set "${ctName}" eth0 security.mac_filtering true # Check spoof checking has been enabled - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "spoof checking on"; then echo "spoof checking is still disabled" false fi - lxc config device set "${ctName}" eth0 vlan 0 + inc config device set "${ctName}" eth0 vlan 0 # Check custom vlan has been disabled. - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ip link show "${parent}" | grep "vf ${vfID}" | grep "vlan"; then # Mellanox cards display vlan 0 as vlan 4095! if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "vlan 4095"; then @@ -76,88 +76,88 @@ test_container_devices_nic_sriov() { fi # Check volatile cleanup on stop. - lxc stop -f "${ctName}" - if lxc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then + inc stop -f "${ctName}" + if inc config show "${ctName}" | grep volatile.eth0 | grep -v volatile.eth0.hwaddr | grep -v volatile.eth0.name ; then echo "unexpected volatile key remains" false fi # Remove 2nd device whilst stopped. - lxc config device remove "${ctName}" eth1 + inc config device remove "${ctName}" eth1 # Set custom MAC - lxc config device set "${ctName}" eth0 hwaddr "${ctMAC1}" - lxc start "${ctName}" + inc config device set "${ctName}" eth0 hwaddr "${ctMAC1}" + inc start "${ctName}" # Check custom MAC is applied. - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "${ctMAC1}"; then echo "eth0 MAC not set" false fi - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Disable mac filtering and try fresh boot. - lxc config device set "${ctName}" eth0 security.mac_filtering false - lxc start "${ctName}" + inc config device set "${ctName}" eth0 security.mac_filtering false + inc start "${ctName}" # Check spoof checking has been disabled (the default). - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "spoof checking off"; then echo "spoof checking is still enabled" false fi # Hot plug fresh device. - lxc config device add "${ctName}" eth1 nic \ + inc config device add "${ctName}" eth1 nic \ nictype=sriov \ parent="${parent}" \ security.mac_filtering=true # Check spoof checking has been enabled. - vfID=$(lxc config get "${ctName}" volatile.eth1.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth1.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "spoof checking on"; then echo "spoof checking is still disabled" false fi - lxc stop -f "${ctName}" + inc stop -f "${ctName}" # Test setting MAC offline. - lxc config device set "${ctName}" eth1 hwaddr "${ctMAC2}" - lxc start "${ctName}" + inc config device set "${ctName}" eth1 hwaddr "${ctMAC2}" + inc start "${ctName}" # Check custom MAC is applied. - vfID=$(lxc config get "${ctName}" volatile.eth1.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth1.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "${ctMAC2}"; then echo "eth1 MAC not set" false fi - lxc stop -f "${ctName}" - lxc config device remove "${ctName}" eth0 - lxc config device remove "${ctName}" eth1 + inc stop -f "${ctName}" + inc config device remove "${ctName}" eth0 + inc config device remove "${ctName}" eth1 # Create sriov network and add NIC device using that network. - lxc network create "${ctName}net" --type=sriov parent="${parent}" - lxc config device add "${ctName}" eth0 nic \ + inc network create "${ctName}net" --type=sriov parent="${parent}" + inc config device add "${ctName}" eth0 nic \ network="${ctName}net" \ name=eth0 \ hwaddr="${ctMAC1}" - lxc start "${ctName}" + inc start "${ctName}" # Check custom MAC is applied. - vfID=$(lxc config get "${ctName}" volatile.eth0.last_state.vf.id) + vfID=$(inc config get "${ctName}" volatile.eth0.last_state.vf.id) if ! ip link show "${parent}" | grep "vf ${vfID}" | grep "${ctMAC1}"; then echo "eth0 MAC not set" false fi - lxc config device remove "${ctName}" eth0 - lxc network delete "${ctName}net" + inc config device remove "${ctName}" eth0 + inc network delete "${ctName}net" - lxc delete -f "${ctName}" + inc delete -f "${ctName}" # Check we haven't left any NICS lying around. endNicCount=$(find /sys/class/net | wc -l) diff --git a/test/suites/container_devices_proxy.sh b/test/suites/container_devices_proxy.sh index 69d62ff3cf8..4c71b641eb8 100644 --- a/test/suites/container_devices_proxy.sh +++ b/test/suites/container_devices_proxy.sh @@ -12,67 +12,67 @@ test_container_devices_proxy() { container_devices_proxy_validation() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" HOST_TCP_PORT=$(local_tcp_port) - lxc launch testimage proxyTester + inc launch testimage proxyTester # Check that connecting to a DNS name is not allowed (security risk). - if lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:localhost:4321 bind=host ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:localhost:4321 bind=host ; then echo "Proxy device shouldn't allow connect hostnames, only IPs" false fi # Check using wildcard addresses isn't allowed in NAT mode. - if lxc config device add proxyTester proxyDev proxy "listen=tcp:0.0.0.0:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:0.0.0.0:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then echo "Proxy device shouldn't allow wildcard IPv4 listen addresses in NAT mode" false fi - if lxc config device add proxyTester proxyDev proxy "listen=tcp:[::]:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:[::]:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then echo "Proxy device shouldn't allow wildcard IPv6 listen addresses in NAT mode" false fi # Check using mixing IP versions in listen/connect addresses isn't allowed in NAT mode. - if lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" "connect=tcp:[::]:4321" nat=true ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" "connect=tcp:[::]:4321" nat=true ; then echo "Proxy device shouldn't allow mixing IP address versions in NAT mode" false fi - if lxc config device add proxyTester proxyDev proxy "listen=tcp:[::1]:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:[::1]:$HOST_TCP_PORT" connect=tcp:0.0.0.0:4321 nat=true ; then echo "Proxy device shouldn't allow mixing IP address versions in NAT mode" false fi # Check user proxy_protocol isn't allowed in NAT mode. - if lxc config device add proxyTester proxyDev proxy "listen=tcp:[::1]:$HOST_TCP_PORT" "connect=tcp:[::]:4321" nat=true proxy_protocol=true ; then + if inc config device add proxyTester proxyDev proxy "listen=tcp:[::1]:$HOST_TCP_PORT" "connect=tcp:[::]:4321" nat=true proxy_protocol=true ; then echo "Proxy device shouldn't allow proxy_protocol in NAT mode" false fi # Check that old invalid config doesn't prevent device being stopped and removed cleanly. - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host - lxd sql global "UPDATE instances_devices_config SET value='tcp:localhost:4321' WHERE value='tcp:127.0.0.1:4321';" - lxc config device remove proxyTester proxyDev + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host + incus sql global "UPDATE instances_devices_config SET value='tcp:localhost:4321' WHERE value='tcp:127.0.0.1:4321';" + inc config device remove proxyTester proxyDev # Add the device again with the same listen param so if the old process hasn't been stopped it will fail to start. - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_tcp() { echo "====> Testing tcp proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: tcp" HOST_TCP_PORT=$(local_tcp_port) - lxc launch testimage proxyTester + inc launch testimage proxyTester # Initial test - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -80,14 +80,14 @@ container_devices_proxy_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi # Restart the container - lxc restart -f proxyTester - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & + inc restart -f proxyTester + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & NSENTER_PID=$! sleep 1 @@ -96,15 +96,15 @@ container_devices_proxy_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi # Change the port - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337 + inc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337 sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -112,19 +112,19 @@ container_devices_proxy_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi # Initial test - lxc config device remove proxyTester proxyDev + inc config device remove proxyTester proxyDev HOST_TCP_PORT2=$(local_tcp_port) - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4322 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4322 exec:/bin/cat & NSENTER_PID1=$! - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT,$HOST_TCP_PORT2" connect=tcp:127.0.0.1:4321-4322 bind=host + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT,$HOST_TCP_PORT2" connect=tcp:127.0.0.1:4321-4322 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -135,169 +135,169 @@ container_devices_proxy_tcp() { wait "${NSENTER_PID1}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi if [ "${ECHO1}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester # Try NAT - lxc init testimage nattest + inc init testimage nattest - lxc network create lxdt$$ dns.domain=test dns.mode=managed ipv6.dhcp.stateful=true - lxc network attach lxdt$$ nattest eth0 - v4_addr="$(lxc network get lxdt$$ ipv4.address | cut -d/ -f1)0" - v6_addr="$(lxc network get lxdt$$ ipv6.address | cut -d/ -f1)00" - lxc config device set nattest eth0 ipv4.address "${v4_addr}" - lxc config device set nattest eth0 ipv6.address "${v6_addr}" + inc network create inct$$ dns.domain=test dns.mode=managed ipv6.dhcp.stateful=true + inc network attach inct$$ nattest eth0 + v4_addr="$(inc network get inct$$ ipv4.address | cut -d/ -f1)0" + v6_addr="$(inc network get inct$$ ipv6.address | cut -d/ -f1)00" + inc config device set nattest eth0 ipv4.address "${v4_addr}" + inc config device set nattest eth0 ipv6.address "${v6_addr}" - firewallDriver=$(lxc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') + firewallDriver=$(inc info | awk -F ":" '/firewall:/{gsub(/ /, "", $0); print $2}') - lxc start nattest + inc start nattest if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi - lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234" connect="tcp:${v4_addr}:1234" bind=host + inc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234" connect="tcp:${v4_addr}:1234" bind=host if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi # enable NAT - lxc config device set nattest validNAT nat true + inc config device set nattest validNAT nat true if [ "$firewallDriver" = "xtables" ]; then - iptables -w -t nat -S | grep -- "-A PREROUTING -d 127.0.0.1/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for LXD container nattest (validNAT)\" -j DNAT --to-destination ${v4_addr}:1234" - iptables -w -t nat -S | grep -- "-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for LXD container nattest (validNAT)\" -j DNAT --to-destination ${v4_addr}:1234" - iptables -w -t nat -S | grep -- "-A POSTROUTING -s ${v4_addr}/32 -d ${v4_addr}/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for LXD container nattest (validNAT)\" -j MASQUERADE" + iptables -w -t nat -S | grep -- "-A PREROUTING -d 127.0.0.1/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for Incus container nattest (validNAT)\" -j DNAT --to-destination ${v4_addr}:1234" + iptables -w -t nat -S | grep -- "-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for Incus container nattest (validNAT)\" -j DNAT --to-destination ${v4_addr}:1234" + iptables -w -t nat -S | grep -- "-A POSTROUTING -s ${v4_addr}/32 -d ${v4_addr}/32 -p tcp -m tcp --dport 1234 -m comment --comment \"generated for Incus container nattest (validNAT)\" -j MASQUERADE" else - [ "$(nft -nn list chain inet lxd prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234 dnat ip to ${v4_addr}:1234")" -eq 1 ] - [ "$(nft -nn list chain inet lxd out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234 dnat ip to ${v4_addr}:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234 dnat ip to ${v4_addr}:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234 dnat ip to ${v4_addr}:1234")" -eq 1 ] fi - lxc config device remove nattest validNAT + inc config device remove nattest validNAT if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT - ! nft -nn list chain inet lxd out.nattest.validNAT + ! nft -nn list chain inet incus prert.nattest.validNAT + ! nft -nn list chain inet incus out.nattest.validNAT fi - lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234" bind=host nat=true + inc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234" bind=host nat=true if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 3 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 3 ] else - [ "$(nft -nn list chain inet lxd prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}:1234")" -eq 1 ] - [ "$(nft -nn list chain inet lxd out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}:1234")" -eq 1 ] fi - lxc config device remove nattest validNAT + inc config device remove nattest validNAT if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi - lxc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234-1235" bind=host nat=true + inc config device add nattest validNAT proxy listen="tcp:127.0.0.1:1234-1235" connect="tcp:${v4_addr}:1234-1235" bind=host nat=true if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 3 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 3 ] else - [ "$(nft -nn list chain inet lxd prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}")" -eq 1 ] - [ "$(nft -nn list chain inet lxd out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}")" -eq 1 ] + [ "$(nft -nn list chain inet incus prert.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}")" -eq 1 ] + [ "$(nft -nn list chain inet incus out.nattest.validNAT | grep -c "ip daddr 127.0.0.1 tcp dport 1234-1235 dnat ip to ${v4_addr}")" -eq 1 ] fi - lxc config device remove nattest validNAT + inc config device remove nattest validNAT if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi # IPv6 test - lxc config device add nattest validNAT proxy listen="tcp:[::1]:1234" connect="tcp:[::]:1234" bind=host nat=true + inc config device add nattest validNAT proxy listen="tcp:[::1]:1234" connect="tcp:[::]:1234" bind=host nat=true if [ "$firewallDriver" = "xtables" ]; then - [ "$(ip6tables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 3 ] + [ "$(ip6tables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 3 ] else - [ "$(nft -nn list chain inet lxd prert.nattest.validNAT | grep -c "ip6 daddr ::1 tcp dport 1234 dnat ip6 to \[${v6_addr}\]:1234")" -eq 1 ] - [ "$(nft -nn list chain inet lxd out.nattest.validNAT | grep -c "ip6 daddr ::1 tcp dport 1234 dnat ip6 to \[${v6_addr}\]:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus prert.nattest.validNAT | grep -c "ip6 daddr ::1 tcp dport 1234 dnat ip6 to \[${v6_addr}\]:1234")" -eq 1 ] + [ "$(nft -nn list chain inet incus out.nattest.validNAT | grep -c "ip6 daddr ::1 tcp dport 1234 dnat ip6 to \[${v6_addr}\]:1234")" -eq 1 ] fi - lxc config device unset nattest validNAT nat + inc config device unset nattest validNAT nat if [ "$firewallDriver" = "xtables" ]; then - [ "$(ip6tables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(ip6tables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi - lxc config device remove nattest validNAT + inc config device remove nattest validNAT # This won't enable NAT - lxc config device add nattest invalidNAT proxy listen="tcp:127.0.0.1:1234" connect="udp:${v4_addr}:1234" bind=host + inc config device add nattest invalidNAT proxy listen="tcp:127.0.0.1:1234" connect="udp:${v4_addr}:1234" bind=host if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (invalidNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (invalidNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.invalidNAT || false - ! nft -nn list chain inet lxd out.nattest.invalidNAT || false + ! nft -nn list chain inet incus prert.nattest.invalidNAT || false + ! nft -nn list chain inet incus out.nattest.invalidNAT || false fi - lxc delete -f nattest + inc delete -f nattest if [ "$firewallDriver" = "xtables" ]; then - [ "$(iptables -w -t nat -S | grep -c "generated for LXD container nattest (validNAT)")" -eq 0 ] + [ "$(iptables -w -t nat -S | grep -c "generated for Incus container nattest (validNAT)")" -eq 0 ] else - ! nft -nn list chain inet lxd prert.nattest.validNAT || false - ! nft -nn list chain inet lxd out.nattest.validNAT || false + ! nft -nn list chain inet incus prert.nattest.validNAT || false + ! nft -nn list chain inet incus out.nattest.validNAT || false fi - lxc network delete lxdt$$ + inc network delete inct$$ } container_devices_proxy_unix() { echo "====> Testing unix proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: unix" - HOST_SOCK="${TEST_DIR}/lxdtest-$(basename "${LXD_DIR}")-host.sock" - lxc launch testimage proxyTester + HOST_SOCK="${TEST_DIR}/incustest-$(basename "${INCUS_DIR}")-host.sock" + inc launch testimage proxyTester # Some busybox images don't have /tmp globally accessible. - lxc exec proxyTester -- chmod 1777 /tmp + inc exec proxyTester -- chmod 1777 /tmp # Initial test ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}").sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! sleep 0.5 - lxc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" uid=1234 gid=1234 security.uid=1234 security.gid=1234 connect=unix:/tmp/"lxdtest-$(basename "${LXD_DIR}").sock" bind=host + inc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" uid=1234 gid=1234 security.uid=1234 security.gid=1234 connect=unix:/tmp/"incustest-$(basename "${INCUS_DIR}").sock" bind=host ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") kill "${NSENTER_PID}" 2>/dev/null || true wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi @@ -305,12 +305,12 @@ container_devices_proxy_unix() { rm -f "${HOST_SOCK}" # Restart the container - lxc restart -f proxyTester + inc restart -f proxyTester ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}").sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! sleep 1 @@ -320,7 +320,7 @@ container_devices_proxy_unix() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi @@ -329,14 +329,14 @@ container_devices_proxy_unix() { # Change the socket ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}")-2.sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}")-2.sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect unix:/tmp/"lxdtest-$(basename "${LXD_DIR}")-2.sock" + inc config device set proxyTester proxyDev connect unix:/tmp/"incustest-$(basename "${INCUS_DIR}")-2.sock" sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") @@ -344,7 +344,7 @@ container_devices_proxy_unix() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi @@ -352,29 +352,29 @@ container_devices_proxy_unix() { rm -f "${HOST_SOCK}" # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_tcp_unix() { echo "====> Testing tcp to unix proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: tcp -> unix" HOST_TCP_PORT=$(local_tcp_port) - lxc launch testimage proxyTester + inc launch testimage proxyTester # Initial test ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}").sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:${HOST_TCP_PORT}" connect=unix:/tmp/"lxdtest-$(basename "${LXD_DIR}").sock" bind=host + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:${HOST_TCP_PORT}" connect=unix:/tmp/"incustest-$(basename "${INCUS_DIR}").sock" bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -382,18 +382,18 @@ container_devices_proxy_tcp_unix() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi # Restart the container - lxc restart -f proxyTester + inc restart -f proxyTester ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}").sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! sleep 1 @@ -403,21 +403,21 @@ container_devices_proxy_tcp_unix() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi # Change the socket ( - PID="$(lxc query /1.0/containers/proxyTester/state | jq .pid)" + PID="$(inc query /1.0/containers/proxyTester/state | jq .pid)" cd "/proc/${PID}/root/tmp/" || exit umask 0000 - exec nsenter -n -U -t "${PID}" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}")-2.sock",unlink-early exec:/bin/cat + exec nsenter -n -U -t "${PID}" -- socat unix-listen:"incustest-$(basename "${INCUS_DIR}")-2.sock",unlink-early exec:/bin/cat ) & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect unix:/tmp/"lxdtest-$(basename "${LXD_DIR}")-2.sock" + inc config device set proxyTester proxyDev connect unix:/tmp/"incustest-$(basename "${INCUS_DIR}")-2.sock" sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -425,29 +425,29 @@ container_devices_proxy_tcp_unix() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_unix_tcp() { echo "====> Testing unix to tcp proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: unix -> tcp" - HOST_SOCK="${TEST_DIR}/lxdtest-$(basename "${LXD_DIR}")-host.sock" - lxc launch testimage proxyTester + HOST_SOCK="${TEST_DIR}/incustest-$(basename "${INCUS_DIR}")-host.sock" + inc launch testimage proxyTester # Initial test - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=tcp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=tcp:127.0.0.1:4321 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") @@ -455,7 +455,7 @@ container_devices_proxy_unix_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi @@ -463,8 +463,8 @@ container_devices_proxy_unix_tcp() { rm -f "${HOST_SOCK}" # Restart the container - lxc restart -f proxyTester - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & + inc restart -f proxyTester + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat & NSENTER_PID=$! sleep 1 @@ -473,7 +473,7 @@ container_devices_proxy_unix_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi @@ -481,9 +481,9 @@ container_devices_proxy_unix_tcp() { rm -f "${HOST_SOCK}" # Change the port - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337 + inc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337 sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") @@ -491,7 +491,7 @@ container_devices_proxy_unix_tcp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi @@ -499,23 +499,23 @@ container_devices_proxy_unix_tcp() { rm -f "${HOST_SOCK}" # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_udp() { echo "====> Testing udp proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: udp" HOST_UDP_PORT=$(local_tcp_port) - lxc launch testimage proxyTester + inc launch testimage proxyTester # Initial test - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=udp:127.0.0.1:$HOST_UDP_PORT" connect=udp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=udp:127.0.0.1:$HOST_UDP_PORT" connect=udp:127.0.0.1:4321 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - udp:127.0.0.1:"${HOST_UDP_PORT}") @@ -523,14 +523,14 @@ container_devices_proxy_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi # Restart the container - lxc restart -f proxyTester - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + inc restart -f proxyTester + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! sleep 1 @@ -539,15 +539,15 @@ container_devices_proxy_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi # Change the port - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 + inc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - udp:127.0.0.1:"${HOST_UDP_PORT}") @@ -555,29 +555,29 @@ container_devices_proxy_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_unix_udp() { echo "====> Testing unix to udp proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: unix -> udp" - HOST_SOCK="${TEST_DIR}/lxdtest-$(basename "${LXD_DIR}")-host.sock" - lxc launch testimage proxyTester + HOST_SOCK="${TEST_DIR}/incustest-$(basename "${INCUS_DIR}")-host.sock" + inc launch testimage proxyTester # Initial test - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=udp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=udp:127.0.0.1:4321 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") @@ -585,7 +585,7 @@ container_devices_proxy_unix_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi @@ -593,8 +593,8 @@ container_devices_proxy_unix_udp() { rm -f "${HOST_SOCK}" # Restart the container - lxc restart -f proxyTester - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + inc restart -f proxyTester + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! sleep 1 @@ -603,7 +603,7 @@ container_devices_proxy_unix_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi @@ -611,9 +611,9 @@ container_devices_proxy_unix_udp() { rm -f "${HOST_SOCK}" # Change the port - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 + inc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - unix:"${HOST_SOCK#"$(pwd)"/}") @@ -621,7 +621,7 @@ container_devices_proxy_unix_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi @@ -629,23 +629,23 @@ container_devices_proxy_unix_udp() { rm -f "${HOST_SOCK}" # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_tcp_udp() { echo "====> Testing tcp to udp proxying" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Setup MESSAGE="Proxy device test string: tcp -> udp" HOST_TCP_PORT=$(local_tcp_port) - lxc launch testimage proxyTester + inc launch testimage proxyTester # Initial test - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! - lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=udp:127.0.0.1:4321 bind=host + inc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=udp:127.0.0.1:4321 bind=host sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -653,14 +653,14 @@ container_devices_proxy_tcp_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly send data from host to container" false fi # Restart the container - lxc restart -f proxyTester - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & + inc restart -f proxyTester + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat & NSENTER_PID=$! sleep 1 @@ -669,15 +669,15 @@ container_devices_proxy_tcp_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart on container restart" false fi # Change the port - nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & + nsenter -n -U -t "$(inc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat & NSENTER_PID=$! - lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 + inc config device set proxyTester proxyDev connect udp:127.0.0.1:1337 sleep 0.5 ECHO=$( (echo "${MESSAGE}" ; sleep 0.5) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}") @@ -685,23 +685,23 @@ container_devices_proxy_tcp_udp() { wait "${NSENTER_PID}" 2>/dev/null || true if [ "${ECHO}" != "${MESSAGE}" ]; then - cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log" + cat "${INCUS_DIR}/logs/proxyTester/proxy.proxyDev.log" echo "Proxy device did not properly restart when config was updated" false fi # Cleanup - lxc delete -f proxyTester + inc delete -f proxyTester } container_devices_proxy_with_overlapping_forward_net() { echo "====> Testing proxy creation with overlapping network forward" ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" netName="testnet" - lxc network create "${netName}" \ + inc network create "${netName}" \ ipv4.address=192.0.2.1/24 \ ipv6.address=fd42:4242:4242:1010::1/64 @@ -710,37 +710,37 @@ container_devices_proxy_with_overlapping_forward_net() { HOST_TCP_PORT=$(local_tcp_port) # First, launch container with a static IP - lxc launch testimage proxyTester - lxc config device add proxyTester eth0 nic \ + inc launch testimage proxyTester + inc config device add proxyTester eth0 nic \ nictype=bridged \ name=eth0 \ parent=${netName} \ ipv4.address=${proxyTesterStaticIP} # Check creating empty forward doesn't create any firewall rules. - lxc network forward create "${netName}" "${overlappingAddr}" + inc network forward create "${netName}" "${overlappingAddr}" # Test overlapping issue (network forward exists --> proxy creation should fail) - ! lxc config device add proxyTester proxyDev proxy "listen=tcp:${overlappingAddr}:$HOST_TCP_PORT" "connect=tcp:${proxyTesterStaticIP}:4321" nat=true || false + ! inc config device add proxyTester proxyDev proxy "listen=tcp:${overlappingAddr}:$HOST_TCP_PORT" "connect=tcp:${proxyTesterStaticIP}:4321" nat=true || false # Intermediary cleanup - lxc delete -f proxyTester - lxc network forward delete "${netName}" "${overlappingAddr}" + inc delete -f proxyTester + inc network forward delete "${netName}" "${overlappingAddr}" # Same operations as before but in the reverse order - lxc launch testimage proxyTester - lxc config device add proxyTester eth0 nic \ + inc launch testimage proxyTester + inc config device add proxyTester eth0 nic \ nictype=bridged \ name=eth0 \ parent=${netName} \ ipv4.address=${proxyTesterStaticIP} - lxc config device add proxyTester proxyDev proxy "listen=tcp:${overlappingAddr}:$HOST_TCP_PORT" "connect=tcp:${proxyTesterStaticIP}:4321" nat=true + inc config device add proxyTester proxyDev proxy "listen=tcp:${overlappingAddr}:$HOST_TCP_PORT" "connect=tcp:${proxyTesterStaticIP}:4321" nat=true # Test overlapping issue (proxy exists --> network forward creation should fail) - ! lxc network forward create "${netName}" "${overlappingAddr}" || false + ! inc network forward create "${netName}" "${overlappingAddr}" || false # Final cleanup - lxc delete -f proxyTester - lxc network delete "${netName}" -} \ No newline at end of file + inc delete -f proxyTester + inc network delete "${netName}" +} diff --git a/test/suites/container_devices_tpm.sh b/test/suites/container_devices_tpm.sh index e774689db3e..9bda8a20791 100644 --- a/test/suites/container_devices_tpm.sh +++ b/test/suites/container_devices_tpm.sh @@ -5,23 +5,23 @@ test_container_devices_tpm() { fi ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" ctName="ct$$" - lxc launch testimage "${ctName}" + inc launch testimage "${ctName}" # Check adding a device with no path - ! lxc config device add "${ctName}" test-dev-invalid + ! inc config device add "${ctName}" test-dev-invalid # Add device - lxc config device add "${ctName}" test-dev1 tpm path=/dev/tpm0 pathrm=/dev/tpmrm0 - lxc exec "${ctName}" -- stat /dev/tpm0 - lxc exec "${ctName}" -- stat /dev/tpmrm0 + inc config device add "${ctName}" test-dev1 tpm path=/dev/tpm0 pathrm=/dev/tpmrm0 + inc exec "${ctName}" -- stat /dev/tpm0 + inc exec "${ctName}" -- stat /dev/tpmrm0 # Remove device - lxc config device rm "${ctName}" test-dev1 - ! lxc exec "${ctName}" -- stat /dev/tpm0 - ! lxc exec "${ctName}" -- stat /dev/tpmrm0 + inc config device rm "${ctName}" test-dev1 + ! inc exec "${ctName}" -- stat /dev/tpm0 + ! inc exec "${ctName}" -- stat /dev/tpmrm0 # Clean up - lxc rm -f "${ctName}" + inc rm -f "${ctName}" } diff --git a/test/suites/container_devices_unix.sh b/test/suites/container_devices_unix.sh index 82f72c6c996..021d4d765b8 100644 --- a/test/suites/container_devices_unix.sh +++ b/test/suites/container_devices_unix.sh @@ -27,143 +27,143 @@ test_container_devices_unix() { fi ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" ctName="ct$$" - lxc launch testimage "${ctName}" + inc launch testimage "${ctName}" # Create a test unix device. testDev="${TEST_DIR}"/dev/testdev-"${ctName}" mknod "${testDev}" "${deviceTypeCode}" 0 0 # Check adding a device without source or path fails. - ! lxc config device add "${ctName}" test-dev-invalid "${deviceType}" - ! lxc config device add "${ctName}" test-dev-invalid "${deviceType}" required=false + ! inc config device add "${ctName}" test-dev-invalid "${deviceType}" + ! inc config device add "${ctName}" test-dev-invalid "${deviceType}" required=false # Check adding a device with missing source and no major/minor numbers fails. - ! lxc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing + ! inc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing # Check adding a required (default) missing device fails. - ! lxc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing - ! lxc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing required=true + ! inc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing + ! inc config device add "${ctName}" test-dev-invalid "${deviceType}" path=/tmp/testdevmissing required=true # Add device based on existing device, check its host-side name, default mode, major/minor inherited, and mounted in container. - lxc config device add "${ctName}" test-dev1 "${deviceType}" source="${testDev}" path=/tmp/testdev - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev1.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" + inc config device add "${ctName}" test-dev1 "${deviceType}" source="${testDev}" path=/tmp/testdev + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev1.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" # Add device with same dest path as existing device, but with different mode and major/minor and check original isn't replaced inside instance. - lxc config device add "${ctName}" test-dev2 "${deviceType}" source="${testDev}" path=/tmp/testdev major=1 minor=1 mode=600 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + inc config device add "${ctName}" test-dev2 "${deviceType}" source="${testDev}" path=/tmp/testdev major=1 minor=1 mode=600 + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" # Check a new host side file was created with correct attributes. - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev2.tmp-testdev | grep "${deviceTypeDesc} 600 1 1" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev2.tmp-testdev | grep "${deviceTypeDesc} 600 1 1" # Remove dupe device and check the original is still mounted. - lxc config device remove "${ctName}" test-dev2 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + inc config device remove "${ctName}" test-dev2 + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" # Check dupe device host side file is removed though. - if ls "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev2.tmp-testdev; then + if ls "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev2.tmp-testdev; then echo "test-dev2 host side file not removed" false fi # Add new device with custom mode and check it creates correctly on boot. - lxc stop -f "${ctName}" - lxc config device add "${ctName}" test-dev3 "${deviceType}" source="${testDev}" path=/tmp/testdev3 major=1 minor=1 mode=600 - lxc start "${ctName}" - lxc exec "${ctName}" -- mount | grep "/tmp/testdev3" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev3 | grep "${deviceTypeDesc} 600 1 1" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev3.tmp-testdev3 | grep "${deviceTypeDesc} 600 1 1" - lxc config device remove "${ctName}" test-dev3 + inc stop -f "${ctName}" + inc config device add "${ctName}" test-dev3 "${deviceType}" source="${testDev}" path=/tmp/testdev3 major=1 minor=1 mode=600 + inc start "${ctName}" + inc exec "${ctName}" -- mount | grep "/tmp/testdev3" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev3 | grep "${deviceTypeDesc} 600 1 1" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev3.tmp-testdev3 | grep "${deviceTypeDesc} 600 1 1" + inc config device remove "${ctName}" test-dev3 # Add new device without a source, but with a path and major and minor numbers. - lxc config device add "${ctName}" test-dev4 "${deviceType}" path=/tmp/testdev4 major=0 minor=2 mode=777 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev4" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev4 | grep "${deviceTypeDesc} 777 0 2" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev4.tmp-testdev4 | grep "${deviceTypeDesc} 777 0 2" - lxc config device remove "${ctName}" test-dev4 - - lxc stop -f "${ctName}" - lxc config device remove "${ctName}" test-dev1 + inc config device add "${ctName}" test-dev4 "${deviceType}" path=/tmp/testdev4 major=0 minor=2 mode=777 + inc exec "${ctName}" -- mount | grep "/tmp/testdev4" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev4 | grep "${deviceTypeDesc} 777 0 2" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev4.tmp-testdev4 | grep "${deviceTypeDesc} 777 0 2" + inc config device remove "${ctName}" test-dev4 + + inc stop -f "${ctName}" + inc config device remove "${ctName}" test-dev1 rm "${testDev}" # Add a device that is missing, but not required, start instance and then add it. - lxc config device add "${ctName}" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev - lxc start "${ctName}" - ! ls "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev + inc config device add "${ctName}" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev + inc start "${ctName}" + ! ls "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev mknod "${testDev}" "${deviceTypeCode}" 0 0 sleep 1 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" # Remove host side device and check it is dynamically removed from instance. rm "${testDev}" sleep 1 - ! lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - ! lxc exec "${ctName}" -- ls /tmp/testdev - ! ls "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev + ! inc exec "${ctName}" -- mount | grep "/tmp/testdev" + ! inc exec "${ctName}" -- ls /tmp/testdev + ! ls "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev - # Leave instance running, restart LXD, then add device back to check LXD start time inotify works. - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true + # Leave instance running, restart Incus, then add device back to check Incus start time inotify works. + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true mknod "${testDev}" "${deviceTypeCode}" 0 0 sleep 1 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" # Update device's source, check old instance device is removed and new watchers set up. rm "${testDev}" testDevSubDir="${testDev}"/subdev ls -la "${TEST_DIR}" - lxc config device set "${ctName}" test-dev-dynamic source="${testDevSubDir}" - ! lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - ! lxc exec "${ctName}" -- ls /tmp/testdev - ! ls "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev + inc config device set "${ctName}" test-dev-dynamic source="${testDevSubDir}" + ! inc exec "${ctName}" -- mount | grep "/tmp/testdev" + ! inc exec "${ctName}" -- ls /tmp/testdev + ! ls "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev mkdir "${testDev}" mknod "${testDevSubDir}" "${deviceTypeCode}" 0 0 sleep 1 - lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - lxc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" + inc exec "${ctName}" -- mount | grep "/tmp/testdev" + inc exec "${ctName}" -- stat -c '%F %a %t %T' /tmp/testdev | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev | grep "${deviceTypeDesc} 660 0 0" # Cleanup. rm -rvf "${testDev}" sleep 1 - ! lxc exec "${ctName}" -- mount | grep "/tmp/testdev" - ! lxc exec "${ctName}" -- ls /tmp/testdev - ! ls "${LXD_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev - lxc delete -f "${ctName}" + ! inc exec "${ctName}" -- mount | grep "/tmp/testdev" + ! inc exec "${ctName}" -- ls /tmp/testdev + ! ls "${INCUS_DIR}"/devices/"${ctName}"/unix.test--dev--dynamic.tmp-testdev + inc delete -f "${ctName}" # Check multiple instances sharing same watcher. - lxc launch testimage "${ctName}1" - lxc config device add "${ctName}1" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev1 - lxc launch testimage "${ctName}2" - lxc config device add "${ctName}2" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev2 + inc launch testimage "${ctName}1" + inc config device add "${ctName}1" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev1 + inc launch testimage "${ctName}2" + inc config device add "${ctName}2" test-dev-dynamic "${deviceType}" required=false source="${testDev}" path=/tmp/testdev2 mknod "${testDev}" "${deviceTypeCode}" 0 0 sleep 1 - lxc exec "${ctName}1" -- mount | grep "/tmp/testdev1" - lxc exec "${ctName}1" -- stat -c '%F %a %t %T' /tmp/testdev1 | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"1/unix.test--dev--dynamic.tmp-testdev1 | grep "${deviceTypeDesc} 660 0 0" - lxc exec "${ctName}2" -- mount | grep "/tmp/testdev2" - lxc exec "${ctName}2" -- stat -c '%F %a %t %T' /tmp/testdev2 | grep "${deviceTypeDesc} 660 0 0" - stat -c '%F %a %t %T' "${LXD_DIR}"/devices/"${ctName}"2/unix.test--dev--dynamic.tmp-testdev2 | grep "${deviceTypeDesc} 660 0 0" + inc exec "${ctName}1" -- mount | grep "/tmp/testdev1" + inc exec "${ctName}1" -- stat -c '%F %a %t %T' /tmp/testdev1 | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"1/unix.test--dev--dynamic.tmp-testdev1 | grep "${deviceTypeDesc} 660 0 0" + inc exec "${ctName}2" -- mount | grep "/tmp/testdev2" + inc exec "${ctName}2" -- stat -c '%F %a %t %T' /tmp/testdev2 | grep "${deviceTypeDesc} 660 0 0" + stat -c '%F %a %t %T' "${INCUS_DIR}"/devices/"${ctName}"2/unix.test--dev--dynamic.tmp-testdev2 | grep "${deviceTypeDesc} 660 0 0" # Stop one instance, then remove the host device to check the watcher still works after first # instance was stopped. This checks the removal logic when multiple containers share watch path. - lxc stop -f "${ctName}1" + inc stop -f "${ctName}1" rm "${testDev}" sleep 1 - ! lxc exec "${ctName}2" -- mount | grep "/tmp/testdev2" - ! lxc exec "${ctName}2" -- ls /tmp/testdev2 - ! ls "${LXD_DIR}"/devices/"${ctName}"2/unix.test--dev--dynamic.tmp-testdev2 - lxc delete -f "${ctName}1" - lxc delete -f "${ctName}2" + ! inc exec "${ctName}2" -- mount | grep "/tmp/testdev2" + ! inc exec "${ctName}2" -- ls /tmp/testdev2 + ! ls "${INCUS_DIR}"/devices/"${ctName}"2/unix.test--dev--dynamic.tmp-testdev2 + inc delete -f "${ctName}1" + inc delete -f "${ctName}2" } diff --git a/test/suites/container_local_cross_pool_handling.sh b/test/suites/container_local_cross_pool_handling.sh index b0443733f58..5eca0b7332c 100644 --- a/test/suites/container_local_cross_pool_handling.sh +++ b/test/suites/container_local_cross_pool_handling.sh @@ -2,41 +2,41 @@ test_container_local_cross_pool_handling() { ensure_import_testimage # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" true + local INCUS_STORAGE_DIR incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" true ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" ensure_import_testimage - brName="lxdt$$" - lxc network create "${brName}" + brName="inct$$" + inc network create "${brName}" if storage_backend_available "btrfs"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-btrfs" btrfs size=1GiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-btrfs" btrfs size=1GiB fi if storage_backend_available "ceph"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-ceph" ceph volume.size=25MiB ceph.osd.pg_num=16 + inc storage create "incustest-$(basename "${INCUS_DIR}")-ceph" ceph volume.size=25MiB ceph.osd.pg_num=16 fi - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-dir" dir + inc storage create "incustest-$(basename "${INCUS_DIR}")-dir" dir if storage_backend_available "lvm"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-lvm" lvm volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-lvm" lvm volume.size=25MiB fi if storage_backend_available "zfs"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-zfs" zfs size=1GiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-zfs" zfs size=1GiB fi for driver in "btrfs" "ceph" "dir" "lvm" "zfs"; do - if [ "$lxd_backend" = "$driver" ]; then + if [ "$incus_backend" = "$driver" ]; then pool_opts= if [ "$driver" = "btrfs" ] || [ "$driver" = "zfs" ]; then @@ -53,75 +53,75 @@ test_container_local_cross_pool_handling() { if [ -n "${pool_opts}" ]; then # shellcheck disable=SC2086 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-${driver}1" "${driver}" $pool_opts + inc storage create "incustest-$(basename "${INCUS_DIR}")-${driver}1" "${driver}" $pool_opts else - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-${driver}1" "${driver}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-${driver}1" "${driver}" fi - lxc init testimage c1 - lxc config device add c1 eth0 nic network="${brName}" - lxc config show c1 + inc init testimage c1 + inc config device add c1 eth0 nic network="${brName}" + inc config show c1 - originalPool=$(lxc profile device get default root pool) + originalPool=$(inc profile device get default root pool) # Check volatile.apply_template is initialised during create. - lxc config get c1 volatile.apply_template | grep create - lxc copy c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" + inc config get c1 volatile.apply_template | grep create + inc copy c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" # Check volatile.apply_template is altered during copy. - lxc config get c2 volatile.apply_template | grep copy - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 - lxc delete -f c2 - lxc move c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" + inc config get c2 volatile.apply_template | grep copy + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 + inc delete -f c2 + inc move c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" # Check volatile.apply_template is not altered during move and rename. - lxc config get c2 volatile.apply_template | grep create - ! lxc info c1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 + inc config get c2 volatile.apply_template | grep create + ! inc info c1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 # Test moving back to original pool without renaming. - lxc move c2 -s "${originalPool}" - lxc config get c2 volatile.apply_template | grep create - lxc storage volume show "${originalPool}" container/c2 - lxc delete -f c2 - - lxc init testimage c1 - lxc snapshot c1 - lxc snapshot c1 - lxc copy c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" --instance-only - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap0 || false - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap1 || false - lxc delete -f c2 - lxc move c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" --instance-only - ! lxc info c1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap0 || false - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap1 || false - lxc delete -f c2 - - lxc init testimage c1 - lxc snapshot c1 - lxc snapshot c1 - lxc copy c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap0 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap1 - lxc delete -f c2 - lxc move c1 c2 -s "lxdtest-$(basename "${LXD_DIR}")-${driver}1" - ! lxc info c1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap0 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" container/c2/snap1 - lxc delete -f c2 + inc move c2 -s "${originalPool}" + inc config get c2 volatile.apply_template | grep create + inc storage volume show "${originalPool}" container/c2 + inc delete -f c2 + + inc init testimage c1 + inc snapshot c1 + inc snapshot c1 + inc copy c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" --instance-only + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 || false + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false + inc delete -f c2 + inc move c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" --instance-only + ! inc info c1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 || false + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false + inc delete -f c2 + + inc init testimage c1 + inc snapshot c1 + inc snapshot c1 + inc copy c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 + inc delete -f c2 + inc move c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" + ! inc info c1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 + inc delete -f c2 fi done - lxc network delete "${brName}" + inc network delete "${brName}" ) # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - kill_lxd "${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/container_syscall_interception.sh b/test/suites/container_syscall_interception.sh index aa0dd02184a..8a2df35e9b2 100644 --- a/test/suites/container_syscall_interception.sh +++ b/test/suites/container_syscall_interception.sh @@ -1,8 +1,8 @@ test_container_syscall_interception() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - if [ "$(lxc query /1.0 | jq -r .environment.lxc_features.seccomp_notify)" != "true" ]; then + if [ "$(inc query /1.0 | jq -r .environment.lxc_features.seccomp_notify)" != "true" ]; then echo "==> SKIP: Seccomp notify not supported" return fi @@ -18,16 +18,16 @@ test_container_syscall_interception() { go build -v -buildvcs=false ./... ) - lxc init testimage c1 - lxc config set c1 limits.memory=123MiB - lxc start c1 - lxc file push syscall/sysinfo/sysinfo c1/root/sysinfo - lxc exec c1 -- /root/sysinfo - ! lxc exec c1 -- /root/sysinfo | grep "Totalram:128974848 " || false - lxc stop -f c1 - lxc config set c1 security.syscalls.intercept.sysinfo=true - lxc start c1 - lxc exec c1 -- /root/sysinfo - lxc exec c1 -- /root/sysinfo | grep "Totalram:128974848 " - lxc delete -f c1 + inc init testimage c1 + inc config set c1 limits.memory=123MiB + inc start c1 + inc file push syscall/sysinfo/sysinfo c1/root/sysinfo + inc exec c1 -- /root/sysinfo + ! inc exec c1 -- /root/sysinfo | grep "Totalram:128974848 " || false + inc stop -f c1 + inc config set c1 security.syscalls.intercept.sysinfo=true + inc start c1 + inc exec c1 -- /root/sysinfo + inc exec c1 -- /root/sysinfo | grep "Totalram:128974848 " + inc delete -f c1 } diff --git a/test/suites/database.sh b/test/suites/database.sh index b34290fc296..15a285e6a3b 100644 --- a/test/suites/database.sh +++ b/test/suites/database.sh @@ -1,93 +1,93 @@ # Test restore database backups after a failed upgrade. test_database_restore(){ - LXD_RESTORE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + INCUS_RESTORE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - spawn_lxd "${LXD_RESTORE_DIR}" true + spawn_incus "${INCUS_RESTORE_DIR}" true # Set a config value before the broken upgrade. ( set -e # shellcheck disable=SC2034 - LXD_DIR=${LXD_RESTORE_DIR} - lxc config set "core.https_allowed_credentials" "true" + INCUS_DIR=${INCUS_RESTORE_DIR} + inc config set "core.https_allowed_credentials" "true" ) - shutdown_lxd "${LXD_RESTORE_DIR}" + shutdown_incus "${INCUS_RESTORE_DIR}" # Simulate a broken update by dropping in a buggy patch.global.sql - cat << EOF > "${LXD_RESTORE_DIR}/database/patch.global.sql" + cat << EOF > "${INCUS_RESTORE_DIR}/database/patch.global.sql" UPDATE config SET value='false' WHERE key='core.https_allowed_credentials'; INSERT INTO broken(n) VALUES(1); EOF - # Starting LXD fails. - ! LXD_DIR="${LXD_RESTORE_DIR}" lxd --logfile "${LXD_RESTORE_DIR}/lxd.log" "${DEBUG-}" 2>&1 || false + # Starting Incus fails. + ! INCUS_DIR="${INCUS_RESTORE_DIR}" incus --logfile "${INCUS_RESTORE_DIR}/incus.log" "${DEBUG-}" 2>&1 || false # Remove the broken patch - rm -f "${LXD_RESTORE_DIR}/database/patch.global.sql" + rm -f "${INCUS_RESTORE_DIR}/database/patch.global.sql" # Restore the backup - rm -rf "${LXD_RESTORE_DIR}/database/global" - cp -a "${LXD_RESTORE_DIR}/database/global.bak" "${LXD_RESTORE_DIR}/database/global" + rm -rf "${INCUS_RESTORE_DIR}/database/global" + cp -a "${INCUS_RESTORE_DIR}/database/global.bak" "${INCUS_RESTORE_DIR}/database/global" # Restart the daemon and check that our previous settings are still there - respawn_lxd "${LXD_RESTORE_DIR}" true + respawn_incus "${INCUS_RESTORE_DIR}" true ( set -e # shellcheck disable=SC2034 - LXD_DIR=${LXD_RESTORE_DIR} - lxc config get "core.https_allowed_credentials" | grep -q "true" + INCUS_DIR=${INCUS_RESTORE_DIR} + inc config get "core.https_allowed_credentials" | grep -q "true" ) - kill_lxd "${LXD_RESTORE_DIR}" + kill_incus "${INCUS_RESTORE_DIR}" } test_database_no_disk_space(){ # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_NOSPACE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + INCUS_NOSPACE_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) # Mount a tmpfs with limited space in the global database directory and create # a very big file in it, which will eventually cause database transactions to # fail. - GLOBAL_DB_DIR="${LXD_NOSPACE_DIR}/database/global" + GLOBAL_DB_DIR="${INCUS_NOSPACE_DIR}/database/global" BIG_FILE="${GLOBAL_DB_DIR}/bigfile" mkdir -p "${GLOBAL_DB_DIR}" mount -t tmpfs -o size=67108864 tmpfs "${GLOBAL_DB_DIR}" dd bs=1024 count=51200 if=/dev/zero of="${BIG_FILE}" - spawn_lxd "${LXD_NOSPACE_DIR}" true + spawn_incus "${INCUS_NOSPACE_DIR}" true ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR="${LXD_NOSPACE_DIR}" + INCUS_DIR="${INCUS_NOSPACE_DIR}" ensure_import_testimage - lxc init testimage c + inc init testimage c # Set a custom user property with a big value, so we eventually eat up all # available disk space in the database directory. - DATA="${LXD_NOSPACE_DIR}/data" + DATA="${INCUS_NOSPACE_DIR}/data" head -c 262144 < /dev/zero | tr '\0' '\141' > "${DATA}" for i in $(seq 20); do - if ! lxc config set c "user.prop${i}" - < "${DATA}"; then + if ! inc config set c "user.prop${i}" - < "${DATA}"; then break fi done # Commands that involve writing to the database keep failing. - ! lxc config set c "user.propX" - < "${DATA}" || false - ! lxc config set c "user.propY" - < "${DATA}" || false + ! inc config set c "user.propX" - < "${DATA}" || false + ! inc config set c "user.propY" - < "${DATA}" || false # Removing the big file makes the database happy again. rm "${BIG_FILE}" - lxc config set c "user.propZ" - < "${DATA}" - lxc delete -f c + inc config set c "user.propZ" - < "${DATA}" + inc delete -f c ) - shutdown_lxd "${LXD_NOSPACE_DIR}" + shutdown_incus "${INCUS_NOSPACE_DIR}" umount "${GLOBAL_DB_DIR}" - kill_lxd "${LXD_NOSPACE_DIR}" + kill_incus "${INCUS_NOSPACE_DIR}" } diff --git a/test/suites/deps.sh b/test/suites/deps.sh index e3f4ccc42ae..63fdde12175 100644 --- a/test/suites/deps.sh +++ b/test/suites/deps.sh @@ -1,3 +1,3 @@ test_check_deps() { - ! ldd "$(command -v lxc)" | grep -q liblxc || false + ! ldd "$(command -v inc)" | grep -q liblxc || false } diff --git a/test/suites/dev_incus.sh b/test/suites/dev_incus.sh index fd8d021018f..a9c53095640 100644 --- a/test/suites/dev_incus.sh +++ b/test/suites/dev_incus.sh @@ -1,35 +1,35 @@ -test_devlxd() { +test_dev_incus() { ensure_import_testimage ( - cd devlxd-client || return + cd dev_incus-client || return # Use -buildvcs=false here to prevent git complaining about untrusted directory when tests are run as root. go build -tags netgo -v -buildvcs=false ./... ) - lxc launch testimage devlxd -c security.devlxd=false + inc launch testimage dev-incus -c security.guestapi=false - ! lxc exec devlxd -- test -S /dev/lxd/sock || false - lxc config unset devlxd security.devlxd - lxc exec devlxd -- test -S /dev/lxd/sock - lxc file push "devlxd-client/devlxd-client" devlxd/bin/ + ! inc exec dev-incus -- test -S /dev/incus/sock || false + inc config unset dev-incus security.guestapi + inc exec dev-incus -- test -S /dev/incus/sock + inc file push "dev_incus-client/dev_incus-client" dev-incus/bin/ - lxc exec devlxd chmod +x /bin/devlxd-client + inc exec dev-incus chmod +x /bin/dev_incus-client - lxc config set devlxd user.foo bar - lxc exec devlxd devlxd-client user.foo | grep bar + inc config set dev-incus user.foo bar + inc exec dev-incus dev_incus-client user.foo | grep bar - lxc config set devlxd user.foo "bar %s bar" - lxc exec devlxd devlxd-client user.foo | grep "bar %s bar" + inc config set dev-incus user.foo "bar %s bar" + inc exec dev-incus dev_incus-client user.foo | grep "bar %s bar" - lxc config set devlxd security.nesting true - ! lxc exec devlxd devlxd-client security.nesting | grep true || false + inc config set dev-incus security.nesting true + ! inc exec dev-incus dev_incus-client security.nesting | grep true || false - cmd=$(unset -f lxc; command -v lxc) - ${cmd} exec devlxd devlxd-client monitor-websocket > "${TEST_DIR}/devlxd-websocket.log" & + cmd=$(unset -f inc; command -v inc) + ${cmd} exec dev-incus dev_incus-client monitor-websocket > "${TEST_DIR}/dev_incus-websocket.log" & client_websocket=$! - ${cmd} exec devlxd devlxd-client monitor-stream > "${TEST_DIR}/devlxd-stream.log" & + ${cmd} exec dev-incus dev_incus-client monitor-stream > "${TEST_DIR}/dev_incus-stream.log" & client_stream=$! ( @@ -62,23 +62,23 @@ timestamp: null type: device EOF - ) > "${TEST_DIR}/devlxd.expected" + ) > "${TEST_DIR}/dev_incus.expected" MATCH=0 for _ in $(seq 10); do - lxc config set devlxd user.foo bar - lxc config set devlxd security.nesting true + inc config set dev-incus user.foo bar + inc config set dev-incus security.nesting true - true > "${TEST_DIR}/devlxd-websocket.log" - true > "${TEST_DIR}/devlxd-stream.log" + true > "${TEST_DIR}/dev_incus-websocket.log" + true > "${TEST_DIR}/dev_incus-stream.log" - lxc config set devlxd user.foo baz - lxc config set devlxd security.nesting false - lxc config device add devlxd mnt disk source="${TEST_DIR}" path=/mnt - lxc config device remove devlxd mnt + inc config set dev-incus user.foo baz + inc config set dev-incus security.nesting false + inc config device add dev-incus mnt disk source="${TEST_DIR}" path=/mnt + inc config device remove dev-incus mnt - if [ "$(tr -d '\0' < "${TEST_DIR}/devlxd-websocket.log" | md5sum | cut -d' ' -f1)" != "$(md5sum "${TEST_DIR}/devlxd.expected" | cut -d' ' -f1)" ] || [ "$(tr -d '\0' < "${TEST_DIR}/devlxd-stream.log" | md5sum | cut -d' ' -f1)" != "$(md5sum "${TEST_DIR}/devlxd.expected" | cut -d' ' -f1)" ]; then + if [ "$(tr -d '\0' < "${TEST_DIR}/dev_incus-websocket.log" | md5sum | cut -d' ' -f1)" != "$(md5sum "${TEST_DIR}/dev_incus.expected" | cut -d' ' -f1)" ] || [ "$(tr -d '\0' < "${TEST_DIR}/dev_incus-stream.log" | md5sum | cut -d' ' -f1)" != "$(md5sum "${TEST_DIR}/dev_incus.expected" | cut -d' ' -f1)" ]; then sleep 0.5 continue fi @@ -90,55 +90,55 @@ EOF kill -9 "${client_websocket}" kill -9 "${client_stream}" - lxc monitor --type=lifecycle > "${TEST_DIR}/devlxd.log" & - monitorDevlxdPID=$! + inc monitor --type=lifecycle > "${TEST_DIR}/dev_incus.log" & + monitorDevIncusPID=$! # Test instance Ready state - lxc info devlxd | grep -q 'Status: RUNNING' - lxc exec devlxd devlxd-client ready-state true - [ "$(lxc config get devlxd volatile.last_state.ready)" = "true" ] + inc info dev-incus | grep -q 'Status: RUNNING' + inc exec dev-incus dev_incus-client ready-state true + [ "$(inc config get dev-incus volatile.last_state.ready)" = "true" ] - grep -Fc "instance-ready" "${TEST_DIR}/devlxd.log" | grep -Fx 1 + grep -Fc "instance-ready" "${TEST_DIR}/dev_incus.log" | grep -Fx 1 - lxc info devlxd | grep -q 'Status: READY' - lxc exec devlxd devlxd-client ready-state false - [ "$(lxc config get devlxd volatile.last_state.ready)" = "false" ] + inc info dev-incus | grep -q 'Status: READY' + inc exec dev-incus dev_incus-client ready-state false + [ "$(inc config get dev-incus volatile.last_state.ready)" = "false" ] - grep -Fc "instance-ready" "${TEST_DIR}/devlxd.log" | grep -Fx 1 + grep -Fc "instance-ready" "${TEST_DIR}/dev_incus.log" | grep -Fx 1 - lxc info devlxd | grep -q 'Status: RUNNING' + inc info dev-incus | grep -q 'Status: RUNNING' - kill -9 ${monitorDevlxdPID} || true + kill -9 ${monitorDevIncusPID} || true - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true # volatile.last_state.ready should be unset during daemon init - [ -z "$(lxc config get devlxd volatile.last_state.ready)" ] + [ -z "$(inc config get dev-incus volatile.last_state.ready)" ] - lxc monitor --type=lifecycle > "${TEST_DIR}/devlxd.log" & - monitorDevlxdPID=$! + inc monitor --type=lifecycle > "${TEST_DIR}/dev_incus.log" & + monitorDevIncusPID=$! - lxc exec devlxd devlxd-client ready-state true - [ "$(lxc config get devlxd volatile.last_state.ready)" = "true" ] + inc exec dev-incus dev_incus-client ready-state true + [ "$(inc config get dev-incus volatile.last_state.ready)" = "true" ] - grep -Fc "instance-ready" "${TEST_DIR}/devlxd.log" | grep -Fx 1 + grep -Fc "instance-ready" "${TEST_DIR}/dev_incus.log" | grep -Fx 1 - lxc stop -f devlxd - [ "$(lxc config get devlxd volatile.last_state.ready)" = "false" ] + inc stop -f dev-incus + [ "$(inc config get dev-incus volatile.last_state.ready)" = "false" ] - lxc start devlxd - lxc exec devlxd devlxd-client ready-state true - [ "$(lxc config get devlxd volatile.last_state.ready)" = "true" ] + inc start dev-incus + inc exec dev-incus dev_incus-client ready-state true + [ "$(inc config get dev-incus volatile.last_state.ready)" = "true" ] - grep -Fc "instance-ready" "${TEST_DIR}/devlxd.log" | grep -Fx 2 + grep -Fc "instance-ready" "${TEST_DIR}/dev_incus.log" | grep -Fx 2 # Check device configs are available and that NIC hwaddr is available even if volatile. - hwaddr=$(lxc config get devlxd volatile.eth0.hwaddr) - lxc exec devlxd devlxd-client devices | jq -r .eth0.hwaddr | grep -Fx "${hwaddr}" + hwaddr=$(inc config get dev-incus volatile.eth0.hwaddr) + inc exec dev-incus dev_incus-client devices | jq -r .eth0.hwaddr | grep -Fx "${hwaddr}" - lxc delete devlxd --force - kill -9 ${monitorDevlxdPID} || true + inc delete dev-incus --force + kill -9 ${monitorDevIncusPID} || true [ "${MATCH}" = "1" ] || false } diff --git a/test/suites/exec.sh b/test/suites/exec.sh index 20b7d8d9af6..9e982ce718c 100644 --- a/test/suites/exec.sh +++ b/test/suites/exec.sh @@ -2,73 +2,73 @@ test_exec() { ensure_import_testimage name=x1 - lxc launch testimage x1 - lxc list ${name} | grep RUNNING + inc launch testimage x1 + inc list ${name} | grep RUNNING exec_container_noninteractive() { - echo "abc${1}" | lxc exec "${name}" --force-noninteractive -- cat | grep abc + echo "abc${1}" | inc exec "${name}" --force-noninteractive -- cat | grep abc } exec_container_interactive() { - echo "abc${1}" | lxc exec "${name}" -- cat | grep abc + echo "abc${1}" | inc exec "${name}" -- cat | grep abc } for i in $(seq 1 25); do - exec_container_interactive "${i}" > "${LXD_DIR}/exec-${i}.out" 2>&1 + exec_container_interactive "${i}" > "${INCUS_DIR}/exec-${i}.out" 2>&1 done for i in $(seq 1 25); do - exec_container_noninteractive "${i}" > "${LXD_DIR}/exec-${i}.out" 2>&1 + exec_container_noninteractive "${i}" > "${INCUS_DIR}/exec-${i}.out" 2>&1 done # Check non-websocket based exec works. - opID=$(lxc query -X POST -d '{\"command\":[\"touch\",\"/root/foo1\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id) + opID=$(inc query -X POST -d '{\"command\":[\"touch\",\"/root/foo1\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id) sleep 1 - lxc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "0" - lxc exec x1 -- stat /root/foo1 + inc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "0" + inc exec x1 -- stat /root/foo1 - opID=$(lxc query -X POST -d '{\"command\":[\"missingcmd\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id) + opID=$(inc query -X POST -d '{\"command\":[\"missingcmd\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id) sleep 1 - lxc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "127" + inc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "127" - echo "hello" | lxc exec x1 -- tee /root/foo1 - opID=$(lxc query -X POST -d '{\"command\":[\"cat\",\"/root/foo1\"],\"record-output\":true}' /1.0/instances/x1/exec | jq -r .id) + echo "hello" | inc exec x1 -- tee /root/foo1 + opID=$(inc query -X POST -d '{\"command\":[\"cat\",\"/root/foo1\"],\"record-output\":true}' /1.0/instances/x1/exec | jq -r .id) sleep 1 - stdOutURL=$(lxc query /1.0/operations/"${opID}" | jq '.metadata.output["1"]') - lxc query "${stdOutURL}" | grep -F "hello" + stdOutURL=$(inc query /1.0/operations/"${opID}" | jq '.metadata.output["1"]') + inc query "${stdOutURL}" | grep -F "hello" - lxc stop "${name}" --force - lxc delete "${name}" + inc stop "${name}" --force + inc delete "${name}" } test_concurrent_exec() { - if [ -z "${LXD_CONCURRENT:-}" ]; then - echo "==> SKIP: LXD_CONCURRENT isn't set" + if [ -z "${INCUS_CONCURRENT:-}" ]; then + echo "==> SKIP: INCUS_CONCURRENT isn't set" return fi ensure_import_testimage name=x1 - lxc launch testimage x1 - lxc list ${name} | grep RUNNING + inc launch testimage x1 + inc list ${name} | grep RUNNING exec_container_noninteractive() { - echo "abc${1}" | lxc exec "${name}" --force-noninteractive -- cat | grep abc + echo "abc${1}" | inc exec "${name}" --force-noninteractive -- cat | grep abc } exec_container_interactive() { - echo "abc${1}" | lxc exec "${name}" -- cat | grep abc + echo "abc${1}" | inc exec "${name}" -- cat | grep abc } PIDS="" for i in $(seq 1 25); do - exec_container_interactive "${i}" > "${LXD_DIR}/exec-${i}.out" 2>&1 & + exec_container_interactive "${i}" > "${INCUS_DIR}/exec-${i}.out" 2>&1 & PIDS="${PIDS} $!" done for i in $(seq 1 25); do - exec_container_noninteractive "${i}" > "${LXD_DIR}/exec-${i}.out" 2>&1 & + exec_container_noninteractive "${i}" > "${INCUS_DIR}/exec-${i}.out" 2>&1 & PIDS="${PIDS} $!" done @@ -76,6 +76,6 @@ test_concurrent_exec() { wait "${pid}" done - lxc stop "${name}" --force - lxc delete "${name}" + inc stop "${name}" --force + inc delete "${name}" } diff --git a/test/suites/external_auth.sh b/test/suites/external_auth.sh index b3f69b07e36..506fe5ca92b 100644 --- a/test/suites/external_auth.sh +++ b/test/suites/external_auth.sh @@ -4,11 +4,11 @@ test_macaroon_auth() { # shellcheck disable=SC2086 identity_endpoint="$(cat ${TEST_DIR}/macaroon-identity.endpoint)" - ensure_has_localhost_remote "$LXD_ADDR" + ensure_has_localhost_remote "$INCUS_ADDR" - lxc config set candid.api.url "$identity_endpoint" + inc config set candid.api.url "$identity_endpoint" key=$(curl -s "${identity_endpoint}/discharge/info" | jq .PublicKey) - lxc config set candid.api.key "${key}" + inc config set candid.api.key "${key}" # invalid credentials make the remote add fail ! ( @@ -16,7 +16,7 @@ test_macaroon_auth() { wrong-user wrong-pass EOF - ) | lxc remote add macaroon-remote "https://$LXD_ADDR" --auth-type candid --accept-certificate || false + ) | inc remote add macaroon-remote "https://$INCUS_ADDR" --auth-type candid --accept-certificate || false # valid credentials work ( @@ -24,13 +24,13 @@ EOF user1 pass1 EOF - ) | lxc remote add macaroon-remote "https://$LXD_ADDR" --auth-type candid --accept-certificate + ) | inc remote add macaroon-remote "https://$INCUS_ADDR" --auth-type candid --accept-certificate - # run a lxc command through the new remote - lxc config show macaroon-remote: | grep -q candid.api.url + # run a inc command through the new remote + inc config show macaroon-remote: | grep -q candid.api.url # cleanup - lxc config unset candid.api.url - lxc config unset core.https_address - lxc remote remove macaroon-remote + inc config unset candid.api.url + inc config unset core.https_address + inc remote remove macaroon-remote } diff --git a/test/suites/fdleak.sh b/test/suites/fdleak.sh index 2a17b3dbfd6..4a53f14757a 100644 --- a/test/suites/fdleak.sh +++ b/test/suites/fdleak.sh @@ -1,28 +1,28 @@ test_fdleak() { - LXD_FDLEAK_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_FDLEAK_DIR}" - spawn_lxd "${LXD_FDLEAK_DIR}" true - pid=$(cat "${LXD_FDLEAK_DIR}/lxd.pid") + INCUS_FDLEAK_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_FDLEAK_DIR}" + spawn_incus "${INCUS_FDLEAK_DIR}" true + pid=$(cat "${INCUS_FDLEAK_DIR}/incus.pid") beforefds=$(/bin/ls "/proc/${pid}/fd" | wc -l) ( set -e # shellcheck disable=SC2034 - LXD_DIR=${LXD_FDLEAK_DIR} + INCUS_DIR=${INCUS_FDLEAK_DIR} ensure_import_testimage for i in $(seq 5); do - lxc init testimage "leaktest${i}" - lxc info "leaktest${i}" - lxc start "leaktest${i}" - lxc exec "leaktest${i}" -- ps -ef - lxc stop "leaktest${i}" --force - lxc delete "leaktest${i}" + inc init testimage "leaktest${i}" + inc info "leaktest${i}" + inc start "leaktest${i}" + inc exec "leaktest${i}" -- ps -ef + inc stop "leaktest${i}" --force + inc delete "leaktest${i}" done - lxc list - lxc query /internal/gc + inc list + inc query /internal/gc exit 0 ) @@ -40,7 +40,7 @@ test_fdleak() { bad=0 # shellcheck disable=SC2015 - [ ${leakedfds} -gt 5 ] && bad=1 || true + [ "${leakedfds}" -gt 5 ] && bad=1 || true if [ ${bad} -eq 1 ]; then echo "${leakedfds} FDS leaked" ls "/proc/${pid}/fd" -al @@ -48,5 +48,5 @@ test_fdleak() { false fi - kill_lxd "${LXD_FDLEAK_DIR}" + kill_incus "${INCUS_FDLEAK_DIR}" } diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh index c948b88215f..ee9b0d565c2 100644 --- a/test/suites/filemanip.sh +++ b/test/suites/filemanip.sh @@ -2,24 +2,24 @@ test_filemanip() { # Workaround for shellcheck getting confused by "cd" set -e ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" echo "test" > "${TEST_DIR}"/filemanip - lxc project create test -c features.profiles=false -c features.images=false -c features.storage.volumes=false - lxc project switch test - lxc launch testimage filemanip - lxc exec filemanip --project=test -- ln -s /tmp/ /tmp/outside - lxc file push "${TEST_DIR}"/filemanip filemanip/tmp/outside/ + inc project create test -c features.profiles=false -c features.images=false -c features.storage.volumes=false + inc project switch test + inc launch testimage filemanip + inc exec filemanip --project=test -- ln -s /tmp/ /tmp/outside + inc file push "${TEST_DIR}"/filemanip filemanip/tmp/outside/ [ ! -f /tmp/filemanip ] - lxc exec filemanip --project=test -- ls /tmp/filemanip + inc exec filemanip --project=test -- ls /tmp/filemanip # missing files should return 404 - err=$(my_curl -o /dev/null -w "%{http_code}" -X GET "https://${LXD_ADDR}/1.0/containers/filemanip/files?path=/tmp/foo") + err=$(my_curl -o /dev/null -w "%{http_code}" -X GET "https://${INCUS_ADDR}/1.0/containers/filemanip/files?path=/tmp/foo") [ "${err}" -eq "404" ] - # lxc {push|pull} -r + # inc {push|pull} -r mkdir "${TEST_DIR}"/source mkdir "${TEST_DIR}"/source/another_level chown 1000:1000 "${TEST_DIR}"/source/another_level @@ -27,72 +27,72 @@ test_filemanip() { echo "bar" > "${TEST_DIR}"/source/bar ln -s bar "${TEST_DIR}"/source/baz - lxc file push -p -r "${TEST_DIR}"/source filemanip/tmp/ptest + inc file push -p -r "${TEST_DIR}"/source filemanip/tmp/ptest - [ "$(lxc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source/another_level)" = "1000" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source/another_level)" = "1000" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] - [ "$(lxc exec filemanip --project=test -- readlink /tmp/ptest/source/baz)" = "bar" ] + [ "$(inc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source/another_level)" = "1000" ] + [ "$(inc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source/another_level)" = "1000" ] + [ "$(inc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] + [ "$(inc exec filemanip --project=test -- readlink /tmp/ptest/source/baz)" = "bar" ] - lxc exec filemanip --project=test -- rm -rf /tmp/ptest/source + inc exec filemanip --project=test -- rm -rf /tmp/ptest/source # Test pushing/pulling a file with spaces echo "foo" > "${TEST_DIR}/source/file with spaces" - lxc file push -p -r "${TEST_DIR}"/source filemanip/tmp/ptest - lxc exec filemanip --project=test -- find /tmp/ptest/source | grep -q "file with spaces" + inc file push -p -r "${TEST_DIR}"/source filemanip/tmp/ptest + inc exec filemanip --project=test -- find /tmp/ptest/source | grep -q "file with spaces" rm -rf "${TEST_DIR}/source/file with spaces" - lxc file pull -p -r filemanip/tmp/ptest "${TEST_DIR}/dest" + inc file pull -p -r filemanip/tmp/ptest "${TEST_DIR}/dest" find "${TEST_DIR}/dest/" | grep "file with spaces" rm -rf "${TEST_DIR}/dest" # Check that file permissions are not applied to intermediate directories - lxc file push -p --mode=400 "${TEST_DIR}"/source/foo \ + inc file push -p --mode=400 "${TEST_DIR}"/source/foo \ filemanip/tmp/ptest/d1/d2/foo - [ "$(lxc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/d1)" = "750" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/d1/d2)" = "750" ] + [ "$(inc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/d1)" = "750" ] + [ "$(inc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/d1/d2)" = "750" ] - lxc exec filemanip --project=test -- rm -rf /tmp/ptest/d1 + inc exec filemanip --project=test -- rm -rf /tmp/ptest/d1 # Special case where we are in the same directory as the one we are currently # created. oldcwd=$(pwd) cd "${TEST_DIR}" - lxc file push -r source filemanip/tmp/ptest + inc file push -r source filemanip/tmp/ptest - [ "$(lxc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] + [ "$(inc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] - lxc exec filemanip --project=test -- rm -rf /tmp/ptest/source + inc exec filemanip --project=test -- rm -rf /tmp/ptest/source # Special case where we are in the same directory as the one we are currently # created. cd source - lxc file push -r ./ filemanip/tmp/ptest + inc file push -r ./ filemanip/tmp/ptest - [ "$(lxc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/another_level)" = "1000" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/another_level)" = "1000" ] + [ "$(inc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/another_level)" = "1000" ] + [ "$(inc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/another_level)" = "1000" ] - lxc exec filemanip --project=test -- rm -rf /tmp/ptest/* + inc exec filemanip --project=test -- rm -rf /tmp/ptest/* - lxc file push -r ../source filemanip/tmp/ptest + inc file push -r ../source filemanip/tmp/ptest - [ "$(lxc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] - [ "$(lxc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] + [ "$(inc exec filemanip --project=test -- stat -c "%u" /tmp/ptest/source)" = "$(id -u)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%g" /tmp/ptest/source)" = "$(id -g)" ] + [ "$(inc exec filemanip --project=test -- stat -c "%a" /tmp/ptest/source)" = "755" ] # Switch back to old working directory. cd "${oldcwd}" mkdir "${TEST_DIR}"/dest - lxc file pull -r filemanip/tmp/ptest/source "${TEST_DIR}"/dest + inc file pull -r filemanip/tmp/ptest/source "${TEST_DIR}"/dest [ "$(cat "${TEST_DIR}"/dest/source/foo)" = "foo" ] [ "$(cat "${TEST_DIR}"/dest/source/bar)" = "bar" ] @@ -101,35 +101,35 @@ test_filemanip() { [ "$(stat -c "%g" "${TEST_DIR}"/dest/source)" = "$(id -g)" ] [ "$(stat -c "%a" "${TEST_DIR}"/dest/source)" = "755" ] - lxc file push -p "${TEST_DIR}"/source/foo local:filemanip/tmp/this/is/a/nonexistent/directory/ - lxc file pull local:filemanip/tmp/this/is/a/nonexistent/directory/foo "${TEST_DIR}" + inc file push -p "${TEST_DIR}"/source/foo local:filemanip/tmp/this/is/a/nonexistent/directory/ + inc file pull local:filemanip/tmp/this/is/a/nonexistent/directory/foo "${TEST_DIR}" [ "$(cat "${TEST_DIR}"/foo)" = "foo" ] - lxc file push -p "${TEST_DIR}"/source/foo filemanip/. - [ "$(lxc exec filemanip --project=test -- cat /foo)" = "foo" ] + inc file push -p "${TEST_DIR}"/source/foo filemanip/. + [ "$(inc exec filemanip --project=test -- cat /foo)" = "foo" ] - lxc file push -p "${TEST_DIR}"/source/foo filemanip/A/B/C/D/ - [ "$(lxc exec filemanip --project=test -- cat /A/B/C/D/foo)" = "foo" ] + inc file push -p "${TEST_DIR}"/source/foo filemanip/A/B/C/D/ + [ "$(inc exec filemanip --project=test -- cat /A/B/C/D/foo)" = "foo" ] - if [ "$(storage_backend "$LXD_DIR")" != "lvm" ]; then - lxc launch testimage idmap -c "raw.idmap=both 0 0" - [ "$(stat -c %u "${LXD_DIR}/containers/test_idmap/rootfs")" = "0" ] - lxc delete idmap --force + if [ "$(storage_backend "$INCUS_DIR")" != "lvm" ]; then + inc launch testimage idmap -c "raw.idmap=both 0 0" + [ "$(stat -c %u "${INCUS_DIR}/containers/test_idmap/rootfs")" = "0" ] + inc delete idmap --force fi # Test SFTP functionality. - cmd=$(unset -f lxc; command -v lxc) + cmd=$(unset -f inc; command -v inc) $cmd file mount filemanip --listen=127.0.0.1:2022 --no-auth & mountPID=$! sleep 1 output=$(curl -s -S --insecure sftp://127.0.0.1:2022/foo || true) kill -9 ${mountPID} - lxc delete filemanip -f + inc delete filemanip -f [ "$output" = "foo" ] rm "${TEST_DIR}"/source/baz rm -rf "${TEST_DIR}/dest" - lxc project switch default - lxc project delete test + inc project switch default + inc project delete test } diff --git a/test/suites/filtering.sh b/test/suites/filtering.sh index ac9560f7015..c5f3fe44355 100644 --- a/test/suites/filtering.sh +++ b/test/suites/filtering.sh @@ -1,40 +1,40 @@ # Test API filtering. test_filtering() { # shellcheck disable=2039,3043 - local LXD_DIR + local INCUS_DIR - LXD_FILTERING_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + INCUS_FILTERING_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - spawn_lxd "${LXD_FILTERING_DIR}" true + spawn_incus "${INCUS_FILTERING_DIR}" true ( set -e # shellcheck disable=SC2034,SC2030 - LXD_DIR="${LXD_FILTERING_DIR}" + INCUS_DIR="${INCUS_FILTERING_DIR}" ensure_import_testimage - lxc init testimage c1 - lxc init testimage c2 + inc init testimage c1 + inc init testimage c2 - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/instances" --data-urlencode "recursion=0" --data-urlencode "filter=name eq c1" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/instances" --data-urlencode "recursion=0" --data-urlencode "filter=name eq c1" | jq ".metadata | length") [ "${count}" = "1" ] || false - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/instances" --data-urlencode "recursion=1" --data-urlencode "filter=name eq c1" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/instances" --data-urlencode "recursion=1" --data-urlencode "filter=name eq c1" | jq ".metadata | length") [ "${count}" = "1" ] || false - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/instances" --data-urlencode "recursion=2" --data-urlencode "filter=name eq c1" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/instances" --data-urlencode "recursion=2" --data-urlencode "filter=name eq c1" | jq ".metadata | length") [ "${count}" = "1" ] || false - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/images" --data-urlencode "recursion=0" --data-urlencode "filter=properties.os eq BusyBox" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/images" --data-urlencode "recursion=0" --data-urlencode "filter=properties.os eq BusyBox" | jq ".metadata | length") [ "${count}" = "1" ] || false - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/images" --data-urlencode "recursion=1" --data-urlencode "filter=properties.os eq Ubuntu" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/images" --data-urlencode "recursion=1" --data-urlencode "filter=properties.os eq Ubuntu" | jq ".metadata | length") [ "${count}" = "0" ] || false - lxc delete c1 - lxc delete c2 + inc delete c1 + inc delete c2 ) - kill_lxd "${LXD_FILTERING_DIR}" + kill_incus "${INCUS_FILTERING_DIR}" } diff --git a/test/suites/fuidshift.sh b/test/suites/fuidshift.sh index ff6d9c0b807..2ae0a7f434c 100644 --- a/test/suites/fuidshift.sh +++ b/test/suites/fuidshift.sh @@ -9,28 +9,28 @@ test_common_fuidshift() { test_nonroot_fuidshift() { test_common_fuidshift - LXD_FUIDMAP_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + INCUS_FUIDMAP_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) u=$(id -u) g=$(id -g) u1=$((u+1)) g1=$((g+1)) - touch "${LXD_FUIDMAP_DIR}/x1" - fuidshift "${LXD_FUIDMAP_DIR}/x1" -t "u:${u}:100000:1" "g:${g}:100000:1" | tee /dev/stderr | grep "to 100000 100000" > /dev/null || fail=1 + touch "${INCUS_FUIDMAP_DIR}/x1" + fuidshift "${INCUS_FUIDMAP_DIR}/x1" -t "u:${u}:100000:1" "g:${g}:100000:1" | tee /dev/stderr | grep "to 100000 100000" > /dev/null || fail=1 if [ "${fail}" -eq 1 ]; then echo "==> Failed to shift own uid to container root" false fi - fuidshift "${LXD_FUIDMAP_DIR}/x1" -t "u:${u1}:10000:1" "g:${g1}:100000:1" | tee /dev/stderr | grep "to -1 -1" > /dev/null || fail=1 + fuidshift "${INCUS_FUIDMAP_DIR}/x1" -t "u:${u1}:10000:1" "g:${g1}:100000:1" | tee /dev/stderr | grep "to -1 -1" > /dev/null || fail=1 if [ "${fail}" -eq 1 ]; then echo "==> Wrongly shifted invalid uid to container root" false fi # unshift it - chown 100000:100000 "${LXD_FUIDMAP_DIR}/x1" - fuidshift "${LXD_FUIDMAP_DIR}/x1" -r -t "u:${u}:100000:1" "g:${g}:100000:1" | tee /dev/stderr | grep "to 0 0" > /dev/null || fail=1 + chown 100000:100000 "${INCUS_FUIDMAP_DIR}/x1" + fuidshift "${INCUS_FUIDMAP_DIR}/x1" -r -t "u:${u}:100000:1" "g:${g}:100000:1" | tee /dev/stderr | grep "to 0 0" > /dev/null || fail=1 if [ "${fail}" -eq 1 ]; then echo "==> Failed to unshift container root back to own uid" false diff --git a/test/suites/idmap.sh b/test/suites/idmap.sh index b7fe62d3abe..0160a65e3a6 100644 --- a/test/suites/idmap.sh +++ b/test/suites/idmap.sh @@ -44,132 +44,132 @@ test_idmap() { # Setup daemon ensure_import_testimage - # Check a normal, non-isolated container (full LXD id range) - lxc launch testimage idmap + # Check a normal, non-isolated container (full Incus id range) + inc launch testimage idmap - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" = "btrfs" ]; then - lxc exec idmap -- btrfs subvolume create -r /aaa || true + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" = "btrfs" ]; then + inc exec idmap -- btrfs subvolume create -r /aaa || true fi - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] # Confirm that we don't allow double mappings - ! echo "uid $((UID_BASE+1)) 1000" | lxc config set idmap raw.idmap - || false - ! echo "gid $((GID_BASE+1)) 1000" | lxc config set idmap raw.idmap - || false + ! echo "uid $((UID_BASE+1)) 1000" | inc config set idmap raw.idmap - || false + ! echo "gid $((GID_BASE+1)) 1000" | inc config set idmap raw.idmap - || false # Convert container to isolated and confirm it's not using the first range - lxc config set idmap security.idmap.isolated true - lxc restart idmap --force - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+65536))" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+65536))" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] + inc config set idmap security.idmap.isolated true + inc restart idmap --force + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+65536))" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+65536))" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] # Bump allocation size - lxc config set idmap security.idmap.size 100000 - lxc restart idmap --force - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] + inc config set idmap security.idmap.size 100000 + inc restart idmap --force + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] # Test using a custom base - lxc config set idmap security.idmap.base $((UID_BASE+12345)) - lxc config set idmap security.idmap.size 110000 - lxc restart idmap --force - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+12345))" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+12345))" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "110000" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "110000" ] - - # Switch back to full LXD range - lxc config unset idmap security.idmap.base - lxc config unset idmap security.idmap.isolated - lxc config unset idmap security.idmap.size - lxc restart idmap --force - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] - lxc delete idmap --force + inc config set idmap security.idmap.base $((UID_BASE+12345)) + inc config set idmap security.idmap.size 110000 + inc restart idmap --force + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+12345))" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+12345))" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "110000" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "110000" ] + + # Switch back to full Incus range + inc config unset idmap security.idmap.base + inc config unset idmap security.idmap.isolated + inc config unset idmap security.idmap.size + inc restart idmap --force + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] + inc delete idmap --force # Confirm id recycling - lxc launch testimage idmap -c security.idmap.isolated=true - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+65536))" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+65536))" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] + inc launch testimage idmap -c security.idmap.isolated=true + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+65536))" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+65536))" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] # Copy and check that the base differs - lxc copy idmap idmap1 - lxc start idmap1 - [ "$(lxc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+131072))" ] - [ "$(lxc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+131072))" ] - [ "$(lxc exec idmap1 -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] - [ "$(lxc exec idmap1 -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] + inc copy idmap idmap1 + inc start idmap1 + [ "$(inc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}')" = "$((UID_BASE+131072))" ] + [ "$(inc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}')" = "$((GID_BASE+131072))" ] + [ "$(inc exec idmap1 -- cat /proc/self/uid_map | awk '{print $3}')" = "65536" ] + [ "$(inc exec idmap1 -- cat /proc/self/gid_map | awk '{print $3}')" = "65536" ] # Validate non-overlapping maps - lxc exec idmap -- touch /a - ! lxc exec idmap -- chown 65536 /a || false - lxc exec idmap -- chown 65535 /a - PID_1=$(lxc info idmap | awk '/^PID/ {print $2}') + inc exec idmap -- touch /a + ! inc exec idmap -- chown 65536 /a || false + inc exec idmap -- chown 65535 /a + PID_1=$(inc info idmap | awk '/^PID/ {print $2}') UID_1=$(stat -c '%u' "/proc/${PID_1}/root/a") - lxc exec idmap1 -- touch /a - PID_2=$(lxc info idmap1 | awk '/^PID/ {print $2}') + inc exec idmap1 -- touch /a + PID_2=$(inc info idmap1 | awk '/^PID/ {print $2}') UID_2=$(stat -c '%u' "/proc/${PID_2}/root/a") [ "${UID_1}" != "${UID_2}" ] [ "${UID_2}" = "$((UID_1+1))" ] # Check profile inheritance - lxc profile create idmap - lxc profile set idmap security.idmap.isolated true - lxc profile set idmap security.idmap.size 100000 - - lxc launch testimage idmap2 - [ "$(lxc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] - [ "$(lxc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] - [ "$(lxc exec idmap2 -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] - [ "$(lxc exec idmap2 -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] - - lxc profile add idmap idmap - lxc profile add idmap1 idmap - lxc profile add idmap2 idmap - lxc restart idmap idmap1 idmap2 --force - lxc launch testimage idmap3 -p default -p idmap - - UID_1=$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}') - GID_1=$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}') - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] - [ "$(lxc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] - [ "$(lxc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] - - UID_2=$(lxc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}') - GID_2=$(lxc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}') - [ "$(lxc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] - [ "$(lxc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] - [ "$(lxc exec idmap1 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] - [ "$(lxc exec idmap1 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] - - UID_3=$(lxc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}') - GID_3=$(lxc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}') - [ "$(lxc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] - [ "$(lxc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] - [ "$(lxc exec idmap2 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] - [ "$(lxc exec idmap2 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] - - UID_4=$(lxc exec idmap3 -- cat /proc/self/uid_map | awk '{print $2}') - GID_4=$(lxc exec idmap3 -- cat /proc/self/gid_map | awk '{print $2}') - [ "$(lxc exec idmap3 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] - [ "$(lxc exec idmap3 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] - [ "$(lxc exec idmap3 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] - [ "$(lxc exec idmap3 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] + inc profile create idmap + inc profile set idmap security.idmap.isolated true + inc profile set idmap security.idmap.size 100000 + + inc launch testimage idmap2 + [ "$(inc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}')" = "${UID_BASE}" ] + [ "$(inc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}')" = "${GID_BASE}" ] + [ "$(inc exec idmap2 -- cat /proc/self/uid_map | awk '{print $3}')" = "${UIDs}" ] + [ "$(inc exec idmap2 -- cat /proc/self/gid_map | awk '{print $3}')" = "${GIDs}" ] + + inc profile add idmap idmap + inc profile add idmap1 idmap + inc profile add idmap2 idmap + inc restart idmap idmap1 idmap2 --force + inc launch testimage idmap3 -p default -p idmap + + UID_1=$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}') + GID_1=$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}') + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] + [ "$(inc exec idmap -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] + [ "$(inc exec idmap -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] + + UID_2=$(inc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}') + GID_2=$(inc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}') + [ "$(inc exec idmap1 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] + [ "$(inc exec idmap1 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] + [ "$(inc exec idmap1 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] + [ "$(inc exec idmap1 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] + + UID_3=$(inc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}') + GID_3=$(inc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}') + [ "$(inc exec idmap2 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] + [ "$(inc exec idmap2 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] + [ "$(inc exec idmap2 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] + [ "$(inc exec idmap2 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] + + UID_4=$(inc exec idmap3 -- cat /proc/self/uid_map | awk '{print $2}') + GID_4=$(inc exec idmap3 -- cat /proc/self/gid_map | awk '{print $2}') + [ "$(inc exec idmap3 -- cat /proc/self/uid_map | awk '{print $2}')" != "${UID_BASE}" ] + [ "$(inc exec idmap3 -- cat /proc/self/gid_map | awk '{print $2}')" != "${GID_BASE}" ] + [ "$(inc exec idmap3 -- cat /proc/self/uid_map | awk '{print $3}')" = "100000" ] + [ "$(inc exec idmap3 -- cat /proc/self/gid_map | awk '{print $3}')" = "100000" ] [ "${UID_1}" != "${UID_2}" ] [ "${UID_1}" != "${UID_3}" ] @@ -185,10 +185,10 @@ test_idmap() { [ "${GID_2}" != "${GID_4}" ] [ "${UID_3}" != "${UID_4}" ] - lxc delete idmap1 idmap2 idmap3 --force + inc delete idmap1 idmap2 idmap3 --force # Test running out of ids - ! lxc launch testimage idmap1 -c security.idmap.isolated=true -c security.idmap.size=$((UIDs+1)) || false + ! inc launch testimage idmap1 -c security.idmap.isolated=true -c security.idmap.size=$((UIDs+1)) || false # Test raw id maps ( @@ -197,16 +197,16 @@ uid ${UID_BASE} 1000000 gid $((GID_BASE+1)) 1000000 both $((UID_BASE+2)) 2000000 EOF - ) | lxc config set idmap raw.idmap - - lxc restart idmap --force - PID=$(lxc info idmap | awk '/^PID/ {print $2}') + ) | inc config set idmap raw.idmap - + inc restart idmap --force + PID=$(inc info idmap | awk '/^PID/ {print $2}') - lxc exec idmap -- touch /a - lxc exec idmap -- chown 1000000:1000000 /a + inc exec idmap -- touch /a + inc exec idmap -- chown 1000000:1000000 /a [ "$(stat -c '%u:%g' "/proc/${PID}/root/a")" = "${UID_BASE}:$((GID_BASE+1))" ] - lxc exec idmap -- touch /b - lxc exec idmap -- chown 2000000:2000000 /b + inc exec idmap -- touch /b + inc exec idmap -- chown 2000000:2000000 /b [ "$(stat -c '%u:%g' "/proc/${PID}/root/b")" = "$((UID_BASE+2)):$((GID_BASE+2))" ] # Test id ranges @@ -216,17 +216,17 @@ uid $((UID_BASE+10))-$((UID_BASE+19)) 3000000-3000009 gid $((GID_BASE+10))-$((GID_BASE+19)) 3000000-3000009 both $((GID_BASE+20))-$((GID_BASE+29)) 4000000-4000009 EOF - ) | lxc config set idmap raw.idmap - - lxc restart idmap --force - PID=$(lxc info idmap | awk '/^PID/ {print $2}') + ) | inc config set idmap raw.idmap - + inc restart idmap --force + PID=$(inc info idmap | awk '/^PID/ {print $2}') - lxc exec idmap -- touch /c - lxc exec idmap -- chown 3000009:3000009 /c + inc exec idmap -- touch /c + inc exec idmap -- chown 3000009:3000009 /c [ "$(stat -c '%u:%g' "/proc/${PID}/root/c")" = "$((UID_BASE+19)):$((GID_BASE+19))" ] - lxc exec idmap -- touch /d - lxc exec idmap -- chown 4000009:4000009 /d + inc exec idmap -- touch /d + inc exec idmap -- chown 4000009:4000009 /d [ "$(stat -c '%u:%g' "/proc/${PID}/root/d")" = "$((UID_BASE+29)):$((GID_BASE+29))" ] - lxc delete idmap --force + inc delete idmap --force } diff --git a/test/suites/image.sh b/test/suites/image.sh index 8319c07c852..7377ce44815 100644 --- a/test/suites/image.sh +++ b/test/suites/image.sh @@ -1,105 +1,105 @@ test_image_expiry() { # shellcheck disable=2039,3043 - local LXD2_DIR LXD2_ADDR - LXD2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD2_DIR}" - spawn_lxd "${LXD2_DIR}" true - LXD2_ADDR=$(cat "${LXD2_DIR}/lxd.addr") + local INCUS2_DIR INCUS2_ADDR + INCUS2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS2_DIR}" + spawn_incus "${INCUS2_DIR}" true + INCUS2_ADDR=$(cat "${INCUS2_DIR}/incus.addr") ensure_import_testimage # shellcheck disable=2153 - lxc_remote remote add l1 "${LXD_ADDR}" --accept-certificate --password foo - lxc_remote remote add l2 "${LXD2_ADDR}" --accept-certificate --password foo + inc_remote remote add l1 "${INCUS_ADDR}" --accept-certificate --password foo + inc_remote remote add l2 "${INCUS2_ADDR}" --accept-certificate --password foo # Create containers from a remote image in two projects. - lxc_remote project create l2:p1 -c features.images=true -c features.profiles=false - lxc_remote init l1:testimage l2:c1 --project default - lxc_remote project switch l2:p1 - lxc_remote init l1:testimage l2:c2 - lxc_remote project switch l2:default + inc_remote project create l2:p1 -c features.images=true -c features.profiles=false + inc_remote init l1:testimage l2:c1 --project default + inc_remote project switch l2:p1 + inc_remote init l1:testimage l2:c2 + inc_remote project switch l2:default - fp="$(lxc_remote image info testimage | awk '/^Fingerprint/ {print $2}')" + fp="$(inc_remote image info testimage | awk '/^Fingerprint/ {print $2}')" # Confirm the image is cached [ -n "${fp}" ] fpbrief=$(echo "${fp}" | cut -c 1-12) - lxc_remote image list l2: | grep -q "${fpbrief}" + inc_remote image list l2: | grep -q "${fpbrief}" # Test modification of image expiry date - lxc_remote image info "l2:${fp}" | grep -q "Expires.*never" - lxc_remote image show "l2:${fp}" | sed "s/expires_at.*/expires_at: 3000-01-01T00:00:00-00:00/" | lxc_remote image edit "l2:${fp}" - lxc_remote image info "l2:${fp}" | grep -q "Expires.*3000" + inc_remote image info "l2:${fp}" | grep -q "Expires.*never" + inc_remote image show "l2:${fp}" | sed "s/expires_at.*/expires_at: 3000-01-01T00:00:00-00:00/" | inc_remote image edit "l2:${fp}" + inc_remote image info "l2:${fp}" | grep -q "Expires.*3000" # Override the upload date for the image record in the default project. - LXD_DIR="$LXD2_DIR" lxd sql global "UPDATE images SET last_use_date='$(date --rfc-3339=seconds -u -d "2 days ago")' WHERE fingerprint='${fp}' AND project_id = 1" | grep -q "Rows affected: 1" + INCUS_DIR="$INCUS2_DIR" incus sql global "UPDATE images SET last_use_date='$(date --rfc-3339=seconds -u -d "2 days ago")' WHERE fingerprint='${fp}' AND project_id = 1" | grep -q "Rows affected: 1" # Trigger the expiry - lxc_remote config set l2: images.remote_cache_expiry 1 + inc_remote config set l2: images.remote_cache_expiry 1 for _ in $(seq 20); do sleep 1 - ! lxc_remote image list l2: | grep -q "${fpbrief}" && break + ! inc_remote image list l2: | grep -q "${fpbrief}" && break done - ! lxc_remote image list l2: | grep -q "${fpbrief}" || false + ! inc_remote image list l2: | grep -q "${fpbrief}" || false # Check image is still in p1 project and has not been expired. - lxc_remote image list l2: --project p1 | grep -q "${fpbrief}" + inc_remote image list l2: --project p1 | grep -q "${fpbrief}" # Test instance can still be created in p1 project. - lxc_remote project switch l2:p1 - lxc_remote init l1:testimage l2:c3 - lxc_remote project switch l2:default + inc_remote project switch l2:p1 + inc_remote init l1:testimage l2:c3 + inc_remote project switch l2:default # Override the upload date for the image record in the p1 project. - LXD_DIR="$LXD2_DIR" lxd sql global "UPDATE images SET last_use_date='$(date --rfc-3339=seconds -u -d "2 days ago")' WHERE fingerprint='${fp}' AND project_id > 1" | grep -q "Rows affected: 1" - lxc_remote project set l2:p1 images.remote_cache_expiry=1 + INCUS_DIR="$INCUS2_DIR" incus sql global "UPDATE images SET last_use_date='$(date --rfc-3339=seconds -u -d "2 days ago")' WHERE fingerprint='${fp}' AND project_id > 1" | grep -q "Rows affected: 1" + inc_remote project set l2:p1 images.remote_cache_expiry=1 # Trigger the expiry in p1 project by changing global images.remote_cache_expiry. - lxc_remote config unset l2: images.remote_cache_expiry + inc_remote config unset l2: images.remote_cache_expiry for _ in $(seq 20); do sleep 1 - ! lxc_remote image list l2: --project p1 | grep -q "${fpbrief}" && break + ! inc_remote image list l2: --project p1 | grep -q "${fpbrief}" && break done - ! lxc_remote image list l2: --project p1 | grep -q "${fpbrief}" || false + ! inc_remote image list l2: --project p1 | grep -q "${fpbrief}" || false # Cleanup and reset - lxc_remote delete -f l2:c1 - lxc_remote delete -f l2:c2 --project p1 - lxc_remote delete -f l2:c3 --project p1 - lxc_remote project delete l2:p1 - lxc_remote remote remove l1 - lxc_remote remote remove l2 - kill_lxd "$LXD2_DIR" + inc_remote delete -f l2:c1 + inc_remote delete -f l2:c2 --project p1 + inc_remote delete -f l2:c3 --project p1 + inc_remote project delete l2:p1 + inc_remote remote remove l1 + inc_remote remote remove l2 + kill_incus "$INCUS2_DIR" } test_image_list_all_aliases() { ensure_import_testimage # shellcheck disable=2039,2034,2155,3043 - local sum="$(lxc image info testimage | awk '/^Fingerprint/ {print $2}')" - lxc image alias create zzz "$sum" - lxc image list | grep -vq zzz + local sum="$(inc image info testimage | awk '/^Fingerprint/ {print $2}')" + inc image alias create zzz "$sum" + inc image list | grep -vq zzz # both aliases are listed if the "aliases" column is included in output - lxc image list -c L | grep -q testimage - lxc image list -c L | grep -q zzz + inc image list -c L | grep -q testimage + inc image list -c L | grep -q zzz } test_image_import_dir() { ensure_import_testimage - lxc image export testimage + inc image export testimage # shellcheck disable=2039,2034,2155,3043 local image="$(ls -1 -- *.tar.xz)" mkdir -p unpacked tar -C unpacked -xf "$image" # shellcheck disable=2039,2034,2155,3043 - local fingerprint="$(lxc image import unpacked | awk '{print $NF;}')" + local fingerprint="$(inc image import unpacked | awk '{print $NF;}')" rm -rf "$image" unpacked - lxc image export "$fingerprint" + inc image export "$fingerprint" # shellcheck disable=2039,2034,2155,3043 local exported="${fingerprint}.tar.xz" @@ -109,74 +109,74 @@ test_image_import_dir() { test_image_import_existing_alias() { ensure_import_testimage - lxc init testimage c - lxc publish c --alias newimage --alias image2 - lxc delete c - lxc image export testimage testimage.file - lxc image delete testimage + inc init testimage c + inc publish c --alias newimage --alias image2 + inc delete c + inc image export testimage testimage.file + inc image delete testimage # the image can be imported with an existing alias - lxc image import testimage.file --alias newimage - lxc image delete newimage image2 + inc image import testimage.file --alias newimage + inc image delete newimage image2 } test_image_refresh() { # shellcheck disable=2039,3043 - local LXD2_DIR LXD2_ADDR - LXD2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD2_DIR}" - spawn_lxd "${LXD2_DIR}" true - LXD2_ADDR=$(cat "${LXD2_DIR}/lxd.addr") + local INCUS2_DIR INCUS2_ADDR + INCUS2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS2_DIR}" + spawn_incus "${INCUS2_DIR}" true + INCUS2_ADDR=$(cat "${INCUS2_DIR}/incus.addr") ensure_import_testimage - lxc_remote remote add l2 "${LXD2_ADDR}" --accept-certificate --password foo + inc_remote remote add l2 "${INCUS2_ADDR}" --accept-certificate --password foo - poolDriver="$(lxc storage show "$(lxc profile device get default root pool)" | awk '/^driver:/ {print $2}')" + poolDriver="$(inc storage show "$(inc profile device get default root pool)" | awk '/^driver:/ {print $2}')" # Publish image - lxc image copy testimage l2: --alias testimage --public - fp="$(lxc image info l2:testimage | awk '/Fingerprint: / {print $2}')" - lxc image rm testimage + inc image copy testimage l2: --alias testimage --public + fp="$(inc image info l2:testimage | awk '/Fingerprint: / {print $2}')" + inc image rm testimage # Create container from published image - lxc init l2:testimage c1 + inc init l2:testimage c1 # Create an alias for the received image - lxc image alias create testimage "${fp}" + inc image alias create testimage "${fp}" # Change image and publish it - lxc init l2:testimage l2:c1 - echo test | lxc file push - l2:c1/tmp/testfile - lxc publish l2:c1 l2: --alias testimage --reuse --public - new_fp="$(lxc image info l2:testimage | awk '/Fingerprint: / {print $2}')" + inc init l2:testimage l2:c1 + echo test | inc file push - l2:c1/tmp/testfile + inc publish l2:c1 l2: --alias testimage --reuse --public + new_fp="$(inc image info l2:testimage | awk '/Fingerprint: / {print $2}')" # Ensure the images differ [ "${fp}" != "${new_fp}" ] # Check original image exists before refresh. - lxc image info "${fp}" + inc image info "${fp}" if [ "${poolDriver}" != "dir" ]; then # Check old storage volume record exists and new one doesn't. - lxd sql global 'select name from storage_volumes' | grep "${fp}" - ! lxd sql global 'select name from storage_volumes' | grep "${new_fp}" || false + incus sql global 'select name from storage_volumes' | grep "${fp}" + ! incus sql global 'select name from storage_volumes' | grep "${new_fp}" || false fi # Refresh image - lxc image refresh testimage + inc image refresh testimage # Ensure the old image is gone. - ! lxc image info "${fp}" || false + ! inc image info "${fp}" || false if [ "${poolDriver}" != "dir" ]; then # Check old storage volume record has been replaced with new one. - ! lxd sql global 'select name from storage_volumes' | grep "${fp}" || false - lxd sql global 'select name from storage_volumes' | grep "${new_fp}" + ! incus sql global 'select name from storage_volumes' | grep "${fp}" || false + incus sql global 'select name from storage_volumes' | grep "${new_fp}" fi # Cleanup - lxc rm l2:c1 - lxc rm c1 - lxc remote rm l2 - kill_lxd "${LXD2_DIR}" + inc rm l2:c1 + inc rm c1 + inc remote rm l2 + kill_incus "${INCUS2_DIR}" } diff --git a/test/suites/image_acl.sh b/test/suites/image_acl.sh index 61f98bf502b..0cc1223cec9 100644 --- a/test/suites/image_acl.sh +++ b/test/suites/image_acl.sh @@ -2,24 +2,24 @@ test_image_acl() { ensure_import_testimage # Launch a new container with an ACL applied file - lxc launch testimage c1 - CONTAINER_PID="$(lxc query /1.0/instances/c1?recursion=1 | jq '.state.pid')" - lxc exec c1 touch foo + inc launch testimage c1 + CONTAINER_PID="$(inc query /1.0/instances/c1?recursion=1 | jq '.state.pid')" + inc exec c1 touch foo setfacl -m user:1000001:rwx "/proc/$CONTAINER_PID/root/root/foo" setfacl -m group:1000001:rwx "/proc/$CONTAINER_PID/root/root/foo" # Publish the container to a new image - lxc stop c1 - lxc publish c1 --alias c1-with-acl + inc stop c1 + inc publish c1 --alias c1-with-acl # Launch a new container from the existing image - lxc launch c1-with-acl c2 + inc launch c1-with-acl c2 # Check if the ACLs are still present - CONTAINER_PID="$(lxc query /1.0/instances/c2?recursion=1 | jq '.state.pid')" + CONTAINER_PID="$(inc query /1.0/instances/c2?recursion=1 | jq '.state.pid')" getfacl "/proc/$CONTAINER_PID/root/root/foo" | grep -q "user:1000001:rwx" getfacl "/proc/$CONTAINER_PID/root/root/foo" | grep -q "group:1000001:rwx" - lxc delete -f c1 c2 - lxc image delete c1-with-acl + inc delete -f c1 c2 + inc image delete c1-with-acl } diff --git a/test/suites/image_auto_update.sh b/test/suites/image_auto_update.sh index e5c29b8af1e..32e1434b3c2 100644 --- a/test/suites/image_auto_update.sh +++ b/test/suites/image_auto_update.sh @@ -1,38 +1,38 @@ test_image_auto_update() { - if lxc image alias list | grep -q "^| testimage\\s*|.*$"; then - lxc image delete testimage + if inc image alias list | grep -q "^| testimage\\s*|.*$"; then + inc image delete testimage fi # shellcheck disable=2039,3043 - local LXD2_DIR LXD2_ADDR - LXD2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD2_DIR}" - spawn_lxd "${LXD2_DIR}" true - LXD2_ADDR=$(cat "${LXD2_DIR}/lxd.addr") + local INCUS2_DIR INCUS2_ADDR + INCUS2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS2_DIR}" + spawn_incus "${INCUS2_DIR}" true + INCUS2_ADDR=$(cat "${INCUS2_DIR}/incus.addr") - (LXD_DIR=${LXD2_DIR} deps/import-busybox --alias testimage --public) - fp1="$(LXD_DIR=${LXD2_DIR} lxc image info testimage | awk '/^Fingerprint/ {print $2}')" + (INCUS_DIR=${INCUS2_DIR} deps/import-busybox --alias testimage --public) + fp1="$(INCUS_DIR=${INCUS2_DIR} inc image info testimage | awk '/^Fingerprint/ {print $2}')" - lxc remote add l2 "${LXD2_ADDR}" --accept-certificate --password foo - lxc init l2:testimage c1 + inc remote add l2 "${INCUS2_ADDR}" --accept-certificate --password foo + inc init l2:testimage c1 # Now the first image image is in the local store, since it was # downloaded to create c1. - alias="$(lxc image info "${fp1}" | awk '{if ($1 == "Alias:") {print $2}}')" + alias="$(inc image info "${fp1}" | awk '{if ($1 == "Alias:") {print $2}}')" [ "${alias}" = "testimage" ] # Delete the first image from the remote store and replace it with a # new one with a different fingerprint (passing "--template create" # will do that). - (LXD_DIR=${LXD2_DIR} lxc image delete testimage) - (LXD_DIR=${LXD2_DIR} deps/import-busybox --alias testimage --public --template create) - fp2="$(LXD_DIR=${LXD2_DIR} lxc image info testimage | awk '/^Fingerprint/ {print $2}')" + (INCUS_DIR=${INCUS2_DIR} inc image delete testimage) + (INCUS_DIR=${INCUS2_DIR} deps/import-busybox --alias testimage --public --template create) + fp2="$(INCUS_DIR=${INCUS2_DIR} inc image info testimage | awk '/^Fingerprint/ {print $2}')" [ "${fp1}" != "${fp2}" ] # Restart the server to force an image refresh immediately # shellcheck disable=2153 - shutdown_lxd "${LXD_DIR}" - respawn_lxd "${LXD_DIR}" true + shutdown_incus "${INCUS_DIR}" + respawn_incus "${INCUS_DIR}" true # Check that the first image got deleted from the local storage # @@ -40,7 +40,7 @@ test_image_auto_update() { # a little bit before it actually completes. retries=600 while [ "${retries}" != "0" ]; do - if lxc image info "${fp1}" > /dev/null 2>&1; then + if inc image info "${fp1}" > /dev/null 2>&1; then sleep 2 retries=$((retries-1)) continue @@ -54,11 +54,11 @@ test_image_auto_update() { fi # The second image replaced the first one in the local storage. - alias="$(lxc image info "${fp2}" | awk '{if ($1 == "Alias:") {print $2}}')" + alias="$(inc image info "${fp2}" | awk '{if ($1 == "Alias:") {print $2}}')" [ "${alias}" = "testimage" ] - lxc delete c1 - lxc remote remove l2 - lxc image delete "${fp2}" - kill_lxd "$LXD2_DIR" + inc delete c1 + inc remote remove l2 + inc image delete "${fp2}" + kill_incus "$INCUS2_DIR" } diff --git a/test/suites/image_prefer_cached.sh b/test/suites/image_prefer_cached.sh index 90c1fe090b9..fcf37e030d7 100644 --- a/test/suites/image_prefer_cached.sh +++ b/test/suites/image_prefer_cached.sh @@ -2,48 +2,48 @@ # one is preferred, even if the its remote has a more recent one. test_image_prefer_cached() { - if lxc image alias list | grep -q "^| testimage\\s*|.*$"; then - lxc image delete testimage + if inc image alias list | grep -q "^| testimage\\s*|.*$"; then + inc image delete testimage fi # shellcheck disable=2039,3043 - local LXD2_DIR LXD2_ADDR - LXD2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD2_DIR}" - spawn_lxd "${LXD2_DIR}" true - LXD2_ADDR=$(cat "${LXD2_DIR}/lxd.addr") + local INCUS2_DIR INCUS2_ADDR + INCUS2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS2_DIR}" + spawn_incus "${INCUS2_DIR}" true + INCUS2_ADDR=$(cat "${INCUS2_DIR}/incus.addr") - (LXD_DIR=${LXD2_DIR} deps/import-busybox --alias testimage --public) - fp1="$(LXD_DIR=${LXD2_DIR} lxc image info testimage | awk '/^Fingerprint/ {print $2}')" + (INCUS_DIR=${INCUS2_DIR} deps/import-busybox --alias testimage --public) + fp1="$(INCUS_DIR=${INCUS2_DIR} inc image info testimage | awk '/^Fingerprint/ {print $2}')" - lxc remote add l2 "${LXD2_ADDR}" --accept-certificate --password foo - lxc init l2:testimage c1 + inc remote add l2 "${INCUS2_ADDR}" --accept-certificate --password foo + inc init l2:testimage c1 # Now the first image image is in the local store, since it was # downloaded to create c1. - alias="$(lxc image info "${fp1}" | awk '{if ($1 == "Alias:") {print $2}}')" + alias="$(inc image info "${fp1}" | awk '{if ($1 == "Alias:") {print $2}}')" [ "${alias}" = "testimage" ] # Delete the first image from the remote store and replace it with a # new one with a different fingerprint (passing "--template create" # will do that). - (LXD_DIR=${LXD2_DIR} lxc image delete testimage) - (LXD_DIR=${LXD2_DIR} deps/import-busybox --alias testimage --public --template create) - fp2="$(LXD_DIR=${LXD2_DIR} lxc image info testimage | awk '/^Fingerprint/ {print $2}')" + (INCUS_DIR=${INCUS2_DIR} inc image delete testimage) + (INCUS_DIR=${INCUS2_DIR} deps/import-busybox --alias testimage --public --template create) + fp2="$(INCUS_DIR=${INCUS2_DIR} inc image info testimage | awk '/^Fingerprint/ {print $2}')" [ "${fp1}" != "${fp2}" ] # At this point starting a new container from "testimage" should not # result in the new image being downloaded. - lxc init l2:testimage c2 - if lxc image info "${fp2}"; then + inc init l2:testimage c2 + if inc image info "${fp2}"; then echo "The second image ${fp2} was downloaded and the cached one not used" return 1 fi - lxc delete c1 - lxc delete c2 - lxc remote remove l2 - lxc image delete "${fp1}" + inc delete c1 + inc delete c2 + inc remote remove l2 + inc image delete "${fp1}" - kill_lxd "$LXD2_DIR" + kill_incus "$INCUS2_DIR" } diff --git a/test/suites/image_profiles.sh b/test/suites/image_profiles.sh index b91dace76bb..1ea1a04608c 100644 --- a/test/suites/image_profiles.sh +++ b/test/suites/image_profiles.sh @@ -1,105 +1,105 @@ test_image_nil_profile_list() { # Launch container with default profile list and check its profiles ensure_import_testimage - lxc launch testimage c1 - lxc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "default" || false + inc launch testimage c1 + inc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "default" || false # Cleanup - lxc delete c1 -f - lxc image delete testimage + inc delete c1 -f + inc image delete testimage } test_image_empty_profile_list() { # Set the profiles to be an empty list ensure_import_testimage - lxc image show testimage | sed "s/profiles.*/profiles: []/; s/- default//" | lxc image edit testimage + inc image show testimage | sed "s/profiles.*/profiles: []/; s/- default//" | inc image edit testimage # Check that the profile list is correct - lxc image show testimage | grep -q 'profiles: \[\]' || false - ! lxc image show testimage | grep -q -- '- default' || false + inc image show testimage | grep -q 'profiles: \[\]' || false + ! inc image show testimage | grep -q -- '- default' || false # Launch the container and check its profiles - storage=$(lxc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) - lxc launch testimage c1 -s "$storage" - lxc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "^$" || false + storage=$(inc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) + inc launch testimage c1 -s "$storage" + inc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "^$" || false # Cleanup - lxc delete c1 -f - lxc image delete testimage + inc delete c1 -f + inc image delete testimage } test_image_alternate_profile_list() { # Add three new profiles to the profile list ensure_import_testimage - lxc profile create p1 - lxc profile create p2 - lxc profile create p3 - lxc image show testimage | sed "s/profiles.*/profiles: ['p1','p2','p3']/; s/- default//" | lxc image edit testimage + inc profile create p1 + inc profile create p2 + inc profile create p3 + inc image show testimage | sed "s/profiles.*/profiles: ['p1','p2','p3']/; s/- default//" | inc image edit testimage # Check that the profile list is correct - lxc image show testimage | grep -q -- '- p1' || false - lxc image show testimage | grep -q -- '- p2' || false - lxc image show testimage | grep -q -- '- p3' || false - ! lxc image show testimage | grep -q -- '- default' || false + inc image show testimage | grep -q -- '- p1' || false + inc image show testimage | grep -q -- '- p2' || false + inc image show testimage | grep -q -- '- p3' || false + ! inc image show testimage | grep -q -- '- default' || false # Launch the container and check its profiles - storage=$(lxc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) - lxc profile device add p1 root disk path=/ pool="$storage" - lxc launch testimage c1 - lxc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "p1 p2 p3" || false + storage=$(inc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) + inc profile device add p1 root disk path=/ pool="$storage" + inc launch testimage c1 + inc list -f json c1 | jq -r '.[0].profiles | join(" ")' | grep -q "p1 p2 p3" || false # Cleanup - lxc delete c1 -f - lxc profile delete p1 - lxc profile delete p2 - lxc profile delete p3 - lxc image delete testimage + inc delete c1 -f + inc profile delete p1 + inc profile delete p2 + inc profile delete p3 + inc image delete testimage } test_profiles_project_default() { - lxc project switch default + inc project switch default test_image_nil_profile_list test_image_empty_profile_list test_image_alternate_profile_list } test_profiles_project_images_profiles() { - lxc project create project1 - lxc project switch project1 - storage=$(lxc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) - lxc profile device add default root disk path=/ pool="$storage" + inc project create project1 + inc project switch project1 + storage=$(inc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) + inc profile device add default root disk path=/ pool="$storage" test_image_nil_profile_list test_image_empty_profile_list test_image_alternate_profile_list - lxc project switch default - lxc project delete project1 + inc project switch default + inc project delete project1 } # Run the tests with a project that only has the features.images enabled test_profiles_project_images() { - lxc project create project1 -c features.profiles=false - lxc project switch project1 + inc project create project1 -c features.profiles=false + inc project switch project1 test_image_nil_profile_list test_image_empty_profile_list test_image_alternate_profile_list - lxc project switch default - lxc project delete project1 + inc project switch default + inc project delete project1 } test_profiles_project_profiles() { - lxc project create project1 -c features.images=false - lxc project switch project1 - storage=$(lxc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) - lxc profile device add default root disk path=/ pool="$storage" + inc project create project1 -c features.images=false + inc project switch project1 + storage=$(inc storage list | grep "^| " | tail -n 1 | cut -d' ' -f2) + inc profile device add default root disk path=/ pool="$storage" test_image_nil_profile_list test_image_empty_profile_list test_image_alternate_profile_list - lxc project switch default - lxc project delete project1 + inc project switch default + inc project delete project1 } diff --git a/test/suites/incremental_copy.sh b/test/suites/incremental_copy.sh index de8a6fe9c7d..fea05e27725 100644 --- a/test/suites/incremental_copy.sh +++ b/test/suites/incremental_copy.sh @@ -1,16 +1,16 @@ test_incremental_copy() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" do_copy "" "" # cross-pool copy # shellcheck disable=2039,3043 local source_pool - source_pool="lxdtest-$(basename "${LXD_DIR}")-dir-pool" - lxc storage create "${source_pool}" dir - do_copy "${source_pool}" "lxdtest-$(basename "${LXD_DIR}")" - lxc storage rm "${source_pool}" + source_pool="incustest-$(basename "${INCUS_DIR}")-dir-pool" + inc storage create "${source_pool}" dir + do_copy "${source_pool}" "incustest-$(basename "${INCUS_DIR}")" + inc storage rm "${source_pool}" } do_copy() { @@ -20,17 +20,17 @@ do_copy() { local target_pool="${2}" # Make sure the containers don't exist - lxc rm -f c1 c2 || true + inc rm -f c1 c2 || true if [ -z "${source_pool}" ]; then - source_pool=$(lxc profile device get default root pool) + source_pool=$(inc profile device get default root pool) fi - lxc init testimage c1 -s "${source_pool}" - lxc storage volume set "${source_pool}" container/c1 user.foo=main + inc init testimage c1 -s "${source_pool}" + inc storage volume set "${source_pool}" container/c1 user.foo=main # Set size to check this is supported during copy. - lxc config device set c1 root size=50MiB + inc config device set c1 root size=50MiB targetPoolFlag= if [ -n "${target_pool}" ]; then @@ -41,62 +41,62 @@ do_copy() { # Initial copy # shellcheck disable=2086 - lxc copy c1 c2 ${targetPoolFlag} - lxc storage volume get "${target_pool}" container/c2 user.foo | grep -Fx "main" + inc copy c1 c2 ${targetPoolFlag} + inc storage volume get "${target_pool}" container/c2 user.foo | grep -Fx "main" - lxc start c1 c2 + inc start c1 c2 # Target container may not be running when refreshing # shellcheck disable=2086 - ! lxc copy c1 c2 --refresh ${targetPoolFlag} || false + ! inc copy c1 c2 --refresh ${targetPoolFlag} || false # Create test file in c1 - lxc exec c1 -- touch /root/testfile1 + inc exec c1 -- touch /root/testfile1 - lxc stop -f c2 + inc stop -f c2 # Refresh the container and validate the contents # shellcheck disable=2086 - lxc copy c1 c2 --refresh ${targetPoolFlag} - lxc start c2 - lxc exec c2 -- test -f /root/testfile1 - lxc stop -f c2 + inc copy c1 c2 --refresh ${targetPoolFlag} + inc start c2 + inc exec c2 -- test -f /root/testfile1 + inc stop -f c2 # This will create snapshot c1/snap0 - lxc storage volume set "${source_pool}" container/c1 user.foo=snap0 - lxc snapshot c1 - lxc storage volume set "${source_pool}" container/c1 user.foo=snap1 - lxc snapshot c1 - lxc storage volume set "${source_pool}" container/c1 user.foo=main + inc storage volume set "${source_pool}" container/c1 user.foo=snap0 + inc snapshot c1 + inc storage volume set "${source_pool}" container/c1 user.foo=snap1 + inc snapshot c1 + inc storage volume set "${source_pool}" container/c1 user.foo=main # Remove the testfile from c1 and refresh again - lxc exec c1 -- rm /root/testfile1 + inc exec c1 -- rm /root/testfile1 # shellcheck disable=2086 - lxc copy c1 c2 --refresh --instance-only ${targetPoolFlag} - lxc start c2 - ! lxc exec c2 -- test -f /root/testfile1 || false - lxc stop -f c2 + inc copy c1 c2 --refresh --instance-only ${targetPoolFlag} + inc start c2 + ! inc exec c2 -- test -f /root/testfile1 || false + inc stop -f c2 # Check whether snapshot c2/snap0 has been created - ! lxc config show c2/snap0 || false + ! inc config show c2/snap0 || false # shellcheck disable=2086 - lxc copy c1 c2 --refresh ${targetPoolFlag} - lxc config show c2/snap0 - lxc config show c2/snap1 - lxc storage volume get "${target_pool}" container/c2 user.foo | grep -Fx "main" - lxc storage volume get "${target_pool}" container/c2/snap0 user.foo | grep -Fx "snap0" - lxc storage volume get "${target_pool}" container/c2/snap1 user.foo | grep -Fx "snap1" + inc copy c1 c2 --refresh ${targetPoolFlag} + inc config show c2/snap0 + inc config show c2/snap1 + inc storage volume get "${target_pool}" container/c2 user.foo | grep -Fx "main" + inc storage volume get "${target_pool}" container/c2/snap0 user.foo | grep -Fx "snap0" + inc storage volume get "${target_pool}" container/c2/snap1 user.foo | grep -Fx "snap1" # This will create snapshot c2/snap2 - lxc snapshot c2 - lxc config show c2/snap2 - lxc storage volume show "${target_pool}" container/c2/snap2 + inc snapshot c2 + inc config show c2/snap2 + inc storage volume show "${target_pool}" container/c2/snap2 # This should remove c2/snap2 # shellcheck disable=2086 - lxc copy c1 c2 --refresh ${targetPoolFlag} - ! lxc config show c2/snap2 || false - ! lxc storage volume show "${target_pool}" container/c2/snap2 || false + inc copy c1 c2 --refresh ${targetPoolFlag} + ! inc config show c2/snap2 || false + ! inc storage volume show "${target_pool}" container/c2/snap2 || false - lxc rm -f c1 c2 + inc rm -f c1 c2 } diff --git a/test/suites/init_auto.sh b/test/suites/init_auto.sh index a8e0eab835c..1bbc38a0954 100644 --- a/test/suites/init_auto.sh +++ b/test/suites/init_auto.sh @@ -1,68 +1,68 @@ test_init_auto() { - # - lxd init --auto --storage-backend zfs + # - incus init --auto --storage-backend zfs # and - # - lxd init --auto + # - incus init --auto # can't be easily tested on jenkins since it hard-codes "default" as pool # naming. This can cause naming conflicts when multiple test-suites are run on # a single runner. - if [ "$(storage_backend "$LXD_DIR")" = "zfs" ]; then - # lxd init --auto --storage-backend zfs --storage-pool - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + if [ "$(storage_backend "$INCUS_DIR")" = "zfs" ]; then + # incus init --auto --storage-backend zfs --storage-pool + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false configure_loop_device loop_file_1 loop_device_1 # shellcheck disable=SC2154 - zpool create -m none -O compression=on "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool" "${loop_device_1}" - LXD_DIR=${LXD_INIT_DIR} lxd init --auto --storage-backend zfs --storage-pool "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool" - LXD_DIR=${LXD_INIT_DIR} lxc profile show default | grep -q "pool: default" + zpool create -m none -O compression=on "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool" "${loop_device_1}" + INCUS_DIR=${INCUS_INIT_DIR} incus init --auto --storage-backend zfs --storage-pool "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool" + INCUS_DIR=${INCUS_INIT_DIR} inc profile show default | grep -q "pool: default" - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" sed -i "\\|^${loop_device_1}|d" "${TEST_DIR}/loops" losetup -d "${loop_device_1}" - # lxd init --auto --storage-backend zfs --storage-pool / - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # incus init --auto --storage-backend zfs --storage-pool / + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false # shellcheck disable=SC2154 configure_loop_device loop_file_1 loop_device_1 - zpool create -m none -O compression=on "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool" "${loop_device_1}" - LXD_DIR=${LXD_INIT_DIR} lxd init --auto --storage-backend zfs --storage-pool "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool/non-existing-dataset" - kill_lxd "${LXD_INIT_DIR}" + zpool create -m none -O compression=on "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool" "${loop_device_1}" + INCUS_DIR=${INCUS_INIT_DIR} incus init --auto --storage-backend zfs --storage-pool "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool/non-existing-dataset" + kill_incus "${INCUS_INIT_DIR}" - # lxd init --auto --storage-backend zfs --storage-pool / - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # incus init --auto --storage-backend zfs --storage-pool / + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false - zfs create -p -o mountpoint=none "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool/existing-dataset" - LXD_DIR=${LXD_INIT_DIR} lxd init --auto --storage-backend zfs --storage-pool "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool/existing-dataset" + zfs create -p -o mountpoint=none "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool/existing-dataset" + INCUS_DIR=${INCUS_INIT_DIR} incus init --auto --storage-backend zfs --storage-pool "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool/existing-dataset" - kill_lxd "${LXD_INIT_DIR}" - zpool destroy "lxdtest-$(basename "${LXD_DIR}")-pool1-existing-pool" + kill_incus "${INCUS_INIT_DIR}" + zpool destroy "incustest-$(basename "${INCUS_DIR}")-pool1-existing-pool" sed -i "\\|^${loop_device_1}|d" "${TEST_DIR}/loops" losetup -d "${loop_device_1}" - # lxd init --storage-backend zfs --storage-create-loop 1 --storage-pool --auto - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # incus init --storage-backend zfs --storage-create-loop 1 --storage-pool --auto + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false - ZFS_POOL="lxdtest-$(basename "${LXD_DIR}")-init" - LXD_DIR=${LXD_INIT_DIR} lxd init --storage-backend zfs --storage-create-loop 1 --storage-pool "${ZFS_POOL}" --auto + ZFS_POOL="incustest-$(basename "${INCUS_DIR}")-init" + INCUS_DIR=${INCUS_INIT_DIR} incus init --storage-backend zfs --storage-create-loop 1 --storage-pool "${ZFS_POOL}" --auto - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" fi - # lxd init --trust-password test --network-address 127.0.0.1 --network-port LOCAL --auto - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # incus init --trust-password test --network-address 127.0.0.1 --network-port LOCAL --auto + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false - LXD_DIR=${LXD_INIT_DIR} lxd init --trust-password test --network-address 127.0.0.1 --network-port "$(local_tcp_port)" --auto + INCUS_DIR=${INCUS_INIT_DIR} incus init --trust-password test --network-address 127.0.0.1 --network-port "$(local_tcp_port)" --auto - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" } diff --git a/test/suites/init_dump.sh b/test/suites/init_dump.sh index 3fcc6b9a2d3..fb659814cfe 100644 --- a/test/suites/init_dump.sh +++ b/test/suites/init_dump.sh @@ -1,18 +1,18 @@ test_init_dump() { - # - lxd init --dump - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # - incus init --dump + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034 - LXD_DIR=${LXD_INIT_DIR} + INCUS_DIR=${INCUS_INIT_DIR} - storage_pool="lxdtest-$(basename "${LXD_DIR}")-data" + storage_pool="incustest-$(basename "${INCUS_DIR}")-data" driver="dir" - cat < config.yaml + incus init --dump > config.yaml cat < expected.yaml config: core.https_address: 127.0.0.1:9999 @@ -55,17 +55,17 @@ networks: ipv6.address: none description: "" managed: true - name: lxdt$$ + name: inct$$ type: bridge storage_pools: - config: - source: ${LXD_DIR}/storage-pools/${storage_pool} + source: ${INCUS_DIR}/storage-pools/${storage_pool} description: "" name: ${storage_pool} driver: ${driver} profiles: - config: {} - description: Default LXD profile + description: Default Incus profile devices: eth0: name: eth0 @@ -83,7 +83,7 @@ profiles: test0: name: test0 nictype: bridged - parent: lxdt$$ + parent: inct$$ type: nic name: test-profile @@ -92,5 +92,5 @@ EOF diff -u config.yaml expected.yaml ) rm -f config.yaml expected.yaml - kill_lxd "${LXD_INIT_DIR}" + kill_incus "${INCUS_INIT_DIR}" } diff --git a/test/suites/init_interactive.sh b/test/suites/init_interactive.sh index 657d7cbcfea..face23c0085 100644 --- a/test/suites/init_interactive.sh +++ b/test/suites/init_interactive.sh @@ -1,28 +1,28 @@ test_init_interactive() { - # - lxd init - LXD_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD_INIT_DIR}" - spawn_lxd "${LXD_INIT_DIR}" false + # - incus init + INCUS_INIT_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS_INIT_DIR}" + spawn_incus "${INCUS_INIT_DIR}" false ( set -e # shellcheck disable=SC2034 - LXD_DIR=${LXD_INIT_DIR} + INCUS_DIR=${INCUS_INIT_DIR} # XXX We need to remove the eth0 device from the default profile, which - # is typically attached by spawn_lxd. - if lxc profile show default | grep -q eth0; then - lxc profile device remove default eth0 + # is typically attached by spawn_incus. + if inc profile show default | grep -q eth0; then + inc profile device remove default eth0 fi - cat < API extension kernel_limits" ensure_import_testimage - lxc init testimage limits + inc init testimage limits # Set it to a limit < 65536 because older systemd's do not have my nofile # limit patch. - lxc config set limits limits.kernel.nofile 3000 - lxc start limits - pid="$(lxc info limits | awk '/^PID/ {print $2}')" + inc config set limits limits.kernel.nofile 3000 + inc start limits + pid="$(inc info limits | awk '/^PID/ {print $2}')" soft="$(awk '/^Max open files/ {print $4}' /proc/"${pid}"/limits)" hard="$(awk '/^Max open files/ {print $5}' /proc/"${pid}"/limits)" - lxc delete --force limits + inc delete --force limits [ "${soft}" = "3000" ] && [ "${hard}" = "3000" ] } diff --git a/test/suites/lxc-to-incus.sh b/test/suites/lxc-to-incus.sh index 65aeb4545dd..38740d02293 100644 --- a/test/suites/lxc-to-incus.sh +++ b/test/suites/lxc-to-incus.sh @@ -1,11 +1,16 @@ -test_lxc_to_lxd() { - ensure_has_localhost_remote "${LXD_ADDR}" +test_lxc_to_incus() { + if ! command -v "lxc-create" >/dev/null 2>&1; then + echo "==> SKIP: Skipping lxc-to-incus as system is missing LXC" + return + fi + + ensure_has_localhost_remote "${INCUS_ADDR}" LXC_DIR="${TEST_DIR}/lxc" mkdir -p "${LXC_DIR}" - lxc network create lxcbr0 + inc network create lxcbr0 # Create LXC containers lxc-create -P "${LXC_DIR}" -n c1 -B dir -t busybox @@ -17,54 +22,54 @@ test_lxc_to_lxd() { lxc-create -P "${LXC_DIR}" -n c3 -B dir -t busybox # Convert single LXC container (dry run) - lxc-to-lxd --lxcpath "${LXC_DIR}" --dry-run --delete --containers c1 + lxc-to-incus --lxcpath "${LXC_DIR}" --dry-run --delete --containers c1 # Ensure the LXC containers have not been deleted [ "$(lxc-ls -P "${LXC_DIR}" -1 | wc -l)" -eq "3" ] # Ensure no containers have been converted - ! lxc info c1 || false - ! lxc info c2 || false - ! lxc info c3 || false + ! inc info c1 || false + ! inc info c2 || false + ! inc info c3 || false # Convert single LXC container - lxc-to-lxd --lxcpath "${LXC_DIR}" --containers c1 + lxc-to-incus --lxcpath "${LXC_DIR}" --containers c1 # Ensure the LXC containers have not been deleted [ "$(lxc-ls -P "${LXC_DIR}" -1 | wc -l)" -eq 3 ] # Ensure only c1 has been converted - lxc info c1 - ! lxc info c2 || false - ! lxc info c3 || false + inc info c1 + ! inc info c2 || false + ! inc info c3 || false # Ensure the converted container is startable - lxc start c1 - lxc exec c1 -- stat /root/foo - lxc delete -f c1 + inc start c1 + inc exec c1 -- stat /root/foo + inc delete -f c1 # Convert some LXC containers - lxc-to-lxd --lxcpath "${LXC_DIR}" --delete --containers c1,c2 + lxc-to-incus --lxcpath "${LXC_DIR}" --delete --containers c1,c2 # Ensure the LXC containers c1 and c2 have been deleted [ "$(lxc-ls -P "${LXC_DIR}" -1 | wc -l)" -eq 1 ] # Ensure all containers have been converted - lxc info c1 - lxc info c2 - ! lxc info c3 || false + inc info c1 + inc info c2 + ! inc info c3 || false # Convert all LXC containers - lxc-to-lxd --lxcpath "${LXC_DIR}" --delete --all + lxc-to-incus --lxcpath "${LXC_DIR}" --delete --all # Ensure the remaining LXC containers have been deleted [ "$(lxc-ls -P "${LXC_DIR}" -1 | wc -l)" -eq 0 ] # Ensure all containers have been converted - lxc info c1 - lxc info c2 - lxc info c3 + inc info c1 + inc info c2 + inc info c3 - lxc delete -f c1 c2 c3 - lxc network delete lxcbr0 + inc delete -f c1 c2 c3 + inc network delete lxcbr0 } diff --git a/test/suites/metrics.sh b/test/suites/metrics.sh index 7782d4e7faa..e774f2ce8c9 100644 --- a/test/suites/metrics.sh +++ b/test/suites/metrics.sh @@ -1,39 +1,39 @@ test_metrics() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - lxc config set core.https_address "${LXD_ADDR}" + inc config set core.https_address "${INCUS_ADDR}" - lxc launch testimage c1 - lxc init testimage c2 + inc launch testimage c1 + inc init testimage c2 # c1 metrics should show as the container is running - lxc query "/1.0/metrics" | grep "name=\"c1\"" + inc query "/1.0/metrics" | grep "name=\"c1\"" # c2 metrics should not exist as it's not running - ! lxc query "/1.0/metrics" | grep "name=\"c2\"" || false + ! inc query "/1.0/metrics" | grep "name=\"c2\"" || false # create new certificate - openssl req -x509 -newkey rsa:2048 -keyout "${TEST_DIR}/metrics.key" -nodes -out "${TEST_DIR}/metrics.crt" -subj "/CN=lxd.local" + openssl req -x509 -newkey rsa:2048 -keyout "${TEST_DIR}/metrics.key" -nodes -out "${TEST_DIR}/metrics.crt" -subj "/CN=incus.local" # this should fail as the certificate is not trusted yet - curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${LXD_ADDR}/1.0/metrics" | grep "\"error_code\":403" + curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${INCUS_ADDR}/1.0/metrics" | grep "\"error_code\":403" # trust newly created certificate for metrics only - lxc config trust add "${TEST_DIR}/metrics.crt" --type=metrics + inc config trust add "${TEST_DIR}/metrics.crt" --type=metrics # c1 metrics should show as the container is running - curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${LXD_ADDR}/1.0/metrics" | grep "name=\"c1\"" + curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${INCUS_ADDR}/1.0/metrics" | grep "name=\"c1\"" # c2 metrics should not exist as it's not running - ! curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${LXD_ADDR}/1.0/metrics" | grep "name=\"c2\"" || false + ! curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${INCUS_ADDR}/1.0/metrics" | grep "name=\"c2\"" || false # make sure nothing else can be done with this certificate - curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${LXD_ADDR}/1.0/instances" | grep "\"error_code\":403" + curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${INCUS_ADDR}/1.0/instances" | grep "\"error_code\":403" metrics_addr="127.0.0.1:$(local_tcp_port)" - lxc config set core.metrics_address "${metrics_addr}" + inc config set core.metrics_address "${metrics_addr}" # c1 metrics should show as the container is running curl -k -s --cert "${TEST_DIR}/metrics.crt" --key "${TEST_DIR}/metrics.key" -X GET "https://${metrics_addr}/1.0/metrics" | grep "name=\"c1\"" @@ -46,8 +46,8 @@ test_metrics() { # test unauthenticated connections ! curl -k -s -X GET "https://${metrics_addr}/1.0/metrics" | grep "name=\"c1\"" || false - lxc config set core.metrics_authentication=false + inc config set core.metrics_authentication=false curl -k -s -X GET "https://${metrics_addr}/1.0/metrics" | grep "name=\"c1\"" - lxc delete -f c1 c2 + inc delete -f c1 c2 } diff --git a/test/suites/migration.sh b/test/suites/migration.sh index 87b1f2c1908..45af1bd18ef 100644 --- a/test/suites/migration.sh +++ b/test/suites/migration.sh @@ -1,577 +1,582 @@ test_migration() { - # setup a second LXD + # setup a second Incus # shellcheck disable=2039,3043 - local LXD2_DIR LXD2_ADDR lxd_backend + local INCUS2_DIR INCUS2_ADDR incus_backend # shellcheck disable=2153 - lxd_backend=$(storage_backend "$LXD_DIR") + incus_backend=$(storage_backend "$INCUS_DIR") - LXD2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) - chmod +x "${LXD2_DIR}" - spawn_lxd "${LXD2_DIR}" true - LXD2_ADDR=$(cat "${LXD2_DIR}/lxd.addr") + INCUS2_DIR=$(mktemp -d -p "${TEST_DIR}" XXX) + chmod +x "${INCUS2_DIR}" + spawn_incus "${INCUS2_DIR}" true + INCUS2_ADDR=$(cat "${INCUS2_DIR}/incus.addr") # workaround for kernel/criu umount /sys/kernel/debug >/dev/null 2>&1 || true # shellcheck disable=2153 - lxc_remote remote add l1 "${LXD_ADDR}" --accept-certificate --password foo - lxc_remote remote add l2 "${LXD2_ADDR}" --accept-certificate --password foo + inc_remote remote add l1 "${INCUS_ADDR}" --accept-certificate --password foo + inc_remote remote add l2 "${INCUS2_ADDR}" --accept-certificate --password foo - migration "$LXD2_DIR" + migration "$INCUS2_DIR" # This should only run on lvm and when the backend is not random. Otherwise # we might perform existence checks for files or dirs that won't be available # since the logical volume is not mounted when the container is not running. # shellcheck disable=2153 - if [ "${LXD_BACKEND}" = "lvm" ]; then + if [ "${INCUS_BACKEND}" = "lvm" ]; then # Test that non-thinpool lvm backends work fine with migration. # shellcheck disable=2039,3043 local storage_pool1 storage_pool2 # shellcheck disable=2153 - storage_pool1="lxdtest-$(basename "${LXD_DIR}")-non-thinpool-lvm-migration" - storage_pool2="lxdtest-$(basename "${LXD2_DIR}")-non-thinpool-lvm-migration" - lxc_remote storage create l1:"$storage_pool1" lvm lvm.use_thinpool=false size=1GiB volume.size=25MiB - lxc_remote profile device set l1:default root pool "$storage_pool1" + storage_pool1="incustest-$(basename "${INCUS_DIR}")-non-thinpool-lvm-migration" + storage_pool2="incustest-$(basename "${INCUS2_DIR}")-non-thinpool-lvm-migration" + inc_remote storage create l1:"$storage_pool1" lvm lvm.use_thinpool=false size=1GiB volume.size=25MiB + inc_remote profile device set l1:default root pool "$storage_pool1" - lxc_remote storage create l2:"$storage_pool2" lvm lvm.use_thinpool=false size=1GiB volume.size=25MiB - lxc_remote profile device set l2:default root pool "$storage_pool2" + inc_remote storage create l2:"$storage_pool2" lvm lvm.use_thinpool=false size=1GiB volume.size=25MiB + inc_remote profile device set l2:default root pool "$storage_pool2" - migration "$LXD2_DIR" + migration "$INCUS2_DIR" - lxc_remote profile device set l1:default root pool "lxdtest-$(basename "${LXD_DIR}")" - lxc_remote profile device set l2:default root pool "lxdtest-$(basename "${LXD2_DIR}")" + inc_remote profile device set l1:default root pool "incustest-$(basename "${INCUS_DIR}")" + inc_remote profile device set l2:default root pool "incustest-$(basename "${INCUS2_DIR}")" - lxc_remote storage delete l1:"$storage_pool1" - lxc_remote storage delete l2:"$storage_pool2" + inc_remote storage delete l1:"$storage_pool1" + inc_remote storage delete l2:"$storage_pool2" fi - if [ "${LXD_BACKEND}" = "zfs" ]; then + if [ "${INCUS_BACKEND}" = "zfs" ]; then # Test that block mode zfs backends work fine with migration. for fs in "ext4" "btrfs" "xfs"; do + if ! command -v "mkfs.${fs}" >/dev/null 2>&1; then + echo "==> SKIP: Skipping block mode test on ${fs} due to missing tools." + continue + fi + # shellcheck disable=2039,3043 local storage_pool1 storage_pool2 # shellcheck disable=2153 - storage_pool1="lxdtest-$(basename "${LXD_DIR}")-block-mode" - storage_pool2="lxdtest-$(basename "${LXD2_DIR}")-block-mode" - lxc_remote storage create l1:"$storage_pool1" zfs size=1GiB volume.zfs.block_mode=true volume.block.filesystem="${fs}" - lxc_remote profile device set l1:default root pool "$storage_pool1" + storage_pool1="incustest-$(basename "${INCUS_DIR}")-block-mode" + storage_pool2="incustest-$(basename "${INCUS2_DIR}")-block-mode" + inc_remote storage create l1:"$storage_pool1" zfs size=1GiB volume.zfs.block_mode=true volume.block.filesystem="${fs}" + inc_remote profile device set l1:default root pool "$storage_pool1" - lxc_remote storage create l2:"$storage_pool2" zfs size=1GiB volume.zfs.block_mode=true volume.block.filesystem="${fs}" - lxc_remote profile device set l2:default root pool "$storage_pool2" + inc_remote storage create l2:"$storage_pool2" zfs size=1GiB volume.zfs.block_mode=true volume.block.filesystem="${fs}" + inc_remote profile device set l2:default root pool "$storage_pool2" - migration "$LXD2_DIR" + migration "$INCUS2_DIR" - lxc_remote profile device set l1:default root pool "lxdtest-$(basename "${LXD_DIR}")" - lxc_remote profile device set l2:default root pool "lxdtest-$(basename "${LXD2_DIR}")" + inc_remote profile device set l1:default root pool "incustest-$(basename "${INCUS_DIR}")" + inc_remote profile device set l2:default root pool "incustest-$(basename "${INCUS2_DIR}")" - lxc_remote storage delete l1:"$storage_pool1" - lxc_remote storage delete l2:"$storage_pool2" + inc_remote storage delete l1:"$storage_pool1" + inc_remote storage delete l2:"$storage_pool2" done fi - lxc_remote remote remove l1 - lxc_remote remote remove l2 - kill_lxd "$LXD2_DIR" + inc_remote remote remove l1 + inc_remote remote remove l2 + kill_incus "$INCUS2_DIR" } migration() { # shellcheck disable=2039,3043 - local lxd2_dir lxd_backend lxd2_backend - lxd2_dir="$1" - lxd_backend=$(storage_backend "$LXD_DIR") - lxd2_backend=$(storage_backend "$lxd2_dir") + local incus2_dir incus_backend incus2_backend + incus2_dir="$1" + incus_backend=$(storage_backend "$INCUS_DIR") + incus2_backend=$(storage_backend "$incus2_dir") ensure_import_testimage - lxc_remote init testimage nonlive + inc_remote init testimage nonlive # test moving snapshots - lxc_remote config set l1:nonlive user.tester foo - lxc_remote snapshot l1:nonlive - lxc_remote config unset l1:nonlive user.tester - lxc_remote move l1:nonlive l2: - lxc_remote config show l2:nonlive/snap0 | grep user.tester | grep foo + inc_remote config set l1:nonlive user.tester foo + inc_remote snapshot l1:nonlive + inc_remote config unset l1:nonlive user.tester + inc_remote move l1:nonlive l2: + inc_remote config show l2:nonlive/snap0 | grep user.tester | grep foo # This line exists so that the container's storage volume is mounted when we # perform existence check for various files. - lxc_remote start l2:nonlive + inc_remote start l2:nonlive # FIXME: make this backend agnostic - if [ "$lxd2_backend" != "lvm" ] && [ "$lxd2_backend" != "zfs" ] && [ "$lxd2_backend" != "ceph" ]; then - [ -d "${lxd2_dir}/containers/nonlive/rootfs" ] + if [ "$incus2_backend" != "lvm" ] && [ "$incus2_backend" != "zfs" ] && [ "$incus2_backend" != "ceph" ]; then + [ -d "${incus2_dir}/containers/nonlive/rootfs" ] fi - lxc_remote stop l2:nonlive --force + inc_remote stop l2:nonlive --force - [ ! -d "${LXD_DIR}/containers/nonlive" ] + [ ! -d "${INCUS_DIR}/containers/nonlive" ] # FIXME: make this backend agnostic - if [ "$lxd2_backend" = "dir" ]; then - [ -d "${lxd2_dir}/snapshots/nonlive/snap0/rootfs/bin" ] + if [ "$incus2_backend" = "dir" ]; then + [ -d "${incus2_dir}/snapshots/nonlive/snap0/rootfs/bin" ] fi - lxc_remote copy l2:nonlive l1:nonlive2 --mode=push + inc_remote copy l2:nonlive l1:nonlive2 --mode=push # This line exists so that the container's storage volume is mounted when we # perform existence check for various files. - lxc_remote start l2:nonlive - [ -d "${LXD_DIR}/containers/nonlive2" ] + inc_remote start l2:nonlive + [ -d "${INCUS_DIR}/containers/nonlive2" ] # FIXME: make this backend agnostic - if [ "$lxd2_backend" != "lvm" ] && [ "$lxd2_backend" != "zfs" ] && [ "$lxd2_backend" != "ceph" ]; then - [ -d "${lxd2_dir}/containers/nonlive/rootfs/bin" ] + if [ "$incus2_backend" != "lvm" ] && [ "$incus2_backend" != "zfs" ] && [ "$incus2_backend" != "ceph" ]; then + [ -d "${incus2_dir}/containers/nonlive/rootfs/bin" ] fi # FIXME: make this backend agnostic - if [ "$lxd_backend" = "dir" ]; then - [ -d "${LXD_DIR}/snapshots/nonlive2/snap0/rootfs/bin" ] + if [ "$incus_backend" = "dir" ]; then + [ -d "${INCUS_DIR}/snapshots/nonlive2/snap0/rootfs/bin" ] fi - lxc_remote copy l1:nonlive2/snap0 l2:nonlive3 --mode=relay + inc_remote copy l1:nonlive2/snap0 l2:nonlive3 --mode=relay # FIXME: make this backend agnostic - if [ "$lxd2_backend" != "lvm" ] && [ "$lxd2_backend" != "zfs" ] && [ "$lxd2_backend" != "ceph" ]; then - [ -d "${lxd2_dir}/containers/nonlive3/rootfs/bin" ] + if [ "$incus2_backend" != "lvm" ] && [ "$incus2_backend" != "zfs" ] && [ "$incus2_backend" != "ceph" ]; then + [ -d "${incus2_dir}/containers/nonlive3/rootfs/bin" ] fi - lxc_remote delete l2:nonlive3 --force + inc_remote delete l2:nonlive3 --force - lxc_remote stop l2:nonlive --force - lxc_remote copy l2:nonlive l2:nonlive2 --mode=push + inc_remote stop l2:nonlive --force + inc_remote copy l2:nonlive l2:nonlive2 --mode=push # should have the same base image tag - [ "$(lxc_remote config get l2:nonlive volatile.base_image)" = "$(lxc_remote config get l2:nonlive2 volatile.base_image)" ] + [ "$(inc_remote config get l2:nonlive volatile.base_image)" = "$(inc_remote config get l2:nonlive2 volatile.base_image)" ] # check that nonlive2 has a new addr in volatile - [ "$(lxc_remote config get l2:nonlive volatile.eth0.hwaddr)" != "$(lxc_remote config get l2:nonlive2 volatile.eth0.hwaddr)" ] - - lxc_remote config unset l2:nonlive volatile.base_image - lxc_remote copy l2:nonlive l1:nobase - lxc_remote delete l1:nobase - - lxc_remote start l1:nonlive2 - lxc_remote list l1: | grep RUNNING | grep nonlive2 - lxc_remote delete l1:nonlive2 l2:nonlive2 --force - - lxc_remote launch testimage cccp - lxc_remote copy l1:cccp l2:udssr --stateless - lxc_remote delete l2:udssr --force - lxc_remote copy l1:cccp l2:udssr --stateless --mode=push - lxc_remote delete l2:udssr --force - lxc_remote copy l1:cccp l2:udssr --stateless --mode=relay - lxc_remote delete l2:udssr --force - - lxc_remote move l1:cccp l2:udssr --stateless - lxc_remote delete l2:udssr --force - lxc_remote launch testimage cccp - lxc_remote move l1:cccp l2:udssr --stateless --mode=push - lxc_remote delete l2:udssr --force - lxc_remote launch testimage cccp - lxc_remote move l1:cccp l2:udssr --stateless --mode=relay - lxc_remote delete l2:udssr --force - - lxc_remote start l2:nonlive - lxc_remote list l2: | grep RUNNING | grep nonlive - lxc_remote delete l2:nonlive --force + [ "$(inc_remote config get l2:nonlive volatile.eth0.hwaddr)" != "$(inc_remote config get l2:nonlive2 volatile.eth0.hwaddr)" ] + + inc_remote config unset l2:nonlive volatile.base_image + inc_remote copy l2:nonlive l1:nobase + inc_remote delete l1:nobase + + inc_remote start l1:nonlive2 + inc_remote list l1: | grep RUNNING | grep nonlive2 + inc_remote delete l1:nonlive2 l2:nonlive2 --force + + inc_remote launch testimage cccp + inc_remote copy l1:cccp l2:udssr --stateless + inc_remote delete l2:udssr --force + inc_remote copy l1:cccp l2:udssr --stateless --mode=push + inc_remote delete l2:udssr --force + inc_remote copy l1:cccp l2:udssr --stateless --mode=relay + inc_remote delete l2:udssr --force + + inc_remote move l1:cccp l2:udssr --stateless + inc_remote delete l2:udssr --force + inc_remote launch testimage cccp + inc_remote move l1:cccp l2:udssr --stateless --mode=push + inc_remote delete l2:udssr --force + inc_remote launch testimage cccp + inc_remote move l1:cccp l2:udssr --stateless --mode=relay + inc_remote delete l2:udssr --force + + inc_remote start l2:nonlive + inc_remote list l2: | grep RUNNING | grep nonlive + inc_remote delete l2:nonlive --force # Get container's pool. - pool=$(lxc config profile device get default root pool) - remote_pool=$(lxc_remote config profile device get l2:default root pool) + pool=$(inc config profile device get default root pool) + remote_pool=$(inc_remote config profile device get l2:default root pool) # Test container only copies - lxc init testimage cccp + inc init testimage cccp - lxc storage volume set "${pool}" container/cccp user.foo=snap0 - echo "before" | lxc file push - cccp/blah - lxc snapshot cccp - lxc storage volume set "${pool}" container/cccp user.foo=snap1 - lxc snapshot cccp - echo "after" | lxc file push - cccp/blah - lxc storage volume set "${pool}" container/cccp user.foo=postsnap1 + inc storage volume set "${pool}" container/cccp user.foo=snap0 + echo "before" | inc file push - cccp/blah + inc snapshot cccp + inc storage volume set "${pool}" container/cccp user.foo=snap1 + inc snapshot cccp + echo "after" | inc file push - cccp/blah + inc storage volume set "${pool}" container/cccp user.foo=postsnap1 # Check storage volume creation times are set. - lxc query /1.0/storage-pools/"${pool}"/volumes/container/cccp | jq .created_at | grep -Fv '0001-01-01T00:00:00Z' - lxc query /1.0/storage-pools/"${pool}"/volumes/container/cccp/snapshots/snap0 | jq .created_at | grep -Fv '0001-01-01T00:00:00Z' + inc query /1.0/storage-pools/"${pool}"/volumes/container/cccp | jq .created_at | grep -Fv '0001-01-01T00:00:00Z' + inc query /1.0/storage-pools/"${pool}"/volumes/container/cccp/snapshots/snap0 | jq .created_at | grep -Fv '0001-01-01T00:00:00Z' # Local container only copy. - lxc copy cccp udssr --instance-only - [ "$(lxc info udssr | grep -c snap)" -eq 0 ] - [ "$(lxc file pull udssr/blah -)" = "after" ] - lxc delete udssr + inc copy cccp udssr --instance-only + [ "$(inc info udssr | grep -c snap)" -eq 0 ] + [ "$(inc file pull udssr/blah -)" = "after" ] + inc delete udssr # Local container with snapshots copy. - lxc copy cccp udssr - [ "$(lxc info udssr | grep -c snap)" -eq 2 ] - [ "$(lxc file pull udssr/blah -)" = "after" ] - lxc storage volume show "${pool}" container/udssr - lxc storage volume get "${pool}" container/udssr user.foo | grep -Fx "postsnap1" - lxc storage volume get "${pool}" container/udssr/snap0 user.foo | grep -Fx "snap0" - lxc storage volume get "${pool}" container/udssr/snap1 user.foo | grep -Fx "snap1" - lxc delete udssr + inc copy cccp udssr + [ "$(inc info udssr | grep -c snap)" -eq 2 ] + [ "$(inc file pull udssr/blah -)" = "after" ] + inc storage volume show "${pool}" container/udssr + inc storage volume get "${pool}" container/udssr user.foo | grep -Fx "postsnap1" + inc storage volume get "${pool}" container/udssr/snap0 user.foo | grep -Fx "snap0" + inc storage volume get "${pool}" container/udssr/snap1 user.foo | grep -Fx "snap1" + inc delete udssr # Remote container only copy. - lxc_remote copy l1:cccp l2:udssr --instance-only - [ "$(lxc_remote info l2:udssr | grep -c snap)" -eq 0 ] - [ "$(lxc_remote file pull l2:udssr/blah -)" = "after" ] - lxc_remote delete l2:udssr + inc_remote copy l1:cccp l2:udssr --instance-only + [ "$(inc_remote info l2:udssr | grep -c snap)" -eq 0 ] + [ "$(inc_remote file pull l2:udssr/blah -)" = "after" ] + inc_remote delete l2:udssr # Remote container with snapshots copy. - lxc_remote copy l1:cccp l2:udssr - [ "$(lxc_remote info l2:udssr | grep -c snap)" -eq 2 ] - [ "$(lxc_remote file pull l2:udssr/blah -)" = "after" ] - lxc_remote storage volume show l2:"${remote_pool}" container/udssr - lxc_remote storage volume get l2:"${remote_pool}" container/udssr user.foo | grep -Fx "postsnap1" - lxc_remote storage volume get l2:"${remote_pool}" container/udssr/snap0 user.foo | grep -Fx "snap0" - lxc_remote storage volume get l2:"${remote_pool}" container/udssr/snap1 user.foo | grep -Fx "snap1" - lxc_remote delete l2:udssr + inc_remote copy l1:cccp l2:udssr + [ "$(inc_remote info l2:udssr | grep -c snap)" -eq 2 ] + [ "$(inc_remote file pull l2:udssr/blah -)" = "after" ] + inc_remote storage volume show l2:"${remote_pool}" container/udssr + inc_remote storage volume get l2:"${remote_pool}" container/udssr user.foo | grep -Fx "postsnap1" + inc_remote storage volume get l2:"${remote_pool}" container/udssr/snap0 user.foo | grep -Fx "snap0" + inc_remote storage volume get l2:"${remote_pool}" container/udssr/snap1 user.foo | grep -Fx "snap1" + inc_remote delete l2:udssr # Remote container only move. - lxc_remote move l1:cccp l2:udssr --instance-only --mode=relay - ! lxc_remote info l1:cccp || false - [ "$(lxc_remote info l2:udssr | grep -c snap)" -eq 0 ] - lxc_remote delete l2:udssr + inc_remote move l1:cccp l2:udssr --instance-only --mode=relay + ! inc_remote info l1:cccp || false + [ "$(inc_remote info l2:udssr | grep -c snap)" -eq 0 ] + inc_remote delete l2:udssr - lxc_remote init testimage l1:cccp - lxc_remote snapshot l1:cccp - lxc_remote snapshot l1:cccp + inc_remote init testimage l1:cccp + inc_remote snapshot l1:cccp + inc_remote snapshot l1:cccp # Remote container with snapshots move. - lxc_remote move l1:cccp l2:udssr --mode=push - ! lxc_remote info l1:cccp || false - [ "$(lxc_remote info l2:udssr | grep -c snap)" -eq 2 ] - lxc_remote delete l2:udssr + inc_remote move l1:cccp l2:udssr --mode=push + ! inc_remote info l1:cccp || false + [ "$(inc_remote info l2:udssr | grep -c snap)" -eq 2 ] + inc_remote delete l2:udssr # Test container only copies - lxc init testimage cccp - lxc snapshot cccp - lxc snapshot cccp + inc init testimage cccp + inc snapshot cccp + inc snapshot cccp # Local container with snapshots move. - lxc move cccp udssr --mode=pull - ! lxc info cccp || false - [ "$(lxc info udssr | grep -c snap)" -eq 2 ] - lxc delete udssr + inc move cccp udssr --mode=pull + ! inc info cccp || false + [ "$(inc info udssr | grep -c snap)" -eq 2 ] + inc delete udssr - if [ "$lxd_backend" = "zfs" ]; then + if [ "$incus_backend" = "zfs" ]; then # Test container only copies when zfs.clone_copy is set to false. - lxc storage set "lxdtest-$(basename "${LXD_DIR}")" zfs.clone_copy false - lxc init testimage cccp - lxc snapshot cccp - lxc snapshot cccp + inc storage set "incustest-$(basename "${INCUS_DIR}")" zfs.clone_copy false + inc init testimage cccp + inc snapshot cccp + inc snapshot cccp # Test container only copies when zfs.clone_copy is set to false. - lxc copy cccp udssr --instance-only - [ "$(lxc info udssr | grep -c snap)" -eq 0 ] - lxc delete udssr + inc copy cccp udssr --instance-only + [ "$(inc info udssr | grep -c snap)" -eq 0 ] + inc delete udssr # Test container with snapshots copy when zfs.clone_copy is set to false. - lxc copy cccp udssr - [ "$(lxc info udssr | grep -c snap)" -eq 2 ] - lxc delete cccp - lxc delete udssr + inc copy cccp udssr + [ "$(inc info udssr | grep -c snap)" -eq 2 ] + inc delete cccp + inc delete udssr - lxc storage unset "lxdtest-$(basename "${LXD_DIR}")" zfs.clone_copy + inc storage unset "incustest-$(basename "${INCUS_DIR}")" zfs.clone_copy fi - lxc_remote init testimage l1:c1 - lxc_remote copy l1:c1 l2:c2 - lxc_remote copy l1:c1 l2:c2 --refresh + inc_remote init testimage l1:c1 + inc_remote copy l1:c1 l2:c2 + inc_remote copy l1:c1 l2:c2 --refresh - lxc_remote start l1:c1 l2:c2 + inc_remote start l1:c1 l2:c2 # Make sure the testfile doesn't exist - ! lxc file pull l1:c1 -- /root/testfile1 || false - ! lxc file pull l2:c2 -- /root/testfile1 || false + ! inc file pull l1:c1 -- /root/testfile1 || false + ! inc file pull l2:c2 -- /root/testfile1 || false - #lxc_remote start l1:c1 l2:c2 + #inc_remote start l1:c1 l2:c2 # Containers may not be running when refreshing - ! lxc_remote copy l1:c1 l2:c2 --refresh || false + ! inc_remote copy l1:c1 l2:c2 --refresh || false # Create test file in c1 - echo test | lxc_remote file push - l1:c1/root/testfile1 + echo test | inc_remote file push - l1:c1/root/testfile1 - lxc_remote stop -f l1:c1 l2:c2 + inc_remote stop -f l1:c1 l2:c2 # Refresh the container and validate the contents - lxc_remote copy l1:c1 l2:c2 --refresh - lxc_remote start l2:c2 - lxc_remote file pull l2:c2/root/testfile1 . + inc_remote copy l1:c1 l2:c2 --refresh + inc_remote start l2:c2 + inc_remote file pull l2:c2/root/testfile1 . rm testfile1 - lxc_remote stop -f l2:c2 + inc_remote stop -f l2:c2 # This will create snapshot c1/snap0 with test device and expiry date. - lxc_remote config device add l1:c1 testsnapdev none - lxc_remote config set l1:c1 snapshots.expiry '1d' - lxc_remote snapshot l1:c1 - lxc_remote config device remove l1:c1 testsnapdev - lxc_remote config device add l1:c1 testdev none + inc_remote config device add l1:c1 testsnapdev none + inc_remote config set l1:c1 snapshots.expiry '1d' + inc_remote snapshot l1:c1 + inc_remote config device remove l1:c1 testsnapdev + inc_remote config device add l1:c1 testdev none # Remove the testfile from c1 and refresh again - lxc_remote file delete l1:c1/root/testfile1 - lxc_remote copy l1:c1 l2:c2 --refresh --instance-only - lxc_remote start l2:c2 - ! lxc_remote file pull l2:c2/root/testfile1 . || false - lxc_remote stop -f l2:c2 + inc_remote file delete l1:c1/root/testfile1 + inc_remote copy l1:c1 l2:c2 --refresh --instance-only + inc_remote start l2:c2 + ! inc_remote file pull l2:c2/root/testfile1 . || false + inc_remote stop -f l2:c2 # Check whether snapshot c2/snap0 has been created with its config intact. - ! lxc_remote config show l2:c2/snap0 || false - lxc_remote copy l1:c1 l2:c2 --refresh - lxc_remote ls l2: - lxc_remote config show l2:c2/snap0 - ! lxc_remote config show l2:c2/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc_remote config device get l2:c2 testdev type | grep -q 'none' - lxc_remote restore l2:c2 snap0 - lxc_remote config device get l2:c2 testsnapdev type | grep -q 'none' + ! inc_remote config show l2:c2/snap0 || false + inc_remote copy l1:c1 l2:c2 --refresh + inc_remote ls l2: + inc_remote config show l2:c2/snap0 + ! inc_remote config show l2:c2/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc_remote config device get l2:c2 testdev type | grep -q 'none' + inc_remote restore l2:c2 snap0 + inc_remote config device get l2:c2 testsnapdev type | grep -q 'none' # This will create snapshot c2/snap1 - lxc_remote snapshot l2:c2 - lxc_remote config show l2:c2/snap1 + inc_remote snapshot l2:c2 + inc_remote config show l2:c2/snap1 # This should remove c2/snap1 - lxc_remote copy l1:c1 l2:c2 --refresh - ! lxc_remote config show l2:c2/snap1 || false + inc_remote copy l1:c1 l2:c2 --refresh + ! inc_remote config show l2:c2/snap1 || false - lxc_remote rm -f l1:c1 l2:c2 + inc_remote rm -f l1:c1 l2:c2 - remote_pool1="lxdtest-$(basename "${LXD_DIR}")" - remote_pool2="lxdtest-$(basename "${lxd2_dir}")" + remote_pool1="incustest-$(basename "${INCUS_DIR}")" + remote_pool2="incustest-$(basename "${incus2_dir}")" - lxc_remote storage volume create l1:"$remote_pool1" vol1 - lxc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap0vol1 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol1 - lxc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap1vol1 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol1 - lxc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1 + inc_remote storage volume create l1:"$remote_pool1" vol1 + inc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap0vol1 + inc_remote storage volume snapshot l1:"$remote_pool1" vol1 + inc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap1vol1 + inc_remote storage volume snapshot l1:"$remote_pool1" vol1 + inc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1 # remote storage volume and snapshots migration in "pull" mode - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" - lxc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol1" - lxc_remote storage volume delete l2:"$remote_pool2" vol2 + inc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" + inc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol1" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol1" + inc_remote storage volume delete l2:"$remote_pool2" vol2 # check moving volume and snapshots. - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l1:"$remote_pool1/vol2" - lxc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol3" - ! lxc_remote storage volume show l1:"$remote_pool1" vol2 || false - lxc_remote storage volume get l2:"$remote_pool2" vol3 user.foo | grep -Fx "postsnap1vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol3/snap0 user.foo | grep -Fx "snap0vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol3/snap1 user.foo | grep -Fx "snap1vol1" - lxc_remote storage volume delete l2:"$remote_pool2" vol3 - - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --volume-only - lxc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" - ! lxc_remote storage volume show l2:"$remote_pool2" vol2/snap0 || false - ! lxc_remote storage volume show l2:"$remote_pool2" vol2/snap1 || false - lxc_remote storage volume delete l2:"$remote_pool2" vol2 + inc_remote storage volume copy l1:"$remote_pool1/vol1" l1:"$remote_pool1/vol2" + inc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol3" + ! inc_remote storage volume show l1:"$remote_pool1" vol2 || false + inc_remote storage volume get l2:"$remote_pool2" vol3 user.foo | grep -Fx "postsnap1vol1" + inc_remote storage volume get l2:"$remote_pool2" vol3/snap0 user.foo | grep -Fx "snap0vol1" + inc_remote storage volume get l2:"$remote_pool2" vol3/snap1 user.foo | grep -Fx "snap1vol1" + inc_remote storage volume delete l2:"$remote_pool2" vol3 + + inc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --volume-only + inc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" + ! inc_remote storage volume show l2:"$remote_pool2" vol2/snap0 || false + ! inc_remote storage volume show l2:"$remote_pool2" vol2/snap1 || false + inc_remote storage volume delete l2:"$remote_pool2" vol2 # remote storage volume and snapshots migration refresh in "pull" mode - lxc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snapremovevol1 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol1 snapremove - lxc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1 - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --refresh - lxc_remote storage volume delete l1:"$remote_pool1" vol1 + inc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snapremovevol1 + inc_remote storage volume snapshot l1:"$remote_pool1" vol1 snapremove + inc_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1 + inc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --refresh + inc_remote storage volume delete l1:"$remote_pool1" vol1 - lxc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol1" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snapremove user.foo | grep -Fx "snapremovevol1" + inc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol1" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol1" + inc_remote storage volume get l2:"$remote_pool2" vol2/snapremove user.foo | grep -Fx "snapremovevol1" # check remote storage volume refresh from a different volume - lxc_remote storage volume create l1:"$remote_pool1" vol3 - lxc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap0vol3 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol3 - lxc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap1vol3 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol3 - lxc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap2vol3 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol3 - lxc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=postsnap1vol3 + inc_remote storage volume create l1:"$remote_pool1" vol3 + inc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap0vol3 + inc_remote storage volume snapshot l1:"$remote_pool1" vol3 + inc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap1vol3 + inc_remote storage volume snapshot l1:"$remote_pool1" vol3 + inc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap2vol3 + inc_remote storage volume snapshot l1:"$remote_pool1" vol3 + inc_remote storage volume set l1:"$remote_pool1" vol3 user.foo=postsnap1vol3 # check snapshot volumes and snapshots are refreshed - lxc_remote storage volume copy l1:"$remote_pool1/vol3" l2:"$remote_pool2/vol2" --refresh - lxc_remote storage volume ls l2:"$remote_pool2" - lxc_remote storage volume delete l1:"$remote_pool1" vol3 - lxc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" # FIXME Should be postsnap1vol3 - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol3" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol3" - lxc_remote storage volume get l2:"$remote_pool2" vol2/snap2 user.foo | grep -Fx "snap2vol3" - ! lxc_remote storage volume show l2:"$remote_pool2" vol2/snapremove || false + inc_remote storage volume copy l1:"$remote_pool1/vol3" l2:"$remote_pool2/vol2" --refresh + inc_remote storage volume ls l2:"$remote_pool2" + inc_remote storage volume delete l1:"$remote_pool1" vol3 + inc_remote storage volume get l2:"$remote_pool2" vol2 user.foo | grep -Fx "postsnap1vol1" # FIXME Should be postsnap1vol3 + inc_remote storage volume get l2:"$remote_pool2" vol2/snap0 user.foo | grep -Fx "snap0vol3" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap1 user.foo | grep -Fx "snap1vol3" + inc_remote storage volume get l2:"$remote_pool2" vol2/snap2 user.foo | grep -Fx "snap2vol3" + ! inc_remote storage volume show l2:"$remote_pool2" vol2/snapremove || false - lxc_remote storage volume delete l2:"$remote_pool2" vol2 + inc_remote storage volume delete l2:"$remote_pool2" vol2 # remote storage volume migration in "push" mode - lxc_remote storage volume create l1:"$remote_pool1" vol1 - lxc_remote storage volume create l1:"$remote_pool1" vol2 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol2 - - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=push - lxc_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=push - ! lxc_remote storage volume list l1:"$remote_pool1/vol1" || false - lxc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol4" --volume-only --mode=push - lxc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol5" --mode=push - lxc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol6" --mode=push - - lxc_remote storage volume delete l2:"$remote_pool2" vol2 - lxc_remote storage volume delete l2:"$remote_pool2" vol3 - lxc_remote storage volume delete l2:"$remote_pool2" vol4 - lxc_remote storage volume delete l2:"$remote_pool2" vol5 - lxc_remote storage volume delete l2:"$remote_pool2" vol6 + inc_remote storage volume create l1:"$remote_pool1" vol1 + inc_remote storage volume create l1:"$remote_pool1" vol2 + inc_remote storage volume snapshot l1:"$remote_pool1" vol2 + + inc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=push + inc_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=push + ! inc_remote storage volume list l1:"$remote_pool1/vol1" || false + inc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol4" --volume-only --mode=push + inc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol5" --mode=push + inc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol6" --mode=push + + inc_remote storage volume delete l2:"$remote_pool2" vol2 + inc_remote storage volume delete l2:"$remote_pool2" vol3 + inc_remote storage volume delete l2:"$remote_pool2" vol4 + inc_remote storage volume delete l2:"$remote_pool2" vol5 + inc_remote storage volume delete l2:"$remote_pool2" vol6 # remote storage volume migration in "relay" mode - lxc_remote storage volume create l1:"$remote_pool1" vol1 - lxc_remote storage volume create l1:"$remote_pool1" vol2 - lxc_remote storage volume snapshot l1:"$remote_pool1" vol2 - - lxc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=relay - lxc_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=relay - ! lxc_remote storage volume list l1:"$remote_pool1/vol1" || false - lxc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol4" --volume-only --mode=relay - lxc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol5" --mode=relay - lxc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol6" --mode=relay - - lxc_remote storage volume delete l2:"$remote_pool2" vol2 - lxc_remote storage volume delete l2:"$remote_pool2" vol3 - lxc_remote storage volume delete l2:"$remote_pool2" vol4 - lxc_remote storage volume delete l2:"$remote_pool2" vol5 - lxc_remote storage volume delete l2:"$remote_pool2" vol6 + inc_remote storage volume create l1:"$remote_pool1" vol1 + inc_remote storage volume create l1:"$remote_pool1" vol2 + inc_remote storage volume snapshot l1:"$remote_pool1" vol2 + + inc_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=relay + inc_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=relay + ! inc_remote storage volume list l1:"$remote_pool1/vol1" || false + inc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol4" --volume-only --mode=relay + inc_remote storage volume copy l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol5" --mode=relay + inc_remote storage volume move l1:"$remote_pool1/vol2" l2:"$remote_pool2/vol6" --mode=relay + + inc_remote storage volume delete l2:"$remote_pool2" vol2 + inc_remote storage volume delete l2:"$remote_pool2" vol3 + inc_remote storage volume delete l2:"$remote_pool2" vol4 + inc_remote storage volume delete l2:"$remote_pool2" vol5 + inc_remote storage volume delete l2:"$remote_pool2" vol6 # Test migration when rsync compression is disabled - lxc_remote storage set l1:"$remote_pool1" rsync.compression false - lxc_remote storage volume create l1:"$remote_pool1" foo - lxc_remote storage volume copy l1:"$remote_pool1"/foo l2:"$remote_pool2"/bar - lxc_remote storage volume delete l1:"$remote_pool1" foo - lxc_remote storage volume delete l2:"$remote_pool2" bar - lxc_remote storage unset l1:"$remote_pool1" rsync.compression + inc_remote storage set l1:"$remote_pool1" rsync.compression false + inc_remote storage volume create l1:"$remote_pool1" foo + inc_remote storage volume copy l1:"$remote_pool1"/foo l2:"$remote_pool2"/bar + inc_remote storage volume delete l1:"$remote_pool1" foo + inc_remote storage volume delete l2:"$remote_pool2" bar + inc_remote storage unset l1:"$remote_pool1" rsync.compression # Test some migration between projects - lxc_remote project create l1:proj -c features.images=false -c features.profiles=false - lxc_remote project switch l1:proj - - lxc_remote init testimage l1:c1 - lxc_remote copy l1:c1 l2: - lxc_remote start l2:c1 - lxc_remote delete l2:c1 -f - - lxc_remote snapshot l1:c1 - lxc_remote snapshot l1:c1 - lxc_remote snapshot l1:c1 - lxc_remote copy l1:c1 l2: - lxc_remote start l2:c1 - lxc_remote stop l2:c1 -f - lxc_remote delete l1:c1 - - lxc_remote copy l2:c1 l1: - lxc_remote start l1:c1 - lxc_remote delete l1:c1 -f - - lxc_remote delete l2:c1/snap0 - lxc_remote delete l2:c1/snap1 - lxc_remote delete l2:c1/snap2 - lxc_remote copy l2:c1 l1: - lxc_remote start l1:c1 - lxc_remote delete l1:c1 -f - lxc_remote delete l2:c1 -f - - lxc_remote project switch l1:default - lxc_remote project delete l1:proj + inc_remote project create l1:proj -c features.images=false -c features.profiles=false + inc_remote project switch l1:proj + + inc_remote init testimage l1:c1 + inc_remote copy l1:c1 l2: + inc_remote start l2:c1 + inc_remote delete l2:c1 -f + + inc_remote snapshot l1:c1 + inc_remote snapshot l1:c1 + inc_remote snapshot l1:c1 + inc_remote copy l1:c1 l2: + inc_remote start l2:c1 + inc_remote stop l2:c1 -f + inc_remote delete l1:c1 + + inc_remote copy l2:c1 l1: + inc_remote start l1:c1 + inc_remote delete l1:c1 -f + + inc_remote delete l2:c1/snap0 + inc_remote delete l2:c1/snap1 + inc_remote delete l2:c1/snap2 + inc_remote copy l2:c1 l1: + inc_remote start l1:c1 + inc_remote delete l1:c1 -f + inc_remote delete l2:c1 -f + + inc_remote project switch l1:default + inc_remote project delete l1:proj # Check migration with invalid snapshot config (disks attached with missing source pool and source path). - lxc_remote init testimage l1:c1 - lxc_remote storage create l1:dir dir - lxc_remote storage volume create l1:dir vol1 - lxc_remote storage volume attach l1:dir vol1 c1 /mnt - mkdir "$LXD_DIR/testvol2" - lxc_remote config device add l1:c1 vol2 disk source="$LXD_DIR/testvol2" path=/vol2 - lxc_remote snapshot l1:c1 # Take snapshot with disk devices still attached. - lxc_remote config device remove c1 vol1 - lxc_remote config device remove c1 vol2 - rmdir "$LXD_DIR/testvol2" - lxc_remote copy l1:c1 l2: - lxc_remote info l2:c1 | grep snap0 - lxc_remote delete l1:c1 -f - lxc_remote delete l2:c1 -f - lxc_remote storage volume delete l1:dir vol1 - lxc_remote storage delete l1:dir + inc_remote init testimage l1:c1 + inc_remote storage create l1:dir dir + inc_remote storage volume create l1:dir vol1 + inc_remote storage volume attach l1:dir vol1 c1 /mnt + mkdir "$INCUS_DIR/testvol2" + inc_remote config device add l1:c1 vol2 disk source="$INCUS_DIR/testvol2" path=/vol2 + inc_remote snapshot l1:c1 # Take snapshot with disk devices still attached. + inc_remote config device remove c1 vol1 + inc_remote config device remove c1 vol2 + rmdir "$INCUS_DIR/testvol2" + inc_remote copy l1:c1 l2: + inc_remote info l2:c1 | grep snap0 + inc_remote delete l1:c1 -f + inc_remote delete l2:c1 -f + inc_remote storage volume delete l1:dir vol1 + inc_remote storage delete l1:dir # Test optimized refresh - lxc_remote init testimage l1:c1 - echo test | lxc_remote file push - l1:c1/tmp/foo - lxc_remote copy l1:c1 l2:c1 - lxc_remote file pull l2:c1/tmp/foo . - lxc_remote snapshot l1:c1 - echo test | lxc_remote file push - l1:c1/tmp/bar - lxc_remote copy l1:c1 l2:c1 --refresh - lxc_remote start l2:c1 - lxc_remote file pull l2:c1/tmp/foo . - lxc_remote file pull l2:c1/tmp/bar . - lxc_remote stop l2:c1 -f - - lxc_remote restore l2:c1 snap0 - lxc_remote start l2:c1 - lxc_remote file pull l2:c1/tmp/foo . - ! lxc_remote file pull l2:c1/tmp/bar . || false - lxc_remote stop l2:c1 -f + inc_remote init testimage l1:c1 + echo test | inc_remote file push - l1:c1/tmp/foo + inc_remote copy l1:c1 l2:c1 + inc_remote file pull l2:c1/tmp/foo . + inc_remote snapshot l1:c1 + echo test | inc_remote file push - l1:c1/tmp/bar + inc_remote copy l1:c1 l2:c1 --refresh + inc_remote start l2:c1 + inc_remote file pull l2:c1/tmp/foo . + inc_remote file pull l2:c1/tmp/bar . + inc_remote stop l2:c1 -f + + inc_remote restore l2:c1 snap0 + inc_remote start l2:c1 + inc_remote file pull l2:c1/tmp/foo . + ! inc_remote file pull l2:c1/tmp/bar . || false + inc_remote stop l2:c1 -f rm foo bar - lxc_remote rm l1:c1 - lxc_remote rm l2:c1 + inc_remote rm l1:c1 + inc_remote rm l2:c1 - lxc_remote init testimage l1:c1 + inc_remote init testimage l1:c1 # This creates snap0 - lxc_remote snapshot l1:c1 + inc_remote snapshot l1:c1 # This creates snap1 - lxc_remote snapshot l1:c1 - lxc_remote copy l1:c1 l2:c1 + inc_remote snapshot l1:c1 + inc_remote copy l1:c1 l2:c1 # This creates snap2 - lxc_remote snapshot l1:c1 + inc_remote snapshot l1:c1 # Delete first snapshot from target - lxc_remote rm l2:c1/snap0 + inc_remote rm l2:c1/snap0 # Refresh - lxc_remote copy l1:c1 l2:c1 --refresh + inc_remote copy l1:c1 l2:c1 --refresh - lxc_remote rm -f l1:c1 - lxc_remote rm -f l2:c1 + inc_remote rm -f l1:c1 + inc_remote rm -f l2:c1 - # In this scenario the source LXD server used to crash due to a missing slice check. + # In this scenario the source Incus server used to crash due to a missing slice check. # Let's test this to make sure it doesn't happen again. - lxc_remote init testimage l1:c1 - lxc_remote copy l1:c1 l2:c1 - lxc_remote snapshot l1:c1 - lxc_remote snapshot l1:c1 + inc_remote init testimage l1:c1 + inc_remote copy l1:c1 l2:c1 + inc_remote snapshot l1:c1 + inc_remote snapshot l1:c1 - lxc_remote copy l1:c1 l2:c1 --refresh - lxc_remote copy l1:c1 l2:c1 --refresh + inc_remote copy l1:c1 l2:c1 --refresh + inc_remote copy l1:c1 l2:c1 --refresh - lxc_remote rm -f l1:c1 - lxc_remote rm -f l2:c1 + inc_remote rm -f l1:c1 + inc_remote rm -f l2:c1 # On btrfs, this used to cause a failure because btrfs couldn't find the parent subvolume. - lxc_remote init testimage l1:c1 - lxc_remote copy l1:c1 l2:c1 - lxc_remote snapshot l1:c1 - lxc_remote copy l1:c1 l2:c1 --refresh - lxc_remote snapshot l1:c1 - lxc_remote copy l1:c1 l2:c1 --refresh + inc_remote init testimage l1:c1 + inc_remote copy l1:c1 l2:c1 + inc_remote snapshot l1:c1 + inc_remote copy l1:c1 l2:c1 --refresh + inc_remote snapshot l1:c1 + inc_remote copy l1:c1 l2:c1 --refresh - lxc_remote rm -f l1:c1 - lxc_remote rm -f l2:c1 + inc_remote rm -f l1:c1 + inc_remote rm -f l2:c1 # On zfs, this used to crash due to a websocket read issue. - lxc launch testimage c1 - lxc snapshot c1 - lxc copy c1 l2:c1 --stateless - lxc copy c1 l2:c1 --stateless --refresh + inc launch testimage c1 + inc snapshot c1 + inc copy c1 l2:c1 --stateless + inc copy c1 l2:c1 --stateless --refresh - lxc_remote rm -f l1:c1 - lxc_remote rm -f l2:c1 + inc_remote rm -f l1:c1 + inc_remote rm -f l2:c1 # migrate ISO custom volumes truncate -s 25MiB foo.iso - lxc storage volume import l1:"${pool}" ./foo.iso iso1 - lxc storage volume copy l1:"${pool}"/iso1 l2:"${remote_pool}"/iso1 + inc storage volume import l1:"${pool}" ./foo.iso iso1 + inc storage volume copy l1:"${pool}"/iso1 l2:"${remote_pool}"/iso1 - lxc storage volume show l2:"${remote_pool}" iso1 | grep -q 'content_type: iso' - lxc storage volume move l1:"${pool}"/iso1 l2:"${remote_pool}"/iso2 - lxc storage volume show l2:"${remote_pool}" iso2 | grep -q 'content_type: iso' - ! lxc storage volume show l1:"${pool}" iso1 || false + inc storage volume show l2:"${remote_pool}" iso1 | grep -q 'content_type: iso' + inc storage volume move l1:"${pool}"/iso1 l2:"${remote_pool}"/iso2 + inc storage volume show l2:"${remote_pool}" iso2 | grep -q 'content_type: iso' + ! inc storage volume show l1:"${pool}" iso1 || false - lxc storage volume delete l2:"${remote_pool}" iso1 - lxc storage volume delete l2:"${remote_pool}" iso2 + inc storage volume delete l2:"${remote_pool}" iso1 + inc storage volume delete l2:"${remote_pool}" iso2 rm -f foo.iso if ! command -v criu >/dev/null 2>&1; then @@ -580,39 +585,39 @@ migration() { fi echo "==> CRIU: starting testing live-migration" - lxc_remote launch testimage l1:migratee -c raw.lxc=lxc.console.path=none + inc_remote launch testimage l1:migratee -c raw.lxc=lxc.console.path=none # Wait for the container to be done booting sleep 1 # Test stateful stop - lxc_remote stop --stateful l1:migratee - lxc_remote start l1:migratee + inc_remote stop --stateful l1:migratee + inc_remote start l1:migratee # Test stateful snapshots # There is apparently a bug in CRIU that prevents checkpointing an instance that has been started from a # checkpoint. So stop instance first before taking stateful snapshot. - lxc_remote stop -f l1:migratee - lxc_remote start l1:migratee - lxc_remote snapshot --stateful l1:migratee - lxc_remote restore l1:migratee snap0 + inc_remote stop -f l1:migratee + inc_remote start l1:migratee + inc_remote snapshot --stateful l1:migratee + inc_remote restore l1:migratee snap0 # Test live migration of container # There is apparently a bug in CRIU that prevents checkpointing an instance that has been started from a # checkpoint. So stop instance first before taking stateful snapshot. - lxc_remote stop -f l1:migratee - lxc_remote start l1:migratee - lxc_remote move l1:migratee l2:migratee + inc_remote stop -f l1:migratee + inc_remote start l1:migratee + inc_remote move l1:migratee l2:migratee # Test copy of stateful snapshot - lxc_remote copy l2:migratee/snap0 l1:migratee - ! lxc_remote copy l2:migratee/snap0 l1:migratee-new-name || false + inc_remote copy l2:migratee/snap0 l1:migratee + ! inc_remote copy l2:migratee/snap0 l1:migratee-new-name || false # Test stateless copies - lxc_remote copy --stateless l2:migratee/snap0 l1:migratee-new-name + inc_remote copy --stateless l2:migratee/snap0 l1:migratee-new-name # Cleanup - lxc_remote delete --force l1:migratee - lxc_remote delete --force l2:migratee - lxc_remote delete --force l1:migratee-new-name + inc_remote delete --force l1:migratee + inc_remote delete --force l2:migratee + inc_remote delete --force l1:migratee-new-name } diff --git a/test/suites/network.sh b/test/suites/network.sh index 092c3d1e6ae..4689d19dcbc 100644 --- a/test/suites/network.sh +++ b/test/suites/network.sh @@ -1,89 +1,89 @@ test_network() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - lxc init testimage nettest + inc init testimage nettest # Standard bridge with random subnet and a bunch of options - lxc network create lxdt$$ - lxc network set lxdt$$ dns.mode dynamic - lxc network set lxdt$$ dns.domain blah - lxc network set lxdt$$ ipv4.routing false - lxc network set lxdt$$ ipv6.routing false - lxc network set lxdt$$ ipv6.dhcp.stateful true - lxc network set lxdt$$ bridge.hwaddr 00:11:22:33:44:55 - [ "$(cat /sys/class/net/lxdt$$/address)" = "00:11:22:33:44:55" ] + inc network create inct$$ + inc network set inct$$ dns.mode dynamic + inc network set inct$$ dns.domain blah + inc network set inct$$ ipv4.routing false + inc network set inct$$ ipv6.routing false + inc network set inct$$ ipv6.dhcp.stateful true + inc network set inct$$ bridge.hwaddr 00:11:22:33:44:55 + [ "$(cat /sys/class/net/inct$$/address)" = "00:11:22:33:44:55" ] # validate unset and patch - [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "true" ] - lxc network unset lxdt$$ ipv6.dhcp.stateful - [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "" ] - lxc query -X PATCH -d "{\\\"config\\\": {\\\"ipv6.dhcp.stateful\\\": \\\"true\\\"}}" /1.0/networks/lxdt$$ - [ "$(lxc network get lxdt$$ ipv6.dhcp.stateful)" = "true" ] + [ "$(inc network get inct$$ ipv6.dhcp.stateful)" = "true" ] + inc network unset inct$$ ipv6.dhcp.stateful + [ "$(inc network get inct$$ ipv6.dhcp.stateful)" = "" ] + inc query -X PATCH -d "{\\\"config\\\": {\\\"ipv6.dhcp.stateful\\\": \\\"true\\\"}}" /1.0/networks/inct$$ + [ "$(inc network get inct$$ ipv6.dhcp.stateful)" = "true" ] # check ipv4.address and ipv6.address can be unset without triggering random subnet generation. - lxc network unset lxdt$$ ipv4.address - ! lxc network show lxdt$$ | grep ipv4.address || false - lxc network unset lxdt$$ ipv6.address - ! lxc network show lxdt$$ | grep ipv6.address || false + inc network unset inct$$ ipv4.address + ! inc network show inct$$ | grep ipv4.address || false + inc network unset inct$$ ipv6.address + ! inc network show inct$$ | grep ipv6.address || false # check ipv4.address and ipv6.address can be regenerated on update using "auto" value. - lxc network set lxdt$$ ipv4.address auto - lxc network show lxdt$$ | grep ipv4.address - lxc network set lxdt$$ ipv6.address auto - lxc network show lxdt$$ | grep ipv6.address + inc network set inct$$ ipv4.address auto + inc network show inct$$ | grep ipv4.address + inc network set inct$$ ipv6.address auto + inc network show inct$$ | grep ipv6.address # delete the network - lxc network delete lxdt$$ + inc network delete inct$$ # edit network description - lxc network create lxdt$$ - lxc network show lxdt$$ | sed 's/^description:.*/description: foo/' | lxc network edit lxdt$$ - lxc network show lxdt$$ | grep -q 'description: foo' - lxc network delete lxdt$$ + inc network create inct$$ + inc network show inct$$ | sed 's/^description:.*/description: foo/' | inc network edit inct$$ + inc network show inct$$ | grep -q 'description: foo' + inc network delete inct$$ # rename network - lxc network create lxdt$$ - lxc network rename lxdt$$ newnet$$ - lxc network list | grep -qv lxdt$$ # the old name is gone - lxc network delete newnet$$ + inc network create inct$$ + inc network rename inct$$ newnet$$ + inc network list | grep -qv inct$$ # the old name is gone + inc network delete newnet$$ # Unconfigured bridge - lxc network create lxdt$$ ipv4.address=none ipv6.address=none - lxc network delete lxdt$$ + inc network create inct$$ ipv4.address=none ipv6.address=none + inc network delete inct$$ # Configured bridge with static assignment - lxc network create lxdt$$ dns.domain=test dns.mode=managed ipv6.dhcp.stateful=true - lxc network attach lxdt$$ nettest eth0 - v4_addr="$(lxc network get lxdt$$ ipv4.address | cut -d/ -f1)0" - v6_addr="$(lxc network get lxdt$$ ipv6.address | cut -d/ -f1)00" - lxc config device set nettest eth0 ipv4.address "${v4_addr}" - lxc config device set nettest eth0 ipv6.address "${v6_addr}" - grep -q "${v4_addr}.*nettest" "${LXD_DIR}/networks/lxdt$$/dnsmasq.hosts/nettest.eth0" - grep -q "${v6_addr}.*nettest" "${LXD_DIR}/networks/lxdt$$/dnsmasq.hosts/nettest.eth0" - lxc start nettest - - lxc network list-leases lxdt$$ | grep STATIC | grep -q "${v4_addr}" - lxc network list-leases lxdt$$ | grep STATIC | grep -q "${v6_addr}" + inc network create inct$$ dns.domain=test dns.mode=managed ipv6.dhcp.stateful=true + inc network attach inct$$ nettest eth0 + v4_addr="$(inc network get inct$$ ipv4.address | cut -d/ -f1)0" + v6_addr="$(inc network get inct$$ ipv6.address | cut -d/ -f1)00" + inc config device set nettest eth0 ipv4.address "${v4_addr}" + inc config device set nettest eth0 ipv6.address "${v6_addr}" + grep -q "${v4_addr}.*nettest" "${INCUS_DIR}/networks/inct$$/dnsmasq.hosts/nettest.eth0" + grep -q "${v6_addr}.*nettest" "${INCUS_DIR}/networks/inct$$/dnsmasq.hosts/nettest.eth0" + inc start nettest + + inc network list-leases inct$$ | grep STATIC | grep -q "${v4_addr}" + inc network list-leases inct$$ | grep STATIC | grep -q "${v6_addr}" # Request DHCPv6 lease (if udhcpc6 is in busybox image). busyboxUdhcpc6=1 - if ! lxc exec nettest -- busybox --list | grep udhcpc6 ; then + if ! inc exec nettest -- busybox --list | grep udhcpc6 ; then busyboxUdhcpc6=0 fi if [ "$busyboxUdhcpc6" = "1" ]; then - lxc exec nettest -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' + inc exec nettest -- udhcpc6 -f -i eth0 -n -q -t5 2>&1 | grep 'IPv6 obtained' fi # Check IPAM information - net_ipv4="$(lxc network get lxdt$$ ipv4.address)" - net_ipv6="$(lxc network get lxdt$$ ipv6.address)" + net_ipv4="$(inc network get inct$$ ipv4.address)" + net_ipv6="$(inc network get inct$$ ipv6.address)" - lxc network list-allocations | grep -e "${net_ipv4}" -e "${net_ipv6}" - lxc network list-allocations | grep -e "/1.0/networks/lxdt$$" -e "/1.0/instances/nettest" - lxc network list-allocations | grep -e "${v4_addr}" -e "${v6_addr}" + inc network list-allocations | grep -e "${net_ipv4}" -e "${net_ipv6}" + inc network list-allocations | grep -e "/1.0/networks/inct$$" -e "/1.0/instances/nettest" + inc network list-allocations | grep -e "${v4_addr}" -e "${v6_addr}" - lxc delete nettest -f - lxc network delete lxdt$$ + inc delete nettest -f + inc network delete inct$$ } diff --git a/test/suites/network_acl.sh b/test/suites/network_acl.sh index ba186b69a56..28cb39a101f 100644 --- a/test/suites/network_acl.sh +++ b/test/suites/network_acl.sh @@ -1,25 +1,25 @@ test_network_acl() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Check basic ACL creation, listing, deletion and project namespacing support. - ! lxc network acl create 192.168.1.1 || false # Don't allow non-hostname compatible names. - lxc network acl create testacl - lxc project create testproj -c features.networks=true - lxc project create testproj2 -c features.networks=false - lxc network acl create testacl --project testproj - lxc project show testproj | grep testacl # Check project sees testacl using it. - ! lxc network acl create testacl --project testproj2 || false - lxc network acl ls | grep testacl - lxc network acl ls --project testproj | grep testacl - lxc network acl delete testacl - lxc network acl delete testacl --project testproj - ! lxc network acl ls | grep testacl || false - ! lxc network acl ls --project testproj | grep testacl || false - lxc project delete testproj + ! inc network acl create 192.168.1.1 || false # Don't allow non-hostname compatible names. + inc network acl create testacl + inc project create testproj -c features.networks=true + inc project create testproj2 -c features.networks=false + inc network acl create testacl --project testproj + inc project show testproj | grep testacl # Check project sees testacl using it. + ! inc network acl create testacl --project testproj2 || false + inc network acl ls | grep testacl + inc network acl ls --project testproj | grep testacl + inc network acl delete testacl + inc network acl delete testacl --project testproj + ! inc network acl ls | grep testacl || false + ! inc network acl ls --project testproj | grep testacl || false + inc project delete testproj # ACL creation from stdin. - cat < state - lxc file push state bar/root/state - lxc file push state bar/root/file_only_in_snap0 - lxc exec bar -- mkdir /root/dir_only_in_snap0 - lxc exec bar -- ln -s file_only_in_snap0 /root/statelink - lxc stop bar --force + inc file push state bar/root/state + inc file push state bar/root/file_only_in_snap0 + inc exec bar -- mkdir /root/dir_only_in_snap0 + inc exec bar -- ln -s file_only_in_snap0 /root/statelink + inc stop bar --force # Get container's pool. - pool=$(lxc config profile device get default root pool) + pool=$(inc config profile device get default root pool) - lxc storage volume set "${pool}" container/bar user.foo=snap0 + inc storage volume set "${pool}" container/bar user.foo=snap0 # Check parent volume.block.filesystem is copied to snapshot and not from pool. - if [ "$lxd_backend" = "lvm" ] || [ "$lxd_backend" = "ceph" ]; then + if [ "$incus_backend" = "lvm" ] || [ "$incus_backend" = "ceph" ]; then # Change pool volume.block.filesystem setting after creation of instance and before snapshot. - lxc storage set "${pool}" volume.block.filesystem=xfs + inc storage set "${pool}" volume.block.filesystem=xfs fi - lxc snapshot bar snap0 + inc snapshot bar snap0 ## prepare snap1 - lxc start bar + inc start bar echo snap1 > state - lxc file push state bar/root/state - lxc file push state bar/root/file_only_in_snap1 - - lxc exec bar -- rmdir /root/dir_only_in_snap0 - lxc exec bar -- rm /root/file_only_in_snap0 - lxc exec bar -- rm /root/statelink - lxc exec bar -- ln -s file_only_in_snap1 /root/statelink - lxc exec bar -- mkdir /root/dir_only_in_snap1 - initialUUID=$(lxc config get bar volatile.uuid) - initialGenerationID=$(lxc config get bar volatile.uuid.generation) - lxc stop bar --force - lxc storage volume set "${pool}" container/bar user.foo=snap1 + inc file push state bar/root/state + inc file push state bar/root/file_only_in_snap1 + + inc exec bar -- rmdir /root/dir_only_in_snap0 + inc exec bar -- rm /root/file_only_in_snap0 + inc exec bar -- rm /root/statelink + inc exec bar -- ln -s file_only_in_snap1 /root/statelink + inc exec bar -- mkdir /root/dir_only_in_snap1 + initialUUID=$(inc config get bar volatile.uuid) + initialGenerationID=$(inc config get bar volatile.uuid.generation) + inc stop bar --force + inc storage volume set "${pool}" container/bar user.foo=snap1 # Delete the state file we created to prevent leaking. rm state - lxc config set bar limits.cpu 1 + inc config set bar limits.cpu 1 - lxc snapshot bar snap1 - lxc storage volume set "${pool}" container/bar user.foo=postsnaps + inc snapshot bar snap1 + inc storage volume set "${pool}" container/bar user.foo=postsnaps # Check volume.block.filesystem on storage volume in parent and snapshot match. - if [ "${lxd_backend}" = "lvm" ] || [ "${lxd_backend}" = "ceph" ]; then + if [ "${incus_backend}" = "lvm" ] || [ "${incus_backend}" = "ceph" ]; then # Change pool volume.block.filesystem setting after creation of instance and before snapshot. - pool=$(lxc config profile device get default root pool) - parentFS=$(lxc storage volume get "${pool}" container/bar block.filesystem) - snapFS=$(lxc storage volume get "${pool}" container/bar/snap0 block.filesystem) + pool=$(inc config profile device get default root pool) + parentFS=$(inc storage volume get "${pool}" container/bar block.filesystem) + snapFS=$(inc storage volume get "${pool}" container/bar/snap0 block.filesystem) if [ "${parentFS}" != "${snapFS}" ]; then echo "block.filesystem settings do not match in parent and snapshot" false fi - lxc storage unset "${pool}" volume.block.filesystem + inc storage unset "${pool}" volume.block.filesystem fi ########################################################## - if [ "$lxd_backend" != "zfs" ]; then + if [ "$incus_backend" != "zfs" ]; then # The problem here is that you can't `zfs rollback` to a snapshot with a # parent, which snap0 has (snap1). restore_and_compare_fs snap0 # Check container config has been restored (limits.cpu is unset) - cpus=$(lxc config get bar limits.cpu) + cpus=$(inc config get bar limits.cpu) if [ -n "${cpus}" ]; then echo "==> config didn't match expected value after restore (${cpus})" false fi # Check storage volume has been restored (user.foo=snap0) - lxc storage volume get "${pool}" container/bar user.foo | grep -Fx "snap0" + inc storage volume get "${pool}" container/bar user.foo | grep -Fx "snap0" fi ########################################################## @@ -210,14 +210,14 @@ snap_restore() { restore_and_compare_fs snap1 # Check that instances UUID remain the same before and after snapshoting - newUUID=$(lxc config get bar volatile.uuid) + newUUID=$(inc config get bar volatile.uuid) if [ "${initialUUID}" != "${newUUID}" ]; then echo "==> UUID of the instance should remain the same after restoring its snapshot" false fi # Check that the generation UUID from before changes compared to the one after snapshoting - newGenerationID=$(lxc config get bar volatile.uuid.generation) + newGenerationID=$(inc config get bar volatile.uuid.generation) if [ "${initialGenerationID}" = "${newGenerationID}" ]; then echo "==> Generation UUID of the instance should change after restoring its snapshot" false @@ -227,167 +227,167 @@ snap_restore() { if ! command -v criu >/dev/null 2>&1; then echo "==> SKIP: stateful snapshotting with CRIU (missing binary)" else - initialUUID=$(lxc config get bar volatile.uuid) - initialGenerationID=$(lxc config get bar volatile.uuid.generation) - lxc start bar - lxc snapshot bar snap2 --stateful + initialUUID=$(inc config get bar volatile.uuid) + initialGenerationID=$(inc config get bar volatile.uuid.generation) + inc start bar + inc snapshot bar snap2 --stateful restore_and_compare_fs snap2 - newUUID=$(lxc config get bar volatile.uuid) + newUUID=$(inc config get bar volatile.uuid) if [ "${initialUUID}" != "${newUUID}" ]; then echo "==> UUID of the instance should remain the same after restoring its stateful snapshot" false fi - newGenerationID=$(lxc config get bar volatile.uuid.generation) + newGenerationID=$(inc config get bar volatile.uuid.generation) if [ "${initialGenerationID}" = "${newGenerationID}" ]; then echo "==> Generation UUID of the instance should change after restoring its stateful snapshot" false fi - lxc stop bar --force + inc stop bar --force fi # Check that instances have two different UUID after a snapshot copy - lxc launch testimage bar2 - initialUUID=$(lxc config get bar2 volatile.uuid) - initialGenerationID=$(lxc config get bar2 volatile.uuid.generation) - lxc copy bar2 bar3 - newUUID=$(lxc config get bar3 volatile.uuid) - newGenerationID=$(lxc config get bar3 volatile.uuid.generation) + inc launch testimage bar2 + initialUUID=$(inc config get bar2 volatile.uuid) + initialGenerationID=$(inc config get bar2 volatile.uuid.generation) + inc copy bar2 bar3 + newUUID=$(inc config get bar3 volatile.uuid) + newGenerationID=$(inc config get bar3 volatile.uuid.generation) if [ "${initialGenerationID}" = "${newGenerationID}" ] || [ "${initialUUID}" = "${newUUID}" ]; then echo "==> UUIDs of the instance should be different after copying snapshot into instance" false fi - lxc delete --force bar2 - lxc delete --force bar3 + inc delete --force bar2 + inc delete --force bar3 # Check config value in snapshot has been restored - cpus=$(lxc config get bar limits.cpu) + cpus=$(inc config get bar limits.cpu) if [ "${cpus}" != "1" ]; then echo "==> config didn't match expected value after restore (${cpus})" false fi # Check storage volume has been restored (user.foo=snap0) - lxc storage volume get "${pool}" container/bar user.foo | grep -Fx "snap1" + inc storage volume get "${pool}" container/bar user.foo | grep -Fx "snap1" ########################################################## # Start container and then restore snapshot to verify the running state after restore. - lxc start bar + inc start bar - if [ "$lxd_backend" != "zfs" ]; then + if [ "$incus_backend" != "zfs" ]; then # see comment above about snap0 restore_and_compare_fs snap0 # check container is running after restore - lxc list | grep bar | grep RUNNING + inc list | grep bar | grep RUNNING fi - lxc stop --force bar + inc stop --force bar - lxc delete bar + inc delete bar # Test if container's with hyphen's in their names are treated correctly. - lxc launch testimage a-b - lxc snapshot a-b base - lxc restore a-b base - lxc snapshot a-b c-d - lxc restore a-b c-d - lxc delete -f a-b + inc launch testimage a-b + inc snapshot a-b base + inc restore a-b base + inc snapshot a-b c-d + inc restore a-b c-d + inc delete -f a-b } restore_and_compare_fs() { snap=${1} echo "==> Restoring ${snap}" - lxc restore bar "${snap}" + inc restore bar "${snap}" # FIXME: make this backend agnostic - if [ "$(storage_backend "$LXD_DIR")" = "dir" ]; then + if [ "$(storage_backend "$INCUS_DIR")" = "dir" ]; then # Recursive diff of container FS - diff -r "${LXD_DIR}/containers/bar/rootfs" "${LXD_DIR}/snapshots/bar/${snap}/rootfs" + diff -r "${INCUS_DIR}/containers/bar/rootfs" "${INCUS_DIR}/snapshots/bar/${snap}/rootfs" fi } test_snap_expiry() { # shellcheck disable=2039,3043 - local lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") + local incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - lxc launch testimage c1 - lxc snapshot c1 - lxc config show c1/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' + inc launch testimage c1 + inc snapshot c1 + inc config show c1/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z' - lxc config set c1 snapshots.expiry '1d' - lxc snapshot c1 - ! lxc config show c1/snap1 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc config set c1 snapshots.expiry '1d' + inc snapshot c1 + ! inc config show c1/snap1 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc copy c1 c2 - ! lxc config show c2/snap1 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc copy c1 c2 + ! inc config show c2/snap1 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc snapshot c1 --no-expiry - lxc config show c1/snap2 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc snapshot c1 --no-expiry + inc config show c1/snap2 | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc rm -f c1 - lxc rm -f c2 + inc rm -f c1 + inc rm -f c2 } test_snap_schedule() { # shellcheck disable=2039,3043 - local lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") + local incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Check we get a snapshot on first start - lxc launch testimage c1 -c snapshots.schedule='@startup' - lxc launch testimage c2 -c snapshots.schedule='@startup, @daily' - lxc launch testimage c3 -c snapshots.schedule='@startup, 10 5,6 * * *' - lxc launch testimage c4 -c snapshots.schedule='@startup, 10 5-8 * * *' - lxc launch testimage c5 -c snapshots.schedule='@startup, 10 2,5-8/2 * * *' - lxc info c1 | grep -q snap0 - lxc info c2 | grep -q snap0 - lxc info c3 | grep -q snap0 - lxc info c4 | grep -q snap0 - lxc info c5 | grep -q snap0 + inc launch testimage c1 -c snapshots.schedule='@startup' + inc launch testimage c2 -c snapshots.schedule='@startup, @daily' + inc launch testimage c3 -c snapshots.schedule='@startup, 10 5,6 * * *' + inc launch testimage c4 -c snapshots.schedule='@startup, 10 5-8 * * *' + inc launch testimage c5 -c snapshots.schedule='@startup, 10 2,5-8/2 * * *' + inc info c1 | grep -q snap0 + inc info c2 | grep -q snap0 + inc info c3 | grep -q snap0 + inc info c4 | grep -q snap0 + inc info c5 | grep -q snap0 # Check we get a new snapshot on restart - lxc restart c1 -f - lxc info c1 | grep -q snap1 + inc restart c1 -f + inc info c1 | grep -q snap1 - lxc rm -f c1 c2 c3 c4 c5 + inc rm -f c1 c2 c3 c4 c5 } test_snap_volume_db_recovery() { # shellcheck disable=2039,3043 - local lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") + local incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" - - poolName=$(lxc profile device get default root pool) - - lxc init testimage c1 - lxc snapshot c1 - lxc snapshot c1 - lxc start c1 - lxc stop -f c1 - lxd sql global 'DELETE FROM storage_volumes_snapshots' # Remove volume snapshot DB records. - lxd sql local 'DELETE FROM patches WHERE name = "storage_missing_snapshot_records"' # Clear patch indicator. - ! lxc start c1 || false # Shouldn't be able to start as backup.yaml generation checks for DB consistency. - lxd shutdown - respawn_lxd "${LXD_DIR}" true - lxc storage volume show "${poolName}" container/c1/snap0 | grep "Auto repaired" - lxc storage volume show "${poolName}" container/c1/snap1 | grep "Auto repaired" - lxc start c1 - lxc delete -f c1 + ensure_has_localhost_remote "${INCUS_ADDR}" + + poolName=$(inc profile device get default root pool) + + inc init testimage c1 + inc snapshot c1 + inc snapshot c1 + inc start c1 + inc stop -f c1 + incus sql global 'DELETE FROM storage_volumes_snapshots' # Remove volume snapshot DB records. + incus sql local 'DELETE FROM patches WHERE name = "storage_missing_snapshot_records"' # Clear patch indicator. + ! inc start c1 || false # Shouldn't be able to start as backup.yaml generation checks for DB consistency. + incus shutdown + respawn_incus "${INCUS_DIR}" true + inc storage volume show "${poolName}" container/c1/snap0 | grep "Auto repaired" + inc storage volume show "${poolName}" container/c1/snap1 | grep "Auto repaired" + inc start c1 + inc delete -f c1 } diff --git a/test/suites/sql.sh b/test/suites/sql.sh index 65719e511df..25334963cf8 100644 --- a/test/suites/sql.sh +++ b/test/suites/sql.sh @@ -1,59 +1,59 @@ -# Test the lxd sql command. +# Test the incus sql command. test_sql() { # Invalid arguments - ! lxd sql foo "SELECT * FROM CONFIG" || false - ! lxd sql global "" || false + ! incus sql foo "SELECT * FROM CONFIG" || false + ! incus sql global "" || false # Local database query - lxd sql local "SELECT * FROM config" | grep -qF "core.https_address" + incus sql local "SELECT * FROM config" | grep -qF "core.https_address" # Global database query - lxd sql global "SELECT * FROM config" | grep -qF "core.trust_password" + incus sql global "SELECT * FROM config" | grep -qF "core.trust_password" # Global database insert - lxd sql global "INSERT INTO config(key,value) VALUES('core.https_allowed_credentials','true')" | grep -qxF "Rows affected: 1" - lxd sql global "DELETE FROM config WHERE key='core.https_allowed_credentials'" | grep -qxF "Rows affected: 1" + incus sql global "INSERT INTO config(key,value) VALUES('core.https_allowed_credentials','true')" | grep -qxF "Rows affected: 1" + incus sql global "DELETE FROM config WHERE key='core.https_allowed_credentials'" | grep -qxF "Rows affected: 1" # Standard input - echo "SELECT * FROM config" | lxd sql global - | grep -qF "core.trust_password" + echo "SELECT * FROM config" | incus sql global - | grep -qF "core.trust_password" # Multiple queries - lxd sql global "SELECT * FROM config; SELECT * FROM instances" | grep -qxF "=> Query 0:" + incus sql global "SELECT * FROM config; SELECT * FROM instances" | grep -qxF "=> Query 0:" # Local database dump SQLITE_DUMP="${TEST_DIR}/dump.db" - lxd sql local .dump | sqlite3 "${SQLITE_DUMP}" + incus sql local .dump | sqlite3 "${SQLITE_DUMP}" sqlite3 "${SQLITE_DUMP}" "SELECT * FROM patches" | grep -qF "|dnsmasq_entries_include_device_name|" rm -f "${SQLITE_DUMP}" # Local database schema dump SQLITE_DUMP="${TEST_DIR}/dump.db" - lxd sql local .schema | sqlite3 "${SQLITE_DUMP}" + incus sql local .schema | sqlite3 "${SQLITE_DUMP}" [ "$(sqlite3 "${SQLITE_DUMP}" 'SELECT * FROM schema' | wc -l)" = "0" ] [ "$(sqlite3 "${SQLITE_DUMP}" 'SELECT * FROM patches' | wc -l)" = "0" ] rm -f "${SQLITE_DUMP}" # Global database dump SQLITE_DUMP="${TEST_DIR}/dump.db" - GLOBAL_DUMP="$(lxd sql global .dump)" + GLOBAL_DUMP="$(incus sql global .dump)" echo "$GLOBAL_DUMP" | grep -F "CREATE TRIGGER" # ensure triggers are captured. echo "$GLOBAL_DUMP" | grep -F "CREATE INDEX" # ensure indices are captured. echo "$GLOBAL_DUMP" | grep -F "CREATE VIEW" # ensure views are captured. echo "$GLOBAL_DUMP" | sqlite3 "${SQLITE_DUMP}" - sqlite3 "${SQLITE_DUMP}" "SELECT * FROM profiles" | grep -qF "|Default LXD profile|" + sqlite3 "${SQLITE_DUMP}" "SELECT * FROM profiles" | grep -qF "|Default Incus profile|" rm -f "${SQLITE_DUMP}" # Global database schema dump SQLITE_DUMP="${TEST_DIR}/dump.db" - lxd sql global .schema | sqlite3 "${SQLITE_DUMP}" + incus sql global .schema | sqlite3 "${SQLITE_DUMP}" [ "$(sqlite3 "${SQLITE_DUMP}" 'SELECT * FROM schema' | wc -l)" = "0" ] [ "$(sqlite3 "${SQLITE_DUMP}" 'SELECT * FROM profiles' | wc -l)" = "0" ] rm -f "${SQLITE_DUMP}" # Sync the global database to disk - SQLITE_SYNC="${LXD_DIR}/database/global/db.bin" + SQLITE_SYNC="${INCUS_DIR}/database/global/db.bin" echo "SYNC ${SQLITE_SYNC}" - lxd sql global .sync + incus sql global .sync sqlite3 "${SQLITE_SYNC}" "SELECT * FROM schema" | grep -q "^1|" - sqlite3 "${SQLITE_SYNC}" "SELECT * FROM profiles" | grep -qF "|Default LXD profile|" + sqlite3 "${SQLITE_SYNC}" "SELECT * FROM profiles" | grep -qF "|Default Incus profile|" } diff --git a/test/suites/storage.sh b/test/suites/storage.sh index 99dadda33ee..75ab71109df 100644 --- a/test/suites/storage.sh +++ b/test/suites/storage.sh @@ -2,760 +2,760 @@ test_storage() { ensure_import_testimage # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + incus_backend=$(storage_backend "$INCUS_DIR") + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false # edit storage and pool description # shellcheck disable=2039,3043 local storage_pool storage_volume - storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool" + storage_pool="incustest-$(basename "${INCUS_DIR}")-pool" storage_volume="${storage_pool}-vol" - lxc storage create "$storage_pool" "$lxd_backend" - lxc storage show "$storage_pool" | sed 's/^description:.*/description: foo/' | lxc storage edit "$storage_pool" - lxc storage show "$storage_pool" | grep -q 'description: foo' + inc storage create "$storage_pool" "$incus_backend" + inc storage show "$storage_pool" | sed 's/^description:.*/description: foo/' | inc storage edit "$storage_pool" + inc storage show "$storage_pool" | grep -q 'description: foo' - lxc storage volume create "$storage_pool" "$storage_volume" + inc storage volume create "$storage_pool" "$storage_volume" # Test setting description on a storage volume - lxc storage volume show "$storage_pool" "$storage_volume" | sed 's/^description:.*/description: bar/' | lxc storage volume edit "$storage_pool" "$storage_volume" - lxc storage volume show "$storage_pool" "$storage_volume" | grep -q 'description: bar' + inc storage volume show "$storage_pool" "$storage_volume" | sed 's/^description:.*/description: bar/' | inc storage volume edit "$storage_pool" "$storage_volume" + inc storage volume show "$storage_pool" "$storage_volume" | grep -q 'description: bar' # Validate get/set - lxc storage set "$storage_pool" user.abc def - [ "$(lxc storage get "$storage_pool" user.abc)" = "def" ] + inc storage set "$storage_pool" user.abc def + [ "$(inc storage get "$storage_pool" user.abc)" = "def" ] - lxc storage volume set "$storage_pool" "$storage_volume" user.abc def - [ "$(lxc storage volume get "$storage_pool" "$storage_volume" user.abc)" = "def" ] + inc storage volume set "$storage_pool" "$storage_volume" user.abc def + [ "$(inc storage volume get "$storage_pool" "$storage_volume" user.abc)" = "def" ] - lxc storage volume delete "$storage_pool" "$storage_volume" + inc storage volume delete "$storage_pool" "$storage_volume" # Test copying pool volume.* key to the volume with prefix stripped at volume creation time - lxc storage set "$storage_pool" volume.snapshots.expiry 3d - lxc storage volume create "$storage_pool" "$storage_volume" - [ "$(lxc storage volume get "$storage_pool" "$storage_volume" snapshots.expiry)" = "3d" ] - lxc storage volume delete "$storage_pool" "$storage_volume" + inc storage set "$storage_pool" volume.snapshots.expiry 3d + inc storage volume create "$storage_pool" "$storage_volume" + [ "$(inc storage volume get "$storage_pool" "$storage_volume" snapshots.expiry)" = "3d" ] + inc storage volume delete "$storage_pool" "$storage_volume" - lxc storage delete "$storage_pool" + inc storage delete "$storage_pool" # Test btrfs resize - if [ "$lxd_backend" = "lvm" ] || [ "$lxd_backend" = "ceph" ]; then + if [ "$incus_backend" = "lvm" ] || [ "$incus_backend" = "ceph" ]; then # shellcheck disable=2039,3043 local btrfs_storage_pool btrfs_storage_volume - btrfs_storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool-btrfs" + btrfs_storage_pool="incustest-$(basename "${INCUS_DIR}")-pool-btrfs" btrfs_storage_volume="${storage_pool}-vol" - lxc storage create "$btrfs_storage_pool" "$lxd_backend" volume.block.filesystem=btrfs volume.size=200MiB - lxc storage volume create "$btrfs_storage_pool" "$btrfs_storage_volume" - lxc storage volume show "$btrfs_storage_pool" "$btrfs_storage_volume" - lxc storage volume set "$btrfs_storage_pool" "$btrfs_storage_volume" size 256MiB - lxc storage volume delete "$btrfs_storage_pool" "$btrfs_storage_volume" + inc storage create "$btrfs_storage_pool" "$incus_backend" volume.block.filesystem=btrfs volume.size=200MiB + inc storage volume create "$btrfs_storage_pool" "$btrfs_storage_volume" + inc storage volume show "$btrfs_storage_pool" "$btrfs_storage_volume" + inc storage volume set "$btrfs_storage_pool" "$btrfs_storage_volume" size 256MiB + inc storage volume delete "$btrfs_storage_pool" "$btrfs_storage_volume" # Test generation of unique UUID. - lxc init testimage uuid1 -s "lxdtest-$(basename "${LXD_DIR}")-pool-btrfs" - POOL="lxdtest-$(basename "${LXD_DIR}")-pool-btrfs" - lxc copy uuid1 uuid2 - lxc start uuid1 - lxc start uuid2 - if [ "$lxd_backend" = "lvm" ]; then + inc init testimage uuid1 -s "incustest-$(basename "${INCUS_DIR}")-pool-btrfs" + POOL="incustest-$(basename "${INCUS_DIR}")-pool-btrfs" + inc copy uuid1 uuid2 + inc start uuid1 + inc start uuid2 + if [ "$incus_backend" = "lvm" ]; then [ "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)" != "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid2)" ] - elif [ "$lxd_backend" = "ceph" ]; then + elif [ "$incus_backend" = "ceph" ]; then [ "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)" != "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid2)" ] fi - lxc delete --force uuid1 - lxc delete --force uuid2 - lxc image delete testimage + inc delete --force uuid1 + inc delete --force uuid2 + inc image delete testimage - lxc storage delete "$btrfs_storage_pool" + inc storage delete "$btrfs_storage_pool" fi ensure_import_testimage ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" # shellcheck disable=SC1009 - if [ "$lxd_backend" = "zfs" ]; then + if [ "$incus_backend" = "zfs" ]; then # Create loop file zfs pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" zfs + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool1" zfs - # Check that we can't create a loop file in a non-LXD owned location. - INVALID_LOOP_FILE="$(mktemp -p "${LXD_DIR}" XXXXXXXXX)-invalid-loop-file" - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" zfs source="${INVALID_LOOP_FILE}" || false + # Check that we can't create a loop file in a non-Incus owned location. + INVALID_LOOP_FILE="$(mktemp -p "${INCUS_DIR}" XXXXXXXXX)-invalid-loop-file" + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-pool1" zfs source="${INVALID_LOOP_FILE}" || false - # Let LXD use an already existing dataset. - zfs create -p -o mountpoint=none "lxdtest-$(basename "${LXD_DIR}")-pool1/existing-dataset-as-pool" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool7" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool1/existing-dataset-as-pool" + # Let Incus use an already existing dataset. + zfs create -p -o mountpoint=none "incustest-$(basename "${INCUS_DIR}")-pool1/existing-dataset-as-pool" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool7" zfs source="incustest-$(basename "${INCUS_DIR}")-pool1/existing-dataset-as-pool" - # Let LXD use an already existing storage pool. + # Let Incus use an already existing storage pool. configure_loop_device loop_file_4 loop_device_4 # shellcheck disable=SC2154 - zpool create -f -m none -O compression=on "lxdtest-$(basename "${LXD_DIR}")-pool9-existing-pool" "${loop_device_4}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool9" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool9-existing-pool" + zpool create -f -m none -O compression=on "incustest-$(basename "${INCUS_DIR}")-pool9-existing-pool" "${loop_device_4}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool9" zfs source="incustest-$(basename "${INCUS_DIR}")-pool9-existing-pool" - # Let LXD create a new dataset and use as pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool8" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool1/non-existing-dataset-as-pool" + # Let Incus create a new dataset and use as pool. + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool8" zfs source="incustest-$(basename "${INCUS_DIR}")-pool1/non-existing-dataset-as-pool" # Create device backed zfs pool configure_loop_device loop_file_1 loop_device_1 # shellcheck disable=SC2154 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool2" zfs source="${loop_device_1}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool2" zfs source="${loop_device_1}" # Test that no invalid zfs storage pool configuration keys can be set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.thinpool_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.use_thinpool=false || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.vg_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-zfs-pool-config" zfs lvm.thinpool_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-zfs-pool-config" zfs lvm.use_thinpool=false || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-zfs-pool-config" zfs lvm.vg_name=bla || false # Test that all valid zfs storage pool configuration keys can be set. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs volume.zfs.remove_snapshots=true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" zfs volume.zfs.remove_snapshots=true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs volume.zfs.use_refquota=true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" zfs volume.zfs.use_refquota=true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs zfs.clone_copy=true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" zfs zfs.clone_copy=true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs zfs.pool_name="lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" zfs zfs.pool_name="incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs rsync.bwlimit=1024 - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" zfs rsync.bwlimit=1024 + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-zfs-pool-config" fi - if [ "$lxd_backend" = "btrfs" ]; then + if [ "$incus_backend" = "btrfs" ]; then # Create loop file btrfs pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool3" btrfs + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool3" btrfs # Create device backed btrfs pool. configure_loop_device loop_file_2 loop_device_2 # shellcheck disable=SC2154 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool4" btrfs source="${loop_device_2}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool4" btrfs source="${loop_device_2}" - # Check that we cannot create storage pools inside of ${LXD_DIR} other than ${LXD_DIR}/storage-pools/{pool_name}. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" btrfs source="${LXD_DIR}" || false + # Check that we cannot create storage pools inside of ${INCUS_DIR} other than ${INCUS_DIR}/storage-pools/{pool_name}. + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-pool5_under_incus_dir" btrfs source="${INCUS_DIR}" || false # Test that no invalid btrfs storage pool configuration keys can be set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.thinpool_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.use_thinpool=false || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.vg_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.filesystem=ext4 || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.mount_options=discard || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.remove_snapshots=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.use_refquota=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs zfs.clone_copy=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs zfs.pool_name=bla || false - - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs rsync.bwlimit=1024 - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" - - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs btrfs.mount_options="rw,strictatime,user_subvol_rm_allowed" - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs.mount_options "rw,relatime,user_subvol_rm_allowed" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs lvm.thinpool_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs lvm.use_thinpool=false || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs lvm.vg_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.filesystem=ext4 || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.mount_options=discard || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.remove_snapshots=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.use_refquota=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs zfs.clone_copy=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-btrfs-pool-config" btrfs zfs.pool_name=bla || false + + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-btrfs-pool-config" btrfs rsync.bwlimit=1024 + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-btrfs-pool-config" + + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-btrfs-pool-config" btrfs btrfs.mount_options="rw,strictatime,user_subvol_rm_allowed" + inc storage set "incustest-$(basename "${INCUS_DIR}")-valid-btrfs-pool-config" btrfs.mount_options "rw,relatime,user_subvol_rm_allowed" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-btrfs-pool-config" fi # Create dir pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5" dir + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool5" dir - # Check that we cannot create storage pools inside of ${LXD_DIR} other than ${LXD_DIR}/storage-pools/{pool_name}. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" dir source="${LXD_DIR}" || false + # Check that we cannot create storage pools inside of ${INCUS_DIR} other than ${INCUS_DIR}/storage-pools/{pool_name}. + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-pool5_under_incus_dir" dir source="${INCUS_DIR}" || false - # Check that we can create storage pools inside of ${LXD_DIR}/storage-pools/{pool_name}. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" dir source="${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" + # Check that we can create storage pools inside of ${INCUS_DIR}/storage-pools/{pool_name}. + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool5_under_incus_dir" dir source="${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool5_under_incus_dir" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool5_under_incus_dir" # Test that no invalid dir storage pool configuration keys can be set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.thinpool_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.use_thinpool=false || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.vg_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir size=1GiB || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.block.filesystem=ext4 || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.block.mount_options=discard || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.zfs.remove_snapshots=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.zfs.use_refquota=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir zfs.clone_copy=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir zfs.pool_name=bla || false - - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-dir-pool-config" dir rsync.bwlimit=1024 - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-dir-pool-config" - - if [ "$lxd_backend" = "lvm" ]; then + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir lvm.thinpool_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir lvm.use_thinpool=false || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir lvm.vg_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir size=1GiB || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir volume.block.filesystem=ext4 || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir volume.block.mount_options=discard || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir volume.zfs.remove_snapshots=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir volume.zfs.use_refquota=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir zfs.clone_copy=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-dir-pool-config" dir zfs.pool_name=bla || false + + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-dir-pool-config" dir rsync.bwlimit=1024 + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-dir-pool-config" + + if [ "$incus_backend" = "lvm" ]; then # Create lvm pool. configure_loop_device loop_file_3 loop_device_3 # shellcheck disable=SC2154 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm source="${loop_device_3}" volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool6" lvm source="${loop_device_3}" volume.size=25MiB configure_loop_device loop_file_5 loop_device_5 # shellcheck disable=SC2154 # Should fail if vg does not exist, since we have no way of knowing where # to create the vg without a block device path set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool10" lvm source=test_vg_1 volume.size=25MiB || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-pool10" lvm source=test_vg_1 volume.size=25MiB || false # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_5}" "${loop_device_5}" configure_loop_device loop_file_6 loop_device_6 # shellcheck disable=SC2154 pvcreate "${loop_device_6}" - vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" "${loop_device_6}" + vgcreate "incustest-$(basename "${INCUS_DIR}")-pool11-test_vg_2" "${loop_device_6}" # Reuse existing volume group "test_vg_2" on existing physical volume. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool11" lvm source="lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool11" lvm source="incustest-$(basename "${INCUS_DIR}")-pool11-test_vg_2" volume.size=25MiB configure_loop_device loop_file_7 loop_device_7 # shellcheck disable=SC2154 pvcreate "${loop_device_7}" - vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" "${loop_device_7}" + vgcreate "incustest-$(basename "${INCUS_DIR}")-pool12-test_vg_3" "${loop_device_7}" # Reuse existing volume group "test_vg_3" on existing physical volume. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool12" lvm source="lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool12" lvm source="incustest-$(basename "${INCUS_DIR}")-pool12-test_vg_3" volume.size=25MiB configure_loop_device loop_file_8 loop_device_8 # shellcheck disable=SC2154 # Create new volume group "test_vg_4". - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool13" lvm source="${loop_device_8}" lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-pool13-test_vg_4" volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool13" lvm source="${loop_device_8}" lvm.vg_name="incustest-$(basename "${INCUS_DIR}")-pool13-test_vg_4" volume.size=25MiB - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool14" lvm volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool14" lvm volume.size=25MiB - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" lvm lvm.use_thinpool=false volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" lvm lvm.use_thinpool=false volume.size=25MiB # Test that no invalid lvm storage pool configuration keys can be set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm volume.zfs.remove_snapshots=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm volume.zfs_use_refquota=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm zfs.clone_copy=true || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm zfs.pool_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm lvm.use_thinpool=false lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" lvm volume.zfs.remove_snapshots=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" lvm volume.zfs_use_refquota=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" lvm zfs.clone_copy=true || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" lvm zfs.pool_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" lvm lvm.use_thinpool=false lvm.thinpool_name="incustest-$(basename "${INCUS_DIR}")-invalid-lvm-pool-config" || false # Test that all valid lvm storage pool configuration keys can be set. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool16" lvm lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool17" lvm lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool18" lvm size=1GiB - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool19" lvm volume.block.filesystem=ext4 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool20" lvm volume.block.mount_options=discard - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool21" lvm volume.size=25MiB - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool22" lvm lvm.use_thinpool=true - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool23" lvm lvm.use_thinpool=true lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool24" lvm rsync.bwlimit=1024 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25" lvm volume.block.mount_options="rw,strictatime,discard" - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25" volume.block.mount_options "rw,lazytime" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool26" lvm volume.block.filesystem=btrfs + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool16" lvm lvm.thinpool_name="incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool17" lvm lvm.vg_name="incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool18" lvm size=1GiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool19" lvm volume.block.filesystem=ext4 + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool20" lvm volume.block.mount_options=discard + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool21" lvm volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool22" lvm lvm.use_thinpool=true + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool23" lvm lvm.use_thinpool=true lvm.thinpool_name="incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool24" lvm rsync.bwlimit=1024 + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool25" lvm volume.block.mount_options="rw,strictatime,discard" + inc storage set "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool25" volume.block.mount_options "rw,lazytime" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool26" lvm volume.block.filesystem=btrfs fi # Set default storage pool for image import. - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool5" + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool5" # Import image into default storage pool. ensure_import_testimage # Muck around with some containers on various pools. - if [ "$lxd_backend" = "zfs" ]; then - lxc init testimage c1pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc list -c b c1pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1" - - lxc init testimage c2pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc list -c b c2pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2" - - lxc launch testimage c3pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc list -c b c3pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1" - - lxc launch testimage c4pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc list -c b c4pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2" - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 zfs.use_refquota true - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2-renamed - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2-renamed c4pool2 + if [ "$incus_backend" = "zfs" ]; then + inc init testimage c1pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc list -c b c1pool1 | grep "incustest-$(basename "${INCUS_DIR}")-pool1" + + inc init testimage c2pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc list -c b c2pool2 | grep "incustest-$(basename "${INCUS_DIR}")-pool2" + + inc launch testimage c3pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc list -c b c3pool1 | grep "incustest-$(basename "${INCUS_DIR}")-pool1" + + inc launch testimage c4pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc list -c b c4pool2 | grep "incustest-$(basename "${INCUS_DIR}")-pool2" + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 zfs.use_refquota true + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2-renamed + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2-renamed c4pool2 fi - if [ "$lxd_backend" = "btrfs" ]; then - lxc init testimage c5pool3 -s "lxdtest-$(basename "${LXD_DIR}")-pool3" - lxc list -c b c5pool3 | grep "lxdtest-$(basename "${LXD_DIR}")-pool3" - lxc init testimage c6pool4 -s "lxdtest-$(basename "${LXD_DIR}")-pool4" - lxc list -c b c6pool4 | grep "lxdtest-$(basename "${LXD_DIR}")-pool4" - - lxc launch testimage c7pool3 -s "lxdtest-$(basename "${LXD_DIR}")-pool3" - lxc list -c b c7pool3 | grep "lxdtest-$(basename "${LXD_DIR}")-pool3" - lxc launch testimage c8pool4 -s "lxdtest-$(basename "${LXD_DIR}")-pool4" - lxc list -c b c8pool4 | grep "lxdtest-$(basename "${LXD_DIR}")-pool4" - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4-renamed - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4-renamed c8pool4 + if [ "$incus_backend" = "btrfs" ]; then + inc init testimage c5pool3 -s "incustest-$(basename "${INCUS_DIR}")-pool3" + inc list -c b c5pool3 | grep "incustest-$(basename "${INCUS_DIR}")-pool3" + inc init testimage c6pool4 -s "incustest-$(basename "${INCUS_DIR}")-pool4" + inc list -c b c6pool4 | grep "incustest-$(basename "${INCUS_DIR}")-pool4" + + inc launch testimage c7pool3 -s "incustest-$(basename "${INCUS_DIR}")-pool3" + inc list -c b c7pool3 | grep "incustest-$(basename "${INCUS_DIR}")-pool3" + inc launch testimage c8pool4 -s "incustest-$(basename "${INCUS_DIR}")-pool4" + inc list -c b c8pool4 | grep "incustest-$(basename "${INCUS_DIR}")-pool4" + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 c5pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 c5pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 c5pool3 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 c5pool3 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 c5pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 c5pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 c5pool3 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 c5pool3 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 c7pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 c7pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 c7pool3 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 c7pool3 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 c8pool4 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 c8pool4 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 c8pool4 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 c8pool4 testDevice + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 c8pool4-renamed + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4-renamed c8pool4 fi - lxc init testimage c9pool5 -s "lxdtest-$(basename "${LXD_DIR}")-pool5" - lxc list -c b c9pool5 | grep "lxdtest-$(basename "${LXD_DIR}")-pool5" - - lxc launch testimage c11pool5 -s "lxdtest-$(basename "${LXD_DIR}")-pool5" - lxc list -c b c11pool5 | grep "lxdtest-$(basename "${LXD_DIR}")-pool5" - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5-renamed - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5-renamed c11pool5 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5 + inc init testimage c9pool5 -s "incustest-$(basename "${INCUS_DIR}")-pool5" + inc list -c b c9pool5 | grep "incustest-$(basename "${INCUS_DIR}")-pool5" + + inc launch testimage c11pool5 -s "incustest-$(basename "${INCUS_DIR}")-pool5" + inc list -c b c11pool5 | grep "incustest-$(basename "${INCUS_DIR}")-pool5" + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 c9pool5 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 c9pool5 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 c9pool5 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 c9pool5 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 c11pool5 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 c11pool5 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 c11pool5 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 c11pool5 testDevice + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 c11pool5-renamed + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5-renamed c11pool5 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5 # should create snap0 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5 # should create snap1 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5 - if [ "$lxd_backend" = "lvm" ]; then - lxc init testimage c10pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6" - lxc list -c b c10pool6 | grep "lxdtest-$(basename "${LXD_DIR}")-pool6" + if [ "$incus_backend" = "lvm" ]; then + inc init testimage c10pool6 -s "incustest-$(basename "${INCUS_DIR}")-pool6" + inc list -c b c10pool6 | grep "incustest-$(basename "${INCUS_DIR}")-pool6" # Test if volume group renaming works by setting lvm.vg_name. - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm.vg_name "lxdtest-$(basename "${LXD_DIR}")-pool6-newName" + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool6" lvm.vg_name "incustest-$(basename "${INCUS_DIR}")-pool6-newName" - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm.thinpool_name "lxdtest-$(basename "${LXD_DIR}")-pool6-newThinpoolName" + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool6" lvm.thinpool_name "incustest-$(basename "${INCUS_DIR}")-pool6-newThinpoolName" - lxc launch testimage c12pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6" - lxc list -c b c12pool6 | grep "lxdtest-$(basename "${LXD_DIR}")-pool6" + inc launch testimage c12pool6 -s "incustest-$(basename "${INCUS_DIR}")-pool6" + inc list -c b c12pool6 | grep "incustest-$(basename "${INCUS_DIR}")-pool6" # grow lv - lxc config device set c12pool6 root size 30MiB - lxc restart c12pool6 --force + inc config device set c12pool6 root size 30MiB + inc restart c12pool6 --force # shrink lv - lxc config device set c12pool6 root size 25MiB - lxc restart c12pool6 --force + inc config device set c12pool6 root size 25MiB + inc restart c12pool6 --force - lxc init testimage c10pool11 -s "lxdtest-$(basename "${LXD_DIR}")-pool11" - lxc list -c b c10pool11 | grep "lxdtest-$(basename "${LXD_DIR}")-pool11" + inc init testimage c10pool11 -s "incustest-$(basename "${INCUS_DIR}")-pool11" + inc list -c b c10pool11 | grep "incustest-$(basename "${INCUS_DIR}")-pool11" - lxc launch testimage c12pool11 -s "lxdtest-$(basename "${LXD_DIR}")-pool11" - lxc list -c b c12pool11 | grep "lxdtest-$(basename "${LXD_DIR}")-pool11" + inc launch testimage c12pool11 -s "incustest-$(basename "${INCUS_DIR}")-pool11" + inc list -c b c12pool11 | grep "incustest-$(basename "${INCUS_DIR}")-pool11" - lxc init testimage c10pool12 -s "lxdtest-$(basename "${LXD_DIR}")-pool12" - lxc list -c b c10pool12 | grep "lxdtest-$(basename "${LXD_DIR}")-pool12" + inc init testimage c10pool12 -s "incustest-$(basename "${INCUS_DIR}")-pool12" + inc list -c b c10pool12 | grep "incustest-$(basename "${INCUS_DIR}")-pool12" - lxc launch testimage c12pool12 -s "lxdtest-$(basename "${LXD_DIR}")-pool12" - lxc list -c b c12pool12 | grep "lxdtest-$(basename "${LXD_DIR}")-pool12" + inc launch testimage c12pool12 -s "incustest-$(basename "${INCUS_DIR}")-pool12" + inc list -c b c12pool12 | grep "incustest-$(basename "${INCUS_DIR}")-pool12" - lxc init testimage c10pool13 -s "lxdtest-$(basename "${LXD_DIR}")-pool13" - lxc list -c b c10pool13 | grep "lxdtest-$(basename "${LXD_DIR}")-pool13" + inc init testimage c10pool13 -s "incustest-$(basename "${INCUS_DIR}")-pool13" + inc list -c b c10pool13 | grep "incustest-$(basename "${INCUS_DIR}")-pool13" - lxc launch testimage c12pool13 -s "lxdtest-$(basename "${LXD_DIR}")-pool13" - lxc list -c b c12pool13 | grep "lxdtest-$(basename "${LXD_DIR}")-pool13" + inc launch testimage c12pool13 -s "incustest-$(basename "${INCUS_DIR}")-pool13" + inc list -c b c12pool13 | grep "incustest-$(basename "${INCUS_DIR}")-pool13" - lxc init testimage c10pool14 -s "lxdtest-$(basename "${LXD_DIR}")-pool14" - lxc list -c b c10pool14 | grep "lxdtest-$(basename "${LXD_DIR}")-pool14" + inc init testimage c10pool14 -s "incustest-$(basename "${INCUS_DIR}")-pool14" + inc list -c b c10pool14 | grep "incustest-$(basename "${INCUS_DIR}")-pool14" - lxc launch testimage c12pool14 -s "lxdtest-$(basename "${LXD_DIR}")-pool14" - lxc list -c b c12pool14 | grep "lxdtest-$(basename "${LXD_DIR}")-pool14" + inc launch testimage c12pool14 -s "incustest-$(basename "${INCUS_DIR}")-pool14" + inc list -c b c12pool14 | grep "incustest-$(basename "${INCUS_DIR}")-pool14" - lxc init testimage c10pool15 -s "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" - lxc list -c b c10pool15 | grep "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" + inc init testimage c10pool15 -s "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" + inc list -c b c10pool15 | grep "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" - lxc launch testimage c12pool15 -s "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" - lxc list -c b c12pool15 | grep "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" + inc launch testimage c12pool15 -s "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" + inc list -c b c12pool15 | grep "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" # Test that changing block filesystem works - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.block.filesystem xfs - lxc init testimage c1pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6" - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.block.filesystem btrfs - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.size 120MiB - lxc init testimage c2pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6" - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool6" volume.block.filesystem xfs + inc init testimage c1pool6 -s "incustest-$(basename "${INCUS_DIR}")-pool6" + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool6" volume.block.filesystem btrfs + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool6" volume.size 120MiB + inc init testimage c2pool6 -s "incustest-$(basename "${INCUS_DIR}")-pool6" + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 c10pool6 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 c10pool6 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 c10pool6 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 c10pool6 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 c12pool6 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 c12pool6 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 c12pool6 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 c12pool6 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 c10pool11 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 c10pool11 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 c10pool11 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 c10pool11 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 c10pool11 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 c10pool11 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 c10pool11 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 c10pool11 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 c10pool12 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 c10pool12 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 c10pool12 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 c10pool12 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 c12pool12 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 c12pool12 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 c12pool12 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 c12pool12 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 c10pool13 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 c10pool13 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 c10pool13 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 c10pool13 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 c12pool13 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 c12pool13 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 c12pool13 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 c12pool13 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 c10pool14 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 c10pool14 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 c10pool14 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 c10pool14 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 c12pool14 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 c12pool14 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 c12pool14 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 c12pool14 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice fi - if [ "$lxd_backend" = "zfs" ]; then - lxc launch testimage c13pool7 -s "lxdtest-$(basename "${LXD_DIR}")-pool7" - lxc launch testimage c14pool7 -s "lxdtest-$(basename "${LXD_DIR}")-pool7" - - lxc launch testimage c15pool8 -s "lxdtest-$(basename "${LXD_DIR}")-pool8" - lxc launch testimage c16pool8 -s "lxdtest-$(basename "${LXD_DIR}")-pool8" - - lxc launch testimage c17pool9 -s "lxdtest-$(basename "${LXD_DIR}")-pool9" - lxc launch testimage c18pool9 -s "lxdtest-$(basename "${LXD_DIR}")-pool9" - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9-renamed - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9-renamed c18pool9 + if [ "$incus_backend" = "zfs" ]; then + inc launch testimage c13pool7 -s "incustest-$(basename "${INCUS_DIR}")-pool7" + inc launch testimage c14pool7 -s "incustest-$(basename "${INCUS_DIR}")-pool7" + + inc launch testimage c15pool8 -s "incustest-$(basename "${INCUS_DIR}")-pool8" + inc launch testimage c16pool8 -s "incustest-$(basename "${INCUS_DIR}")-pool8" + + inc launch testimage c17pool9 -s "incustest-$(basename "${INCUS_DIR}")-pool9" + inc launch testimage c18pool9 -s "incustest-$(basename "${INCUS_DIR}")-pool9" + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 c13pool7 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 c13pool7 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 c13pool7 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 c13pool7 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 c14pool7 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 c14pool7 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 c14pool7 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 c14pool7 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 c15pool8 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 c15pool8 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 c15pool8 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 c15pool8 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 c16pool8 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 c16pool8 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 c16pool8 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 c16pool8 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 c17pool9 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 c17pool9 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 c17pool9 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 c17pool9 testDevice + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 c18pool9 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 c18pool9 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 c18pool9 testDevice + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 c18pool9 testDevice + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 c18pool9-renamed + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9-renamed c18pool9 fi - if [ "$lxd_backend" = "zfs" ]; then - lxc delete -f c1pool1 - lxc delete -f c3pool1 + if [ "$incus_backend" = "zfs" ]; then + inc delete -f c1pool1 + inc delete -f c3pool1 - lxc delete -f c4pool2 - lxc delete -f c2pool2 + inc delete -f c4pool2 + inc delete -f c2pool2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 fi - if [ "$lxd_backend" = "btrfs" ]; then - lxc delete -f c5pool3 - lxc delete -f c7pool3 + if [ "$incus_backend" = "btrfs" ]; then + inc delete -f c5pool3 + inc delete -f c7pool3 - lxc delete -f c8pool4 - lxc delete -f c6pool4 + inc delete -f c8pool4 + inc delete -f c6pool4 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool3" c5pool3 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool4" c6pool4 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool3" c7pool3 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool4" c8pool4 fi - lxc delete -f c9pool5 - lxc delete -f c11pool5 - - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5 - - if [ "$lxd_backend" = "lvm" ]; then - lxc delete -f c1pool6 - lxc delete -f c2pool6 - lxc delete -f c10pool6 - lxc delete -f c12pool6 - - lxc delete -f c10pool11 - lxc delete -f c12pool11 - - lxc delete -f c10pool12 - lxc delete -f c12pool12 - - lxc delete -f c10pool13 - lxc delete -f c12pool13 - - lxc delete -f c10pool14 - lxc delete -f c12pool14 - - lxc delete -f c10pool15 - lxc delete -f c12pool15 - - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 + inc delete -f c9pool5 + inc delete -f c11pool5 + + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool5" c9pool5 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool5" c11pool5 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5 + + if [ "$incus_backend" = "lvm" ]; then + inc delete -f c1pool6 + inc delete -f c2pool6 + inc delete -f c10pool6 + inc delete -f c12pool6 + + inc delete -f c10pool11 + inc delete -f c12pool11 + + inc delete -f c10pool12 + inc delete -f c12pool12 + + inc delete -f c10pool13 + inc delete -f c12pool13 + + inc delete -f c10pool14 + inc delete -f c12pool14 + + inc delete -f c10pool15 + inc delete -f c12pool15 + + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool6" c10pool6 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool6" c12pool6 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool11" c10pool11 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool11" c12pool11 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool12" c10pool12 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool12" c12pool12 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool13" c10pool13 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool13" c12pool13 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool14" c10pool14 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool14" c12pool14 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c10pool15 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" c12pool15 fi - if [ "$lxd_backend" = "zfs" ]; then - lxc delete -f c13pool7 - lxc delete -f c14pool7 + if [ "$incus_backend" = "zfs" ]; then + inc delete -f c13pool7 + inc delete -f c14pool7 - lxc delete -f c15pool8 - lxc delete -f c16pool8 + inc delete -f c15pool8 + inc delete -f c16pool8 - lxc delete -f c17pool9 - lxc delete -f c18pool9 + inc delete -f c17pool9 + inc delete -f c18pool9 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool7" c13pool7 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool7" c14pool7 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool8" c15pool8 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool8" c16pool8 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool9" c17pool9 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool9" c18pool9 fi - lxc image delete testimage + inc image delete testimage - if [ "$lxd_backend" = "zfs" ]; then - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool7" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool8" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool9" + if [ "$incus_backend" = "zfs" ]; then + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool7" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool8" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool9" # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_4}" "${loop_device_4}" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool1" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool2" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool2" # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_1}" "${loop_device_1}" fi - if [ "$lxd_backend" = "btrfs" ]; then - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool4" + if [ "$incus_backend" = "btrfs" ]; then + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool4" # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_2}" "${loop_device_2}" fi - if [ "$lxd_backend" = "lvm" ]; then - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool6" + if [ "$incus_backend" = "lvm" ]; then + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool6" # shellcheck disable=SC2154 pvremove -ff "${loop_device_3}" || true # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_3}" "${loop_device_3}" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool11" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool11" # shellcheck disable=SC2154 - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" || true + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-pool11-test_vg_2" || true pvremove -ff "${loop_device_6}" || true # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_6}" "${loop_device_6}" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool12" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool12" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-pool12-test_vg_3" || true pvremove -ff "${loop_device_7}" || true # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_7}" "${loop_device_7}" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool13" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool13-test_vg_4" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool13" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-pool13-test_vg_4" || true pvremove -ff "${loop_device_8}" || true # shellcheck disable=SC2154 deconfigure_loop_device "${loop_file_8}" "${loop_device_8}" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool14" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool14" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool14" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-pool14" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool15" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool16" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool16" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool16" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool16" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool17" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool17" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool17" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool17" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool18" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool18" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool18" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool18" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool19" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool19" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool19" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool19" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool20" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool20" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool20" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool20" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool21" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool21" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool21" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool21" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool22" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool22" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool22" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool22" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool23" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool23" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool23" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool23" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool24" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool24" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool24" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool24" || true - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25" - vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool25" || true + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-lvm-pool-config-pool25" + vgremove -ff "incustest-$(basename "${INCUS_DIR}")-non-thinpool-pool25" || true fi ) @@ -768,134 +768,134 @@ test_storage() { rootMinKiB2="18900" rootMaxKiB2="28000" - if [ "$lxd_backend" != "dir" ]; then - lxc launch testimage quota1 - rootOrigSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') + if [ "$incus_backend" != "dir" ]; then + inc launch testimage quota1 + rootOrigSizeKiB=$(inc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') rootOrigMinSizeKiB=$((rootOrigSizeKiB-2000)) rootOrigMaxSizeKiB=$((rootOrigSizeKiB+2000)) - lxc profile device set default root size "${QUOTA1}" - lxc stop -f quota1 - lxc start quota1 + inc profile device set default root size "${QUOTA1}" + inc stop -f quota1 + inc start quota1 # BTRFS quota isn't accessible with the df tool. - if [ "$lxd_backend" != "btrfs" ]; then - rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') + if [ "$incus_backend" != "btrfs" ]; then + rootSizeKiB=$(inc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') if [ "$rootSizeKiB" -gt "$rootMaxKiB1" ] || [ "$rootSizeKiB" -lt "$rootMinKiB1" ] ; then echo "root size not within quota range" false fi fi - lxc launch testimage quota2 - lxc stop -f quota2 - lxc start quota2 + inc launch testimage quota2 + inc stop -f quota2 + inc start quota2 - lxc init testimage quota3 - lxc start quota3 + inc init testimage quota3 + inc start quota3 - lxc profile device set default root size "${QUOTA2}" + inc profile device set default root size "${QUOTA2}" - lxc stop -f quota1 - lxc start quota1 + inc stop -f quota1 + inc start quota1 - lxc stop -f quota2 - lxc start quota2 - if [ "$lxd_backend" != "btrfs" ]; then - rootSizeKiB=$(lxc exec quota2 -- df -P / | tail -n1 | awk '{print $2}') + inc stop -f quota2 + inc start quota2 + if [ "$incus_backend" != "btrfs" ]; then + rootSizeKiB=$(inc exec quota2 -- df -P / | tail -n1 | awk '{print $2}') if [ "$rootSizeKiB" -gt "$rootMaxKiB2" ] || [ "$rootSizeKiB" -lt "$rootMinKiB2" ] ; then echo "root size not within quota range" false fi fi - lxc stop -f quota3 - lxc start quota3 + inc stop -f quota3 + inc start quota3 - lxc profile device unset default root size + inc profile device unset default root size # Only ZFS supports hot quota changes (LVM requires a reboot). - if [ "$lxd_backend" = "zfs" ]; then - rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') + if [ "$incus_backend" = "zfs" ]; then + rootSizeKiB=$(inc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') if [ "$rootSizeKiB" -gt "$rootOrigMaxSizeKiB" ] || [ "$rootSizeKiB" -lt "$rootOrigMinSizeKiB" ] ; then echo "original root size not restored" false fi fi - lxc stop -f quota1 - lxc start quota1 - if [ "$lxd_backend" = "zfs" ]; then - rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') + inc stop -f quota1 + inc start quota1 + if [ "$incus_backend" = "zfs" ]; then + rootSizeKiB=$(inc exec quota1 -- df -P / | tail -n1 | awk '{print $2}') if [ "$rootSizeKiB" -gt "$rootOrigMaxSizeKiB" ] || [ "$rootSizeKiB" -lt "$rootOrigMinSizeKiB" ] ; then echo "original root size not restored" false fi fi - lxc stop -f quota2 - lxc start quota2 + inc stop -f quota2 + inc start quota2 - lxc stop -f quota3 - lxc start quota3 + inc stop -f quota3 + inc start quota3 - lxc delete -f quota1 - lxc delete -f quota2 - lxc delete -f quota3 + inc delete -f quota1 + inc delete -f quota2 + inc delete -f quota3 fi - if [ "${lxd_backend}" = "btrfs" ]; then + if [ "${incus_backend}" = "btrfs" ]; then # shellcheck disable=SC2031 - pool_name="lxdtest-$(basename "${LXD_DIR}")-quota" + pool_name="incustest-$(basename "${INCUS_DIR}")-quota" # shellcheck disable=SC1009 - lxc storage create "${pool_name}" btrfs + inc storage create "${pool_name}" btrfs # Import image into default storage pool. ensure_import_testimage # Launch container. - lxc launch -s "${pool_name}" testimage c1 + inc launch -s "${pool_name}" testimage c1 # Disable quotas. The usage should be 0. # shellcheck disable=SC2031 - btrfs quota disable "${LXD_DIR}/storage-pools/${pool_name}" - usage=$(lxc query /1.0/instances/c1/state | jq '.disk.root') + btrfs quota disable "${INCUS_DIR}/storage-pools/${pool_name}" + usage=$(inc query /1.0/instances/c1/state | jq '.disk.root') [ "${usage}" = "null" ] # Enable quotas. The usage should then be > 0. # shellcheck disable=SC2031 - btrfs quota enable "${LXD_DIR}/storage-pools/${pool_name}" - usage=$(lxc query /1.0/instances/c1/state | jq '.disk.root.usage') + btrfs quota enable "${INCUS_DIR}/storage-pools/${pool_name}" + usage=$(inc query /1.0/instances/c1/state | jq '.disk.root.usage') [ "${usage}" -gt 0 ] # Clean up everything. - lxc rm -f c1 - lxc storage delete "${pool_name}" + inc rm -f c1 + inc storage delete "${pool_name}" fi # Test removing storage pools only containing image volumes # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool26" - lxc storage create "$storage_pool" "$lxd_backend" - lxc init -s "${storage_pool}" testimage c1 + INCUS_DIR="${INCUS_DIR}" + storage_pool="incustest-$(basename "${INCUS_DIR}")-pool26" + inc storage create "$storage_pool" "$incus_backend" + inc init -s "${storage_pool}" testimage c1 # The storage pool will not be removed since it has c1 attached to it - ! lxc storage delete "${storage_pool}" || false - lxc delete c1 + ! inc storage delete "${storage_pool}" || false + inc delete c1 # The storage pool will be deleted since the testimage is also attached to # the default pool - lxc storage delete "${storage_pool}" - lxc image show testimage + inc storage delete "${storage_pool}" + inc image show testimage # Test storage pool resize - if [ "${lxd_backend}" = "btrfs" ] || [ "${lxd_backend}" = "lvm" ] || [ "${lxd_backend}" = "zfs" ]; then + if [ "${incus_backend}" = "btrfs" ] || [ "${incus_backend}" = "lvm" ] || [ "${incus_backend}" = "zfs" ]; then # shellcheck disable=SC1009 - pool_name="lxdtest-$(basename "${LXD_DIR}")-pool1" + pool_name="incustest-$(basename "${INCUS_DIR}")-pool1" - lxc storage create "${pool_name}" "${lxd_backend}" size=1GiB + inc storage create "${pool_name}" "${incus_backend}" size=1GiB - lxc launch testimage c1 -s "${pool_name}" + inc launch testimage c1 -s "${pool_name}" expected_size=1073741824 # +/- 5% of the expected size @@ -903,13 +903,13 @@ test_storage() { expected_size_max=1127428916 # Check pool file size - [ "$(stat --format="%s" "${LXD_DIR}/disks/${pool_name}.img")" = "${expected_size}" ] + [ "$(stat --format="%s" "${INCUS_DIR}/disks/${pool_name}.img")" = "${expected_size}" ] - if [ "${lxd_backend}" = "btrfs" ]; then - actual_size="$(btrfs filesystem show --raw "${LXD_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')" - elif [ "${lxd_backend}" = "lvm" ]; then - actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "lxdtest-$(basename "${LXD_DIR}")/LXDThinPool")" - elif [ "${lxd_backend}" = "zfs" ]; then + if [ "${incus_backend}" = "btrfs" ]; then + actual_size="$(btrfs filesystem show --raw "${INCUS_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')" + elif [ "${incus_backend}" = "lvm" ]; then + actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "incustest-$(basename "${INCUS_DIR}")/IncusThinPool")" + elif [ "${incus_backend}" = "zfs" ]; then actual_size="$(zpool list -Hp "${pool_name}" | awk '{print $2}')" fi @@ -917,7 +917,7 @@ test_storage() { [ "${actual_size}" -ge "${expected_size_min}" ] || [ "${actual_size}" -le "${expected_size_max}" ] # Grow pool - lxc storage set "${pool_name}" size=2GiB + inc storage set "${pool_name}" size=2GiB expected_size=2147483648 # +/- 5% of the expected size @@ -925,13 +925,13 @@ test_storage() { expected_size_max=2254857831 # Check pool file size - [ "$(stat --format="%s" "${LXD_DIR}/disks/${pool_name}.img")" = "${expected_size}" ] + [ "$(stat --format="%s" "${INCUS_DIR}/disks/${pool_name}.img")" = "${expected_size}" ] - if [ "${lxd_backend}" = "btrfs" ]; then - actual_size="$(btrfs filesystem show --raw "${LXD_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')" - elif [ "${lxd_backend}" = "lvm" ]; then - actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "lxdtest-$(basename "${LXD_DIR}")/LXDThinPool")" - elif [ "${lxd_backend}" = "zfs" ]; then + if [ "${incus_backend}" = "btrfs" ]; then + actual_size="$(btrfs filesystem show --raw "${INCUS_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')" + elif [ "${incus_backend}" = "lvm" ]; then + actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "incustest-$(basename "${INCUS_DIR}")/IncusThinPool")" + elif [ "${incus_backend}" = "zfs" ]; then actual_size="$(zpool list -Hp "${pool_name}" | awk '{print $2}')" fi @@ -939,16 +939,16 @@ test_storage() { [ "${actual_size}" -ge "${expected_size_min}" ] || [ "${actual_size}" -le "${expected_size_max}" ] # Shrinking the pool should fail - ! lxc storage set "${pool_name}" size=1GiB || false + ! inc storage set "${pool_name}" size=1GiB || false # Ensure the pool is still usable after resizing by launching an instance - lxc launch testimage c2 -s "${pool_name}" + inc launch testimage c2 -s "${pool_name}" - lxc rm -f c1 c2 - lxc storage rm "${pool_name}" + inc rm -f c1 c2 + inc storage rm "${pool_name}" fi # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - kill_lxd "${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_buckets.sh b/test/suites/storage_buckets.sh index 9d8ff9a6a32..6281e5ad97f 100644 --- a/test/suites/storage_buckets.sh +++ b/test/suites/storage_buckets.sh @@ -28,14 +28,14 @@ s3cmdrun () { test_storage_buckets() { # shellcheck disable=2039,3043 - local lxd_backend + local incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") + incus_backend=$(storage_backend "$INCUS_DIR") - if [ "$lxd_backend" = "ceph" ]; then - if [ -z "${LXD_CEPH_CEPHOBJECT_RADOSGW:-}" ]; then - # Check LXD_CEPH_CEPHOBJECT_RADOSGW specified for ceph bucket tests. - export TEST_UNMET_REQUIREMENT="LXD_CEPH_CEPHOBJECT_RADOSGW not specified" + if [ "$incus_backend" = "ceph" ]; then + if [ -z "${INCUS_CEPH_CEPHOBJECT_RADOSGW:-}" ]; then + # Check INCUS_CEPH_CEPHOBJECT_RADOSGW specified for ceph bucket tests. + export TEST_UNMET_REQUIREMENT="INCUS_CEPH_CEPHOBJECT_RADOSGW not specified" return fi elif ! command -v minio ; then @@ -44,19 +44,19 @@ test_storage_buckets() { return fi - poolName=$(lxc profile device get default root pool) - bucketPrefix="lxd$$" + poolName=$(inc profile device get default root pool) + bucketPrefix="inc$$" # Check cephobject.radosgw.endpoint is required for cephobject pools. - if [ "$lxd_backend" = "ceph" ]; then - ! lxc storage create s3 cephobject || false - lxc storage create s3 cephobject cephobject.radosgw.endpoint="${LXD_CEPH_CEPHOBJECT_RADOSGW}" - lxc storage show s3 + if [ "$incus_backend" = "ceph" ]; then + ! inc storage create s3 cephobject || false + inc storage create s3 cephobject cephobject.radosgw.endpoint="${INCUS_CEPH_CEPHOBJECT_RADOSGW}" + inc storage show s3 poolName="s3" - s3Endpoint="${LXD_CEPH_CEPHOBJECT_RADOSGW}" + s3Endpoint="${INCUS_CEPH_CEPHOBJECT_RADOSGW}" else # Create a loop device for dir pools as MinIO doesn't support running on tmpfs (which the test suite can do). - if [ "$lxd_backend" = "dir" ]; then + if [ "$incus_backend" = "dir" ]; then configure_loop_device loop_file_1 loop_device_1 # shellcheck disable=SC2154 mkfs.ext4 "${loop_device_1}" @@ -64,129 +64,129 @@ test_storage_buckets() { mount "${loop_device_1}" "${TEST_DIR}/${bucketPrefix}" losetup -d "${loop_device_1}" mkdir "${TEST_DIR}/${bucketPrefix}/s3" - lxc storage create s3 dir source="${TEST_DIR}/${bucketPrefix}/s3" + inc storage create s3 dir source="${TEST_DIR}/${bucketPrefix}/s3" poolName="s3" fi buckets_addr="127.0.0.1:$(local_tcp_port)" - lxc config set core.storage_buckets_address "${buckets_addr}" + inc config set core.storage_buckets_address "${buckets_addr}" s3Endpoint="https://${buckets_addr}" fi # Check bucket name validation. - ! lxc storage bucket create "${poolName}" .foo || false - ! lxc storage bucket create "${poolName}" fo || false - ! lxc storage bucket create "${poolName}" fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo || false - ! lxc storage bucket create "${poolName}" "foo bar" || false + ! inc storage bucket create "${poolName}" .foo || false + ! inc storage bucket create "${poolName}" fo || false + ! inc storage bucket create "${poolName}" fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo || false + ! inc storage bucket create "${poolName}" "foo bar" || false # Create bucket. - initCreds=$(lxc storage bucket create "${poolName}" "${bucketPrefix}.foo" user.foo=comment) + initCreds=$(inc storage bucket create "${poolName}" "${bucketPrefix}.foo" user.foo=comment) initAccessKey=$(echo "${initCreds}" | awk '{ if ($2 == "access" && $3 == "key:") {print $4}}') initSecretKey=$(echo "${initCreds}" | awk '{ if ($2 == "secret" && $3 == "key:") {print $4}}') - s3cmdrun "${lxd_backend}" "${initAccessKey}" "${initSecretKey}" ls | grep -F "${bucketPrefix}.foo" + s3cmdrun "${incus_backend}" "${initAccessKey}" "${initSecretKey}" ls | grep -F "${bucketPrefix}.foo" - lxc storage bucket list "${poolName}" | grep -F "${bucketPrefix}.foo" - lxc storage bucket show "${poolName}" "${bucketPrefix}.foo" + inc storage bucket list "${poolName}" | grep -F "${bucketPrefix}.foo" + inc storage bucket show "${poolName}" "${bucketPrefix}.foo" # Create bucket keys. # Create admin key with randomly generated credentials. - creds=$(lxc storage bucket key create "${poolName}" "${bucketPrefix}.foo" admin-key --role=admin) + creds=$(inc storage bucket key create "${poolName}" "${bucketPrefix}.foo" admin-key --role=admin) adAccessKey=$(echo "${creds}" | awk '{ if ($1 == "Access" && $2 == "key:") {print $3}}') adSecretKey=$(echo "${creds}" | awk '{ if ($1 == "Secret" && $2 == "key:") {print $3}}') # Create read-only key with manually specified credentials. - creds=$(lxc storage bucket key create "${poolName}" "${bucketPrefix}.foo" ro-key --role=read-only --access-key="${bucketPrefix}.foo.ro" --secret-key="password") + creds=$(inc storage bucket key create "${poolName}" "${bucketPrefix}.foo" ro-key --role=read-only --access-key="${bucketPrefix}.foo.ro" --secret-key="password") roAccessKey=$(echo "${creds}" | awk '{ if ($1 == "Access" && $2 == "key:") {print $3}}') roSecretKey=$(echo "${creds}" | awk '{ if ($1 == "Secret" && $2 == "key:") {print $3}}') - lxc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "admin-key" - lxc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "ro-key" - lxc storage bucket key show "${poolName}" "${bucketPrefix}.foo" admin-key - lxc storage bucket key show "${poolName}" "${bucketPrefix}.foo" ro-key + inc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "admin-key" + inc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "ro-key" + inc storage bucket key show "${poolName}" "${bucketPrefix}.foo" admin-key + inc storage bucket key show "${poolName}" "${bucketPrefix}.foo" ro-key # Test listing buckets via S3. - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" ls | grep -F "${bucketPrefix}.foo" - s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" ls | grep -F "${bucketPrefix}.foo" + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" ls | grep -F "${bucketPrefix}.foo" + s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" ls | grep -F "${bucketPrefix}.foo" # Test making buckets via S3 is blocked. - ! s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" mb "s3://${bucketPrefix}.foo2" || false - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" mb "s3://${bucketPrefix}.foo2" || false + ! s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" mb "s3://${bucketPrefix}.foo2" || false + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" mb "s3://${bucketPrefix}.foo2" || false # Test putting a file into a bucket. - lxdTestFile="bucketfile_${bucketPrefix}.txt" - head -c 2M /dev/urandom > "${lxdTestFile}" - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" put "${lxdTestFile}" "s3://${bucketPrefix}.foo" - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" put "${lxdTestFile}" "s3://${bucketPrefix}.foo" || false + incusTestFile="bucketfile_${bucketPrefix}.txt" + head -c 2M /dev/urandom > "${incusTestFile}" + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" put "${incusTestFile}" "s3://${bucketPrefix}.foo" + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" put "${incusTestFile}" "s3://${bucketPrefix}.foo" || false # Test listing bucket files via S3. - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" ls "s3://${bucketPrefix}.foo" | grep -F "${lxdTestFile}" - s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" ls "s3://${bucketPrefix}.foo" | grep -F "${lxdTestFile}" + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" ls "s3://${bucketPrefix}.foo" | grep -F "${incusTestFile}" + s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" ls "s3://${bucketPrefix}.foo" | grep -F "${incusTestFile}" # Test getting a file from a bucket. - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" get "s3://${bucketPrefix}.foo/${lxdTestFile}" "${lxdTestFile}.get" - rm "${lxdTestFile}.get" - s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" get "s3://${bucketPrefix}.foo/${lxdTestFile}" "${lxdTestFile}.get" - rm "${lxdTestFile}.get" + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" get "s3://${bucketPrefix}.foo/${incusTestFile}" "${incusTestFile}.get" + rm "${incusTestFile}.get" + s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" get "s3://${bucketPrefix}.foo/${incusTestFile}" "${incusTestFile}.get" + rm "${incusTestFile}.get" # Test setting bucket policy to allow anonymous access (also tests bucket URL generation). - bucketURL=$(lxc storage bucket show "${poolName}" "${bucketPrefix}.foo" | awk '{if ($1 == "s3_url:") {print $2}}') + bucketURL=$(inc storage bucket show "${poolName}" "${bucketPrefix}.foo" | awk '{if ($1 == "s3_url:") {print $2}}') - curl -sI --insecure -o /dev/null -w "%{http_code}" "${bucketURL}/${lxdTestFile}" | grep -Fx "403" - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" setpolicy deps/s3_global_read_policy.json "s3://${bucketPrefix}.foo" || false - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" setpolicy deps/s3_global_read_policy.json "s3://${bucketPrefix}.foo" - curl -sI --insecure -o /dev/null -w "%{http_code}" "${bucketURL}/${lxdTestFile}" | grep -Fx "200" - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" delpolicy "s3://${bucketPrefix}.foo" || false - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" delpolicy "s3://${bucketPrefix}.foo" - curl -sI --insecure o /dev/null -w "%{http_code}" "${bucketURL}/${lxdTestFile}" | grep -Fx "403" + curl -sI --insecure -o /dev/null -w "%{http_code}" "${bucketURL}/${incusTestFile}" | grep -Fx "403" + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" setpolicy deps/s3_global_read_policy.json "s3://${bucketPrefix}.foo" || false + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" setpolicy deps/s3_global_read_policy.json "s3://${bucketPrefix}.foo" + curl -sI --insecure -o /dev/null -w "%{http_code}" "${bucketURL}/${incusTestFile}" | grep -Fx "200" + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" delpolicy "s3://${bucketPrefix}.foo" || false + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" delpolicy "s3://${bucketPrefix}.foo" + curl -sI --insecure o /dev/null -w "%{http_code}" "${bucketURL}/${incusTestFile}" | grep -Fx "403" # Test deleting a file from a bucket. - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" del "s3://${bucketPrefix}.foo/${lxdTestFile}" || false - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" del "s3://${bucketPrefix}.foo/${lxdTestFile}" + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" del "s3://${bucketPrefix}.foo/${incusTestFile}" || false + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" del "s3://${bucketPrefix}.foo/${incusTestFile}" # Test bucket quota (except dir driver which doesn't support quotas so check that its prevented). - if [ "$lxd_backend" = "dir" ]; then - ! lxc storage bucket create "${poolName}" "${bucketPrefix}.foo2" size=1MiB || false + if [ "$incus_backend" = "dir" ]; then + ! inc storage bucket create "${poolName}" "${bucketPrefix}.foo2" size=1MiB || false else - initCreds=$(lxc storage bucket create "${poolName}" "${bucketPrefix}.foo2" size=1MiB) + initCreds=$(inc storage bucket create "${poolName}" "${bucketPrefix}.foo2" size=1MiB) initAccessKey=$(echo "${initCreds}" | awk '{ if ($2 == "access" && $3 == "key:") {print $4}}') initSecretKey=$(echo "${initCreds}" | awk '{ if ($2 == "secret" && $3 == "key:") {print $4}}') - ! s3cmdrun "${lxd_backend}" "${initAccessKey}" "${initSecretKey}" put "${lxdTestFile}" "s3://${bucketPrefix}.foo2" || false + ! s3cmdrun "${incus_backend}" "${initAccessKey}" "${initSecretKey}" put "${incusTestFile}" "s3://${bucketPrefix}.foo2" || false # Grow bucket quota (significantly larger in order for MinIO to detect their is sufficient space to continue). - lxc storage bucket set "${poolName}" "${bucketPrefix}.foo2" size=150MiB - s3cmdrun "${lxd_backend}" "${initAccessKey}" "${initSecretKey}" put "${lxdTestFile}" "s3://${bucketPrefix}.foo2" - s3cmdrun "${lxd_backend}" "${initAccessKey}" "${initSecretKey}" del "s3://${bucketPrefix}.foo2/${lxdTestFile}" - lxc storage bucket delete "${poolName}" "${bucketPrefix}.foo2" + inc storage bucket set "${poolName}" "${bucketPrefix}.foo2" size=150MiB + s3cmdrun "${incus_backend}" "${initAccessKey}" "${initSecretKey}" put "${incusTestFile}" "s3://${bucketPrefix}.foo2" + s3cmdrun "${incus_backend}" "${initAccessKey}" "${initSecretKey}" del "s3://${bucketPrefix}.foo2/${incusTestFile}" + inc storage bucket delete "${poolName}" "${bucketPrefix}.foo2" fi # Cleanup test file used earlier. - rm "${lxdTestFile}" + rm "${incusTestFile}" # Test deleting bucket via s3. - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" rb "s3://${bucketPrefix}.foo" || false - s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" rb "s3://${bucketPrefix}.foo" + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" rb "s3://${bucketPrefix}.foo" || false + s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" rb "s3://${bucketPrefix}.foo" # Delete bucket keys. - lxc storage bucket key delete "${poolName}" "${bucketPrefix}.foo" admin-key - lxc storage bucket key delete "${poolName}" "${bucketPrefix}.foo" ro-key - ! lxc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "admin-key" || false - ! lxc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "ro-key" || false - ! lxc storage bucket key show "${poolName}" "${bucketPrefix}.foo" admin-key || false - ! lxc storage bucket key show "${poolName}" "${bucketPrefix}.foo" ro-key || false - ! s3cmdrun "${lxd_backend}" "${adAccessKey}" "${adSecretKey}" ls || false - ! s3cmdrun "${lxd_backend}" "${roAccessKey}" "${roSecretKey}" ls || false + inc storage bucket key delete "${poolName}" "${bucketPrefix}.foo" admin-key + inc storage bucket key delete "${poolName}" "${bucketPrefix}.foo" ro-key + ! inc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "admin-key" || false + ! inc storage bucket key list "${poolName}" "${bucketPrefix}.foo" | grep -F "ro-key" || false + ! inc storage bucket key show "${poolName}" "${bucketPrefix}.foo" admin-key || false + ! inc storage bucket key show "${poolName}" "${bucketPrefix}.foo" ro-key || false + ! s3cmdrun "${incus_backend}" "${adAccessKey}" "${adSecretKey}" ls || false + ! s3cmdrun "${incus_backend}" "${roAccessKey}" "${roSecretKey}" ls || false # Delete bucket. - lxc storage bucket delete "${poolName}" "${bucketPrefix}.foo" - ! lxc storage bucket list "${poolName}" | grep -F "${bucketPrefix}.foo" || false - ! lxc storage bucket show "${poolName}" "${bucketPrefix}.foo" || false + inc storage bucket delete "${poolName}" "${bucketPrefix}.foo" + ! inc storage bucket list "${poolName}" | grep -F "${bucketPrefix}.foo" || false + ! inc storage bucket show "${poolName}" "${bucketPrefix}.foo" || false - if [ "$lxd_backend" = "ceph" ] || [ "$lxd_backend" = "dir" ]; then - lxc storage delete "${poolName}" + if [ "$incus_backend" = "ceph" ] || [ "$incus_backend" = "dir" ]; then + inc storage delete "${poolName}" fi - if [ "$lxd_backend" = "dir" ]; then + if [ "$incus_backend" = "dir" ]; then umount "${TEST_DIR}/${bucketPrefix}" rmdir "${TEST_DIR}/${bucketPrefix}" diff --git a/test/suites/storage_driver_btrfs.sh b/test/suites/storage_driver_btrfs.sh index 1115c565a70..1a09ddda4a1 100644 --- a/test/suites/storage_driver_btrfs.sh +++ b/test/suites/storage_driver_btrfs.sh @@ -1,163 +1,163 @@ test_storage_driver_btrfs() { # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" != "btrfs" ]; then + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" != "btrfs" ]; then return fi - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" # shellcheck disable=SC1009 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" btrfs - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool2" btrfs + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool1" btrfs + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool2" btrfs # Set default storage pool for image import. - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Import image into default storage pool. ensure_import_testimage # Create first container in pool1 with subvolumes. - lxc launch testimage c1pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc launch testimage c1pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" # Snapshot without any subvolumes (to test missing subvolume parent origin is handled). - lxc snapshot c1pool1 snap0 + inc snapshot c1pool1 snap0 # Create some subvolumes and populate with test files. Mark the intermedia subvolume as read only. - OWNER="$(stat -c %u:%g "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs")" - btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a" - chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a" - btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" - chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" - btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" - chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" - lxc exec c1pool1 -- touch /a/a1.txt - lxc exec c1pool1 -- touch /a/b/b1.txt - lxc exec c1pool1 -- touch /a/b/c/c1.txt - btrfs property set "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro true + OWNER="$(stat -c %u:%g "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs")" + btrfs subvolume create "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a" + chown "${OWNER}" "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a" + btrfs subvolume create "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" + chown "${OWNER}" "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" + btrfs subvolume create "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" + chown "${OWNER}" "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" + inc exec c1pool1 -- touch /a/a1.txt + inc exec c1pool1 -- touch /a/b/b1.txt + inc exec c1pool1 -- touch /a/b/c/c1.txt + btrfs property set "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro true # Snapshot again now subvolumes exist. - lxc snapshot c1pool1 snap1 + inc snapshot c1pool1 snap1 # Add some more files to subvolumes - btrfs property set "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro false - lxc exec c1pool1 -- touch /a/a2.txt - lxc exec c1pool1 -- touch /a/b/b2.txt - lxc exec c1pool1 -- touch /a/b/c/c2.txt - btrfs property set "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro true - lxc snapshot c1pool1 snap2 + btrfs property set "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro false + inc exec c1pool1 -- touch /a/a2.txt + inc exec c1pool1 -- touch /a/b/b2.txt + inc exec c1pool1 -- touch /a/b/c/c2.txt + btrfs property set "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro true + inc snapshot c1pool1 snap2 # Copy container to other BTRFS storage pool (will use migration subsystem). - lxc copy c1pool1 c1pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc start c1pool2 - lxc exec c1pool2 -- stat /a/a2.txt - lxc exec c1pool2 -- stat /a/b/b2.txt - lxc exec c1pool2 -- stat /a/b/c/c2.txt + inc copy c1pool1 c1pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc start c1pool2 + inc exec c1pool2 -- stat /a/a2.txt + inc exec c1pool2 -- stat /a/b/b2.txt + inc exec c1pool2 -- stat /a/b/c/c2.txt # Test readonly property has been propagated. - lxc exec c1pool2 -- touch /a/w.txt - ! lxc exec c1pool2 -- touch /a/b/w.txt || false - lxc exec c1pool2 -- touch /a/b/c/w.txt + inc exec c1pool2 -- touch /a/w.txt + ! inc exec c1pool2 -- touch /a/b/w.txt || false + inc exec c1pool2 -- touch /a/b/c/w.txt # Restore copied snapshot and check it is correct. - lxc restore c1pool2 snap1 - lxc exec c1pool2 -- stat /a/a1.txt - lxc exec c1pool2 -- stat /a/b/b1.txt - lxc exec c1pool2 -- stat /a/b/c/c1.txt - ! lxc exec c1pool2 -- stat /a/a2.txt || false - ! lxc exec c1pool2 -- stat /a/b/b2.txt || false - ! lxc exec c1pool2 -- stat /a/b/c/c2.txt || false + inc restore c1pool2 snap1 + inc exec c1pool2 -- stat /a/a1.txt + inc exec c1pool2 -- stat /a/b/b1.txt + inc exec c1pool2 -- stat /a/b/c/c1.txt + ! inc exec c1pool2 -- stat /a/a2.txt || false + ! inc exec c1pool2 -- stat /a/b/b2.txt || false + ! inc exec c1pool2 -- stat /a/b/c/c2.txt || false # Test readonly property has been propagated in snapshot. - lxc exec c1pool2 -- touch /a/w.txt - ! lxc exec c1pool2 -- touch /a/b/w.txt || false - lxc exec c1pool2 -- touch /a/b/c/w.txt - lxc delete -f c1pool2 + inc exec c1pool2 -- touch /a/w.txt + ! inc exec c1pool2 -- touch /a/b/w.txt || false + inc exec c1pool2 -- touch /a/b/c/w.txt + inc delete -f c1pool2 # Copy snapshot to as a new instance on different pool. - lxc copy c1pool1/snap1 c1pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc start c1pool2 - lxc exec c1pool2 -- stat /a/a1.txt - lxc exec c1pool2 -- stat /a/b/b1.txt - lxc exec c1pool2 -- stat /a/b/c/c1.txt - ! lxc exec c1pool2 -- stat /a/a2.txt || false - ! lxc exec c1pool2 -- stat /a/b/b2.txt || false - ! lxc exec c1pool2 -- stat /a/b/c/c2.txt || false + inc copy c1pool1/snap1 c1pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc start c1pool2 + inc exec c1pool2 -- stat /a/a1.txt + inc exec c1pool2 -- stat /a/b/b1.txt + inc exec c1pool2 -- stat /a/b/c/c1.txt + ! inc exec c1pool2 -- stat /a/a2.txt || false + ! inc exec c1pool2 -- stat /a/b/b2.txt || false + ! inc exec c1pool2 -- stat /a/b/c/c2.txt || false # Test readonly property has been propagated in snapshot. - lxc exec c1pool2 -- touch /a/w.txt - ! lxc exec c1pool2 -- touch /a/b/w.txt || false - lxc exec c1pool2 -- touch /a/b/c/w.txt - lxc delete -f c1pool2 + inc exec c1pool2 -- touch /a/w.txt + ! inc exec c1pool2 -- touch /a/b/w.txt || false + inc exec c1pool2 -- touch /a/b/c/w.txt + inc delete -f c1pool2 # Delete /a in c1pool1 and restore snap 1. - btrfs property set "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro false - btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" - btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" - btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a" - lxc restore c1pool1 snap1 - lxc exec c1pool1 -- stat /a/a1.txt - lxc exec c1pool1 -- stat /a/b/b1.txt - lxc exec c1pool1 -- stat /a/b/c/c1.txt - lxc exec c1pool1 -- touch /a/w.txt - ! lxc exec c1pool1 -- touch /a/b/w.txt || false - lxc exec c1pool1 -- touch /a/b/c/w.txt + btrfs property set "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro false + btrfs subvol delete "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c" + btrfs subvol delete "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a/b" + btrfs subvol delete "${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")-pool1/containers/c1pool1/rootfs/a" + inc restore c1pool1 snap1 + inc exec c1pool1 -- stat /a/a1.txt + inc exec c1pool1 -- stat /a/b/b1.txt + inc exec c1pool1 -- stat /a/b/c/c1.txt + inc exec c1pool1 -- touch /a/w.txt + ! inc exec c1pool1 -- touch /a/b/w.txt || false + inc exec c1pool1 -- touch /a/b/c/w.txt # Copy c1pool1 to same pool. - lxc copy c1pool1 c2pool1 - lxc start c2pool1 - lxc exec c2pool1 -- stat /a/a1.txt - lxc exec c2pool1 -- stat /a/b/b1.txt - lxc exec c2pool1 -- stat /a/b/c/c1.txt + inc copy c1pool1 c2pool1 + inc start c2pool1 + inc exec c2pool1 -- stat /a/a1.txt + inc exec c2pool1 -- stat /a/b/b1.txt + inc exec c2pool1 -- stat /a/b/c/c1.txt # Test readonly property has been propagated. - lxc exec c2pool1 -- touch /a/w.txt - ! lxc exec c2pool1 -- touch /a/b/w.txt || false - lxc exec c2pool1 -- touch /a/b/c/w.txt - lxc delete -f c2pool1 + inc exec c2pool1 -- touch /a/w.txt + ! inc exec c2pool1 -- touch /a/b/w.txt || false + inc exec c2pool1 -- touch /a/b/c/w.txt + inc delete -f c2pool1 # Copy snap2 of c1pool1 to same pool as separate instance. - lxc copy c1pool1/snap2 c2pool1 - lxc start c2pool1 - lxc exec c2pool1 -- stat /a/a2.txt - lxc exec c2pool1 -- stat /a/b/b2.txt - lxc exec c2pool1 -- stat /a/b/c/c2.txt + inc copy c1pool1/snap2 c2pool1 + inc start c2pool1 + inc exec c2pool1 -- stat /a/a2.txt + inc exec c2pool1 -- stat /a/b/b2.txt + inc exec c2pool1 -- stat /a/b/c/c2.txt # Test readonly property has been propagated. - lxc exec c2pool1 -- touch /a/w.txt - ! lxc exec c2pool1 -- touch /a/b/w.txt || false - lxc exec c2pool1 -- touch /a/b/c/w.txt - lxc delete -f c2pool1 + inc exec c2pool1 -- touch /a/w.txt + ! inc exec c2pool1 -- touch /a/b/w.txt || false + inc exec c2pool1 -- touch /a/b/c/w.txt + inc delete -f c2pool1 # Backup c1pool1 and test subvolumes can be restored. - lxc export c1pool1 "${LXD_DIR}/c1pool1.tar.gz" --optimized-storage - lxc delete -f c1pool1 - lxc import "${LXD_DIR}/c1pool1.tar.gz" - lxc start c1pool1 - lxc exec c1pool1 -- stat /a/a1.txt - lxc exec c1pool1 -- stat /a/b/b1.txt - lxc exec c1pool1 -- stat /a/b/c/c1.txt + inc export c1pool1 "${INCUS_DIR}/c1pool1.tar.gz" --optimized-storage + inc delete -f c1pool1 + inc import "${INCUS_DIR}/c1pool1.tar.gz" + inc start c1pool1 + inc exec c1pool1 -- stat /a/a1.txt + inc exec c1pool1 -- stat /a/b/b1.txt + inc exec c1pool1 -- stat /a/b/c/c1.txt # Test readonly property has been propagated. - lxc exec c1pool1 -- touch /a/w.txt - ! lxc exec c1pool1 -- touch /a/b/w.txt || false - lxc exec c1pool1 -- touch /a/b/c/w.txt - - lxc delete -f c1pool1 - lxc profile device remove default root - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool2" + inc exec c1pool1 -- touch /a/w.txt + ! inc exec c1pool1 -- touch /a/b/w.txt || false + inc exec c1pool1 -- touch /a/b/c/w.txt + + inc delete -f c1pool1 + inc profile device remove default root + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool1" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool2" ) # shellcheck disable=SC2031 - kill_lxd "${LXD_STORAGE_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_driver_ceph.sh b/test/suites/storage_driver_ceph.sh index da739423075..102f29644d9 100644 --- a/test/suites/storage_driver_ceph.sh +++ b/test/suites/storage_driver_ceph.sh @@ -1,63 +1,63 @@ test_storage_driver_ceph() { # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" != "ceph" ]; then + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" != "ceph" ]; then return fi - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" # shellcheck disable=SC1009 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" ceph volume.size=25MiB ceph.osd.pg_num=16 + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool1" ceph volume.size=25MiB ceph.osd.pg_num=16 # Set default storage pool for image import. - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Import image into default storage pool. ensure_import_testimage # create osd pool - ceph --cluster "${LXD_CEPH_CLUSTER}" osd pool create "lxdtest-$(basename "${LXD_DIR}")-existing-osd-pool" 1 + ceph --cluster "${INCUS_CEPH_CLUSTER}" osd pool create "incustest-$(basename "${INCUS_DIR}")-existing-osd-pool" 1 - # Let LXD use an already existing osd pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool2" ceph source="lxdtest-$(basename "${LXD_DIR}")-existing-osd-pool" volume.size=25MiB ceph.osd.pg_num=16 + # Let Incus use an already existing osd pool. + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool2" ceph source="incustest-$(basename "${INCUS_DIR}")-existing-osd-pool" volume.size=25MiB ceph.osd.pg_num=16 # Test that no invalid ceph storage pool configuration keys can be set. - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-ceph-pool-config" ceph lvm.thinpool_name=bla || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-ceph-pool-config" ceph lvm.use_thinpool=false || false - ! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-ceph-pool-config" ceph lvm.vg_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-ceph-pool-config" ceph lvm.thinpool_name=bla || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-ceph-pool-config" ceph lvm.use_thinpool=false || false + ! inc storage create "incustest-$(basename "${INCUS_DIR}")-invalid-ceph-pool-config" ceph lvm.vg_name=bla || false # Test that all valid ceph storage pool configuration keys can be set. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-ceph-pool-config" ceph volume.block.filesystem=ext4 volume.block.mount_options=discard volume.size=25MiB ceph.rbd.clone_copy=true ceph.osd.pg_num=16 - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-ceph-pool-config" + inc storage create "incustest-$(basename "${INCUS_DIR}")-valid-ceph-pool-config" ceph volume.block.filesystem=ext4 volume.block.mount_options=discard volume.size=25MiB ceph.rbd.clone_copy=true ceph.osd.pg_num=16 + inc storage delete "incustest-$(basename "${INCUS_DIR}")-valid-ceph-pool-config" # Muck around with some containers on various pools. - lxc init testimage c1pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc list -c b c1pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc init testimage c1pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc list -c b c1pool1 | grep "incustest-$(basename "${INCUS_DIR}")-pool1" - lxc init testimage c2pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc list -c b c2pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2" + inc init testimage c2pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc list -c b c2pool2 | grep "incustest-$(basename "${INCUS_DIR}")-pool2" - lxc launch testimage c3pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc list -c b c3pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc launch testimage c3pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc list -c b c3pool1 | grep "incustest-$(basename "${INCUS_DIR}")-pool1" - lxc launch testimage c4pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc list -c b c4pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2" + inc launch testimage c4pool2 -s "incustest-$(basename "${INCUS_DIR}")-pool2" + inc list -c b c4pool2 | grep "incustest-$(basename "${INCUS_DIR}")-pool2" - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool1" volume.block.filesystem xfs + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool1" volume.block.filesystem xfs # xfs is unhappy with block devices < 48 MiB. It seems to calculate the # ag{count,size} parameters wrong and/or sets the data area too big. - lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool1" volume.size 48MiB - lxc init testimage c5pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc storage set "incustest-$(basename "${INCUS_DIR}")-pool1" volume.size 48MiB + inc init testimage c5pool1 -s "incustest-$(basename "${INCUS_DIR}")-pool1" # Test whether dependency tracking is working correctly. We should be able # to create a container, copy it, which leads to a dependency relation @@ -68,71 +68,71 @@ test_storage_driver_ceph() { # it to introduce another dependency relation. Now we delete the source # container again. This should work. If it doesn't it means the rename # operation tries to map the two source to the same name. - lxc init testimage a -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc copy a b - lxc delete a - lxc init testimage a -s "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc copy a c - lxc delete a - lxc delete b - lxc delete c - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 - - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice /opt - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice2 /opt || false - lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2-renamed - lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2-renamed c4pool2 - - lxc delete -f c1pool1 - lxc delete -f c3pool1 - lxc delete -f c5pool1 - - lxc delete -f c4pool2 - lxc delete -f c2pool2 - - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 size 500MiB - lxc storage volume unset "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 size - - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 - - lxc image delete testimage - lxc profile device remove default root - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool1" - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool2" - ceph --cluster "${LXD_CEPH_CLUSTER}" osd pool rm "lxdtest-$(basename "${LXD_DIR}")-existing-osd-pool" "lxdtest-$(basename "${LXD_DIR}")-existing-osd-pool" --yes-i-really-really-mean-it + inc init testimage a -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc copy a b + inc delete a + inc init testimage a -s "incustest-$(basename "${INCUS_DIR}")-pool1" + inc copy a c + inc delete a + inc delete b + inc delete c + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 c1pool1 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 c2pool2 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 c3pool1 + + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice /opt + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice2 /opt || false + inc storage volume detach "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2 + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 c4pool2-renamed + inc storage volume rename "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2-renamed c4pool2 + + inc delete -f c1pool1 + inc delete -f c3pool1 + inc delete -f c5pool1 + + inc delete -f c4pool2 + inc delete -f c2pool2 + + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 size 500MiB + inc storage volume unset "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 size + + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool1" c1pool1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool1" c2pool2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool2" c3pool1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-pool2" c4pool2 + + inc image delete testimage + inc profile device remove default root + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool1" + inc storage delete "incustest-$(basename "${INCUS_DIR}")-pool2" + ceph --cluster "${INCUS_CEPH_CLUSTER}" osd pool rm "incustest-$(basename "${INCUS_DIR}")-existing-osd-pool" "incustest-$(basename "${INCUS_DIR}")-existing-osd-pool" --yes-i-really-really-mean-it ) # shellcheck disable=SC2031 - kill_lxd "${LXD_STORAGE_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_driver_cephfs.sh b/test/suites/storage_driver_cephfs.sh index 233f415e158..1974d456ef3 100644 --- a/test/suites/storage_driver_cephfs.sh +++ b/test/suites/storage_driver_cephfs.sh @@ -1,44 +1,44 @@ test_storage_driver_cephfs() { # shellcheck disable=2039,3043 - local lxd_backend + local incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" != "ceph" ] || [ -z "${LXD_CEPH_CEPHFS:-}" ]; then + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" != "ceph" ] || [ -z "${INCUS_CEPH_CEPHFS:-}" ]; then return fi # Simple create/delete attempt - lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" - lxc storage delete cephfs + inc storage create cephfs cephfs source="${INCUS_CEPH_CEPHFS}/$(basename "${INCUS_DIR}")" + inc storage delete cephfs # Second create (confirm got cleaned up properly) - lxc storage create cephfs cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")" - lxc storage info cephfs + inc storage create cephfs cephfs source="${INCUS_CEPH_CEPHFS}/$(basename "${INCUS_DIR}")" + inc storage info cephfs # Creation, rename and deletion - lxc storage volume create cephfs vol1 - lxc storage volume set cephfs vol1 size 100MiB - lxc storage volume rename cephfs vol1 vol2 - lxc storage volume copy cephfs/vol2 cephfs/vol1 - lxc storage volume delete cephfs vol1 - lxc storage volume delete cephfs vol2 + inc storage volume create cephfs vol1 + inc storage volume set cephfs vol1 size 100MiB + inc storage volume rename cephfs vol1 vol2 + inc storage volume copy cephfs/vol2 cephfs/vol1 + inc storage volume delete cephfs vol1 + inc storage volume delete cephfs vol2 # Snapshots - lxc storage volume create cephfs vol1 - lxc storage volume snapshot cephfs vol1 - lxc storage volume snapshot cephfs vol1 - lxc storage volume snapshot cephfs vol1 blah1 - lxc storage volume rename cephfs vol1/blah1 vol1/blah2 - lxc storage volume snapshot cephfs vol1 blah1 - lxc storage volume delete cephfs vol1/snap0 - lxc storage volume delete cephfs vol1/snap1 - lxc storage volume restore cephfs vol1 blah1 - lxc storage volume copy cephfs/vol1 cephfs/vol2 --volume-only - lxc storage volume copy cephfs/vol1 cephfs/vol3 --volume-only - lxc storage volume delete cephfs vol1 - lxc storage volume delete cephfs vol2 - lxc storage volume delete cephfs vol3 + inc storage volume create cephfs vol1 + inc storage volume snapshot cephfs vol1 + inc storage volume snapshot cephfs vol1 + inc storage volume snapshot cephfs vol1 blah1 + inc storage volume rename cephfs vol1/blah1 vol1/blah2 + inc storage volume snapshot cephfs vol1 blah1 + inc storage volume delete cephfs vol1/snap0 + inc storage volume delete cephfs vol1/snap1 + inc storage volume restore cephfs vol1 blah1 + inc storage volume copy cephfs/vol1 cephfs/vol2 --volume-only + inc storage volume copy cephfs/vol1 cephfs/vol3 --volume-only + inc storage volume delete cephfs vol1 + inc storage volume delete cephfs vol2 + inc storage volume delete cephfs vol3 # Cleanup - lxc storage delete cephfs + inc storage delete cephfs } diff --git a/test/suites/storage_driver_zfs.sh b/test/suites/storage_driver_zfs.sh index b591ad87568..12e0a6e975b 100644 --- a/test/suites/storage_driver_zfs.sh +++ b/test/suites/storage_driver_zfs.sh @@ -8,222 +8,227 @@ test_storage_driver_zfs() { do_zfs_cross_pool_copy() { # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" != "zfs" ]; then + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" != "zfs" ]; then return fi - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false # Import image into default storage pool. ensure_import_testimage - lxc storage create lxdtest-"$(basename "${LXD_DIR}")"-dir dir + inc storage create incustest-"$(basename "${INCUS_DIR}")"-dir dir - lxc init testimage c1 -s lxdtest-"$(basename "${LXD_DIR}")"-dir - lxc copy c1 c2 -s lxdtest-"$(basename "${LXD_DIR}")" + inc init testimage c1 -s incustest-"$(basename "${INCUS_DIR}")"-dir + inc copy c1 c2 -s incustest-"$(basename "${INCUS_DIR}")" # Check created zfs volume - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c2")" = "filesystem" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c2")" = "filesystem" ] # Turn on block mode - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode true + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode true - lxc copy c1 c3 -s lxdtest-"$(basename "${LXD_DIR}")" + inc copy c1 c3 -s incustest-"$(basename "${INCUS_DIR}")" # Check created zfs volume - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c3")" = "volume" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c3")" = "volume" ] # Turn off block mode - lxc storage unset lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode + inc storage unset incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode - lxc storage create lxdtest-"$(basename "${LXD_DIR}")"-zfs zfs + inc storage create incustest-"$(basename "${INCUS_DIR}")"-zfs zfs - lxc init testimage c4 -s lxdtest-"$(basename "${LXD_DIR}")"-zfs - lxc copy c4 c5 -s lxdtest-"$(basename "${LXD_DIR}")" + inc init testimage c4 -s incustest-"$(basename "${INCUS_DIR}")"-zfs + inc copy c4 c5 -s incustest-"$(basename "${INCUS_DIR}")" # Check created zfs volume - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c5")" = "filesystem" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c5")" = "filesystem" ] # Turn on block mode - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode true + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode true # Although block mode is turned on on the target storage pool, c6 will be created as a dataset. # That is because of optimized transfer which doesn't change the volume type. - lxc copy c4 c6 -s lxdtest-"$(basename "${LXD_DIR}")" + inc copy c4 c6 -s incustest-"$(basename "${INCUS_DIR}")" # Check created zfs volume - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c6")" = "filesystem" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c6")" = "filesystem" ] # Turn off block mode - lxc storage unset lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode + inc storage unset incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode # Clean up - lxc rm -f c1 c2 c3 c4 c5 c6 - lxc storage rm lxdtest-"$(basename "${LXD_DIR}")"-dir - lxc storage rm lxdtest-"$(basename "${LXD_DIR}")"-zfs + inc rm -f c1 c2 c3 c4 c5 c6 + inc storage rm incustest-"$(basename "${INCUS_DIR}")"-dir + inc storage rm incustest-"$(basename "${INCUS_DIR}")"-zfs # shellcheck disable=SC2031 - kill_lxd "${LXD_STORAGE_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } do_storage_driver_zfs() { filesystem="$1" + if ! command -v "mkfs.${filesystem}" >/dev/null 2>&1; then + echo "==> SKIP: Skipping block mode test on ${filesystem} due to missing tools." + return + fi + # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - if [ "$lxd_backend" != "zfs" ]; then + incus_backend=$(storage_backend "$INCUS_DIR") + if [ "$incus_backend" != "zfs" ]; then return fi - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false # Import image into default storage pool. ensure_import_testimage - fingerprint=$(lxc image info testimage | awk '/^Fingerprint/ {print $2}') + fingerprint=$(inc image info testimage | awk '/^Fingerprint/ {print $2}') # Create non-block container - lxc launch testimage c1 + inc launch testimage c1 # Check created container and image volumes - zfs list lxdtest-"$(basename "${LXD_DIR}")/containers/c1" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}@readonly" - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c1")" = "filesystem" ] - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}")" = "filesystem" ] + zfs list incustest-"$(basename "${INCUS_DIR}")/containers/c1" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}@readonly" + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c1")" = "filesystem" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}")" = "filesystem" ] # Turn on block mode - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode true + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode true # Set block filesystem - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.block.filesystem "${filesystem}" + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.block.filesystem "${filesystem}" # Create container in block mode and check online grow. - lxc launch testimage c2 - lxc config device override c2 root size=11GiB + inc launch testimage c2 + inc config device override c2 root size=11GiB # Check created zfs volumes - zfs list lxdtest-"$(basename "${LXD_DIR}")/containers/c2" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}_${filesystem}" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}_${filesystem}@readonly" - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c2")" = "volume" ] + zfs list incustest-"$(basename "${INCUS_DIR}")/containers/c2" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}_${filesystem}" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}_${filesystem}@readonly" + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c2")" = "volume" ] # Create container in block mode with smaller size override. - lxc init testimage c3 -d root,size=5GiB - lxc delete -f c3 + inc init testimage c3 -d root,size=5GiB + inc delete -f c3 # Delete image volume - lxc storage volume rm lxdtest-"$(basename "${LXD_DIR}")" image/"${fingerprint}" + inc storage volume rm incustest-"$(basename "${INCUS_DIR}")" image/"${fingerprint}" - zfs list lxdtest-"$(basename "${LXD_DIR}")/deleted/images/${fingerprint}_${filesystem}" - zfs list lxdtest-"$(basename "${LXD_DIR}")/deleted/images/${fingerprint}_${filesystem}@readonly" + zfs list incustest-"$(basename "${INCUS_DIR}")/deleted/images/${fingerprint}_${filesystem}" + zfs list incustest-"$(basename "${INCUS_DIR}")/deleted/images/${fingerprint}_${filesystem}@readonly" - lxc storage unset lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode + inc storage unset incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode # Create non-block mode instance - lxc launch testimage c6 - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}" - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c6")" = "filesystem" ] + inc launch testimage c6 + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}" + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c6")" = "filesystem" ] - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode true + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode true # Create block mode instance - lxc launch testimage c7 + inc launch testimage c7 # Check created zfs volumes - zfs list lxdtest-"$(basename "${LXD_DIR}")/containers/c7" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}_${filesystem}" - zfs list lxdtest-"$(basename "${LXD_DIR}")/images/${fingerprint}_${filesystem}@readonly" - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c7")" = "volume" ] + zfs list incustest-"$(basename "${INCUS_DIR}")/containers/c7" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}_${filesystem}" + zfs list incustest-"$(basename "${INCUS_DIR}")/images/${fingerprint}_${filesystem}@readonly" + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c7")" = "volume" ] - lxc stop -f c1 c2 + inc stop -f c1 c2 # Try renaming instance - lxc rename c2 c3 + inc rename c2 c3 # Create snapshot - lxc snapshot c3 snap0 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c3@snapshot-snap0")" = "snapshot" ] + inc snapshot c3 snap0 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c3@snapshot-snap0")" = "snapshot" ] # This should create c11 as a dataset, and c21 as a zvol - lxc copy c1 c11 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c11")" = "filesystem" ] + inc copy c1 c11 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c11")" = "filesystem" ] - lxc copy c3 c21 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c21")" = "volume" ] - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c21@snapshot-snap0")" = "snapshot" ] + inc copy c3 c21 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c21")" = "volume" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c21@snapshot-snap0")" = "snapshot" ] # Create storage volumes - lxc storage volume create lxdtest-"$(basename "${LXD_DIR}")" vol1 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/custom/default_vol1")" = "volume" ] + inc storage volume create incustest-"$(basename "${INCUS_DIR}")" vol1 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/custom/default_vol1")" = "volume" ] - lxc storage volume create lxdtest-"$(basename "${LXD_DIR}")" vol2 zfs.block_mode=false - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/custom/default_vol2")" = "filesystem" ] + inc storage volume create incustest-"$(basename "${INCUS_DIR}")" vol2 zfs.block_mode=false + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/custom/default_vol2")" = "filesystem" ] - lxc storage volume attach lxdtest-"$(basename "${LXD_DIR}")" vol1 c1 /mnt - lxc storage volume attach lxdtest-"$(basename "${LXD_DIR}")" vol1 c3 /mnt - lxc storage volume attach lxdtest-"$(basename "${LXD_DIR}")" vol1 c21 /mnt + inc storage volume attach incustest-"$(basename "${INCUS_DIR}")" vol1 c1 /mnt + inc storage volume attach incustest-"$(basename "${INCUS_DIR}")" vol1 c3 /mnt + inc storage volume attach incustest-"$(basename "${INCUS_DIR}")" vol1 c21 /mnt - lxc start c1 - lxc start c3 - lxc start c21 + inc start c1 + inc start c3 + inc start c21 - lxc exec c3 -- touch /mnt/foo - lxc exec c21 -- ls /mnt/foo - lxc exec c1 -- ls /mnt/foo + inc exec c3 -- touch /mnt/foo + inc exec c21 -- ls /mnt/foo + inc exec c1 -- ls /mnt/foo - lxc storage volume detach lxdtest-"$(basename "${LXD_DIR}")" vol1 c1 - lxc storage volume detach lxdtest-"$(basename "${LXD_DIR}")" vol1 c3 - lxc storage volume detach lxdtest-"$(basename "${LXD_DIR}")" vol1 c21 + inc storage volume detach incustest-"$(basename "${INCUS_DIR}")" vol1 c1 + inc storage volume detach incustest-"$(basename "${INCUS_DIR}")" vol1 c3 + inc storage volume detach incustest-"$(basename "${INCUS_DIR}")" vol1 c21 - ! lxc exec c3 -- ls /mnt/foo || false - ! lxc exec c21 -- ls /mnt/foo || false + ! inc exec c3 -- ls /mnt/foo || false + ! inc exec c21 -- ls /mnt/foo || false # Backup and import - lxc launch testimage c4 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c4")" = "volume" ] - lxc exec c4 -- touch /root/foo - lxc stop -f c4 - lxc snapshot c4 snap0 - lxc export c4 "${LXD_DIR}/c4.tar.gz" - lxc rm -f c4 - - lxc import "${LXD_DIR}/c4.tar.gz" c4 - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c4")" = "volume" ] - [ "$(zfs get -H -o value type lxdtest-"$(basename "${LXD_DIR}")/containers/c4@snapshot-snap0")" = "snapshot" ] - lxc start c4 - lxc exec c4 -- test -f /root/foo + inc launch testimage c4 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c4")" = "volume" ] + inc exec c4 -- touch /root/foo + inc stop -f c4 + inc snapshot c4 snap0 + inc export c4 "${INCUS_DIR}/c4.tar.gz" + inc rm -f c4 + + inc import "${INCUS_DIR}/c4.tar.gz" c4 + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c4")" = "volume" ] + [ "$(zfs get -H -o value type incustest-"$(basename "${INCUS_DIR}")/containers/c4@snapshot-snap0")" = "snapshot" ] + inc start c4 + inc exec c4 -- test -f /root/foo # Snapshot and restore - lxc snapshot c4 snap1 - lxc exec c4 -- touch /root/bar - lxc stop -f c4 - lxc restore c4 snap1 - lxc start c4 - lxc exec c4 -- test -f /root/foo - ! lxc exec c4 -- test -f /root/bar || false - - lxc storage set lxdtest-"$(basename "${LXD_DIR}")" volume.size=5GiB - lxc launch testimage c5 - lxc storage unset lxdtest-"$(basename "${LXD_DIR}")" volume.size + inc snapshot c4 snap1 + inc exec c4 -- touch /root/bar + inc stop -f c4 + inc restore c4 snap1 + inc start c4 + inc exec c4 -- test -f /root/foo + ! inc exec c4 -- test -f /root/bar || false + + inc storage set incustest-"$(basename "${INCUS_DIR}")" volume.size=5GiB + inc launch testimage c5 + inc storage unset incustest-"$(basename "${INCUS_DIR}")" volume.size # Clean up - lxc rm -f c1 c3 c11 c21 c4 c5 c6 c7 - lxc storage volume rm lxdtest-"$(basename "${LXD_DIR}")" vol1 - lxc storage volume rm lxdtest-"$(basename "${LXD_DIR}")" vol2 + inc rm -f c1 c3 c11 c21 c4 c5 c6 c7 + inc storage volume rm incustest-"$(basename "${INCUS_DIR}")" vol1 + inc storage volume rm incustest-"$(basename "${INCUS_DIR}")" vol2 # Turn off block mode - lxc storage unset lxdtest-"$(basename "${LXD_DIR}")" volume.zfs.block_mode + inc storage unset incustest-"$(basename "${INCUS_DIR}")" volume.zfs.block_mode # shellcheck disable=SC2031 - kill_lxd "${LXD_STORAGE_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_local_volume_handling.sh b/test/suites/storage_local_volume_handling.sh index b6e81a65767..f8978b56936 100644 --- a/test/suites/storage_local_volume_handling.sh +++ b/test/suites/storage_local_volume_handling.sh @@ -2,43 +2,43 @@ test_storage_local_volume_handling() { ensure_import_testimage # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + local INCUS_STORAGE_DIR incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false ensure_import_testimage ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" if storage_backend_available "btrfs"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-btrfs" btrfs size=1GiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-btrfs" btrfs size=1GiB fi if storage_backend_available "ceph"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-ceph" ceph volume.size=25MiB ceph.osd.pg_num=16 - if [ -n "${LXD_CEPH_CEPHFS:-}" ]; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-cephfs" cephfs source="${LXD_CEPH_CEPHFS}/$(basename "${LXD_DIR}")-cephfs" + inc storage create "incustest-$(basename "${INCUS_DIR}")-ceph" ceph volume.size=25MiB ceph.osd.pg_num=16 + if [ -n "${INCUS_CEPH_CEPHFS:-}" ]; then + inc storage create "incustest-$(basename "${INCUS_DIR}")-cephfs" cephfs source="${INCUS_CEPH_CEPHFS}/$(basename "${INCUS_DIR}")-cephfs" fi fi - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-dir" dir + inc storage create "incustest-$(basename "${INCUS_DIR}")-dir" dir if storage_backend_available "lvm"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-lvm" lvm volume.size=25MiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-lvm" lvm volume.size=25MiB fi if storage_backend_available "zfs"; then - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-zfs" zfs size=1GiB + inc storage create "incustest-$(basename "${INCUS_DIR}")-zfs" zfs size=1GiB fi # Test all combinations of our storage drivers - driver="${lxd_backend}" + driver="${incus_backend}" pool_opts= if [ "$driver" = "btrfs" ] || [ "$driver" = "zfs" ]; then @@ -55,208 +55,208 @@ test_storage_local_volume_handling() { if [ -n "${pool_opts}" ]; then # shellcheck disable=SC2086 - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-${driver}1" "${driver}" $pool_opts + inc storage create "incustest-$(basename "${INCUS_DIR}")-${driver}1" "${driver}" $pool_opts else - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-${driver}1" "${driver}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-${driver}1" "${driver}" fi - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 user.foo=snap0 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 snapshots.expiry=1H + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 user.foo=snap0 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 snapshots.expiry=1H # This will create the snapshot vol1/snap0 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 # This will create the snapshot vol1/snap1 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 user.foo=snap1 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 user.foo=postsnap1 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 user.foo=snap1 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 user.foo=postsnap1 # Copy volume with snapshots in same pool - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1copy" + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1copy" # Ensure the target snapshots are there - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy/snap0 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy/snap1 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy/snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy/snap1 # Check snapshot volume config was copied - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy user.foo | grep -Fx "postsnap1" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy/snap0 user.foo | grep -Fx "snap0" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy/snap1 user.foo | grep -Fx "snap1" - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1copy + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy user.foo | grep -Fx "postsnap1" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy/snap0 user.foo | grep -Fx "snap0" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy/snap1 user.foo | grep -Fx "snap1" + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1copy # Copy volume with snapshots in different pool - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${driver}1/vol1" + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${driver}1/vol1" # Ensure the target snapshots are there - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1/snap0 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1/snap1 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1/snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1/snap1 # Check snapshot volume config was copied - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1 user.foo | grep -Fx "postsnap1" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1/snap0 user.foo | grep -Fx "snap0" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1/snap1 user.foo | grep -Fx "snap1" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1 user.foo | grep -Fx "postsnap1" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1/snap0 user.foo | grep -Fx "snap0" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1/snap1 user.foo | grep -Fx "snap1" # Copy volume only - lxc storage volume copy --volume-only "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${driver}1/vol2" + inc storage volume copy --volume-only "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${driver}1/vol2" # Ensure the target snapshots are not there - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol2/snap0 || false - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol2/snap1 || false + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol2/snap0 || false + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol2/snap1 || false # Check snapshot volume config was copied - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol2 user.foo | grep -Fx "postsnap1" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol2 user.foo | grep -Fx "postsnap1" # Copy snapshot to volume - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1/snap0" "lxdtest-$(basename "${LXD_DIR}")-${driver}1/vol3" + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1/snap0" "incustest-$(basename "${INCUS_DIR}")-${driver}1/vol3" # Check snapshot volume config was copied from snapshot - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol3 - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol3 user.foo | grep -Fx "snap0" - - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol3 - lxc storage volume move "lxdtest-$(basename "${LXD_DIR}")-${driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${driver}1/vol1" - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}" vol1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${driver}1" vol1 - lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-${driver}1" + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol3 + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol3 user.foo | grep -Fx "snap0" + + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol3 + inc storage volume move "incustest-$(basename "${INCUS_DIR}")-${driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${driver}1/vol1" + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}" vol1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${driver}1" vol1 + inc storage delete "incustest-$(basename "${INCUS_DIR}")-${driver}1" for source_driver in "btrfs" "ceph" "cephfs" "dir" "lvm" "zfs"; do for target_driver in "btrfs" "ceph" "cephfs" "dir" "lvm" "zfs"; do # shellcheck disable=SC2235 if [ "$source_driver" != "$target_driver" ] \ - && ([ "$lxd_backend" = "$source_driver" ] || ([ "$lxd_backend" = "ceph" ] && [ "$source_driver" = "cephfs" ] && [ -n "${LXD_CEPH_CEPHFS:-}" ])) \ + && ([ "$incus_backend" = "$source_driver" ] || ([ "$incus_backend" = "ceph" ] && [ "$source_driver" = "cephfs" ] && [ -n "${INCUS_CEPH_CEPHFS:-}" ])) \ && storage_backend_available "$source_driver" && storage_backend_available "$target_driver"; then # source_driver -> target_driver - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 # This will create the snapshot vol1/snap0 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 # Copy volume with snapshots - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol1" + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol1" # Ensure the target snapshot is there - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1/snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1/snap0 # Copy volume only - lxc storage volume copy --volume-only "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol2" + inc storage volume copy --volume-only "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol2" # Copy snapshot to volume - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1/snap0" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol3" - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol3 - lxc storage volume move "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol1" - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1/snap0" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol3" + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol3 + inc storage volume move "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol1" + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 # target_driver -> source_driver - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 - lxc storage volume move "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 + inc storage volume move "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 if [ "${source_driver}" = "cephfs" ] || [ "${target_driver}" = "cephfs" ]; then continue fi # create custom block volume without snapshots - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 --type=block size=4194304 - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol1" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol1" - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 | grep -q 'content_type: block' + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 --type=block size=4194304 + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol1" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol1" + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 | grep -q 'content_type: block' # create custom block volume with a snapshot - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2 --type=block size=4194304 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2/snap0 | grep -q 'content_type: block' + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2 --type=block size=4194304 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2/snap0 | grep -q 'content_type: block' # restore snapshot - lxc storage volume restore "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2 snap0 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2 | grep -q 'content_type: block' + inc storage volume restore "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2 snap0 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2 | grep -q 'content_type: block' # copy with snapshots - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol2" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol2" - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol2 | grep -q 'content_type: block' - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol2/snap0 | grep -q 'content_type: block' + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol2" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol2" + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol2 | grep -q 'content_type: block' + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol2/snap0 | grep -q 'content_type: block' # copy without snapshots - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol2" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol3" --volume-only - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol3 | grep -q 'content_type: block' - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol3/snap0 | grep -q 'content_type: block' || false + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol2" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol3" --volume-only + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol3 | grep -q 'content_type: block' + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol3/snap0 | grep -q 'content_type: block' || false # move images - lxc storage volume move "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol2" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol4" - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol2 | grep -q 'content_type: block' || false - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol4 | grep -q 'content_type: block' - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol4/snap0 | grep -q 'content_type: block' + inc storage volume move "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol2" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol4" + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol2 | grep -q 'content_type: block' || false + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol4 | grep -q 'content_type: block' + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol4/snap0 | grep -q 'content_type: block' # check refreshing volumes # create storage volume with user config differing over snapshots - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 --type=block size=4194304 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 user.foo=snap0vol5 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 user.foo=snap1vol5 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 user.foo=snapremovevol5 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 snapremove - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 user.foo=postsnap1vol5 + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 --type=block size=4194304 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 user.foo=snap0vol5 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 user.foo=snap1vol5 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 user.foo=snapremovevol5 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 snapremove + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 user.foo=postsnap1vol5 # create storage volume with user config differing over snapshots and additional snapshot than vol5 - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 --type=block size=4194304 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 user.foo=snap0vol6 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 user.foo=snap1vol6 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 user.foo=snap2vol6 - lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 - lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 user.foo=postsnap1vol6 + inc storage volume create "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 --type=block size=4194304 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 user.foo=snap0vol6 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 user.foo=snap1vol6 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 user.foo=snap2vol6 + inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 + inc storage volume set "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 user.foo=postsnap1vol6 # copy to new volume destination with refresh flag - lxc storage volume copy --refresh "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol5" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol5" + inc storage volume copy --refresh "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol5" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol5" # check snapshot volumes (including config) were copied - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5 user.foo | grep -Fx "postsnap1vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snap0 user.foo | grep -Fx "snap0vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snap1 user.foo | grep -Fx "snap1vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snapremove user.foo | grep -Fx "snapremovevol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5 user.foo | grep -Fx "postsnap1vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snap0 user.foo | grep -Fx "snap0vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snap1 user.foo | grep -Fx "snap1vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snapremove user.foo | grep -Fx "snapremovevol5" # incremental copy to existing volume destination with refresh flag - lxc storage volume copy --refresh "lxdtest-$(basename "${LXD_DIR}")-${source_driver}/vol6" "lxdtest-$(basename "${LXD_DIR}")-${target_driver}/vol5" + inc storage volume copy --refresh "incustest-$(basename "${INCUS_DIR}")-${source_driver}/vol6" "incustest-$(basename "${INCUS_DIR}")-${target_driver}/vol5" # check snapshot volumes (including config) was overridden from new source and that missing snapshot is # present and that the missing snapshot has been removed. # Note: Due to a known issue we are currently only diffing the snapshots by name, so infact existing # snapshots of the same name won't be overwritten even if their config or contents is different. - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5 user.foo | grep -Fx "postsnap1vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snap0 user.foo | grep -Fx "snap0vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snap1 user.foo | grep -Fx "snap1vol5" - lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snap2 user.foo | grep -Fx "snap2vol6" - ! lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5/snapremove user.foo || false + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5 user.foo | grep -Fx "postsnap1vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snap0 user.foo | grep -Fx "snap0vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snap1 user.foo | grep -Fx "snap1vol5" + inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snap2 user.foo | grep -Fx "snap2vol6" + ! inc storage volume get "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5/snapremove user.foo || false # copy ISO custom volumes truncate -s 25MiB foo.iso - lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" ./foo.iso iso1 - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")-${source_driver}"/iso1 "lxdtest-$(basename "${LXD_DIR}")-${target_driver}"/iso1 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" iso1 | grep -q 'content_type: iso' - lxc storage volume move "lxdtest-$(basename "${LXD_DIR}")-${source_driver}"/iso1 "lxdtest-$(basename "${LXD_DIR}")-${target_driver}"/iso2 - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" iso2 | grep -q 'content_type: iso' - ! lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" iso1 || false + inc storage volume import "incustest-$(basename "${INCUS_DIR}")-${source_driver}" ./foo.iso iso1 + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")-${source_driver}"/iso1 "incustest-$(basename "${INCUS_DIR}")-${target_driver}"/iso1 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" iso1 | grep -q 'content_type: iso' + inc storage volume move "incustest-$(basename "${INCUS_DIR}")-${source_driver}"/iso1 "incustest-$(basename "${INCUS_DIR}")-${target_driver}"/iso2 + inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${target_driver}" iso2 | grep -q 'content_type: iso' + ! inc storage volume show "incustest-$(basename "${INCUS_DIR}")-${source_driver}" iso1 || false # clean up - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol3 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol4 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol5 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" vol5 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${source_driver}" vol6 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" iso1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-${target_driver}" iso2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol3 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol4 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol5 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" vol5 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${source_driver}" vol6 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" iso1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")-${target_driver}" iso2 rm -f foo.iso fi done @@ -264,6 +264,6 @@ test_storage_local_volume_handling() { ) # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - kill_lxd "${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_profiles.sh b/test/suites/storage_profiles.sh index 86cadd2c943..924aed36c54 100644 --- a/test/suites/storage_profiles.sh +++ b/test/suites/storage_profiles.sh @@ -1,13 +1,13 @@ test_storage_profiles() { # shellcheck disable=2039 - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false ( set -e # shellcheck disable=2030 - LXD_DIR="${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_STORAGE_DIR}" HAS_ZFS="dir" if command -v zfs >/dev/null 2>&1; then @@ -21,120 +21,120 @@ test_storage_profiles() { # shellcheck disable=SC1009 # Create loop file zfs pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" "${HAS_ZFS}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool1" "${HAS_ZFS}" # Create loop file btrfs pool. - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool2" "${HAS_BTRFS}" + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool2" "${HAS_BTRFS}" - lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool4" dir + inc storage create "incustest-$(basename "${INCUS_DIR}")-pool4" dir # Set default storage pool for image import. - lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Import image into default storage pool. ensure_import_testimage - lxc profile create test + inc profile create test # Create a new profile that provides a root device for some containers. - lxc profile device add test rootfs disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device add test rootfs disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Begin interesting test cases. for i in $(seq 1 3); do - lxc launch testimage c"${i}" --profile test + inc launch testimage c"${i}" --profile test done # Check that we can't remove or change the root disk device since containers # are actually using it. - ! lxc profile device remove test rootfs || false - ! lxc profile device set test rootfs pool "lxdtest-$(basename "${LXD_DIR}")-pool2" || false + ! inc profile device remove test rootfs || false + ! inc profile device set test rootfs pool "incustest-$(basename "${INCUS_DIR}")-pool2" || false # Give all the containers we started their own local root disk device. for i in $(seq 1 2); do - ! lxc config device add c"${i}" root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" || false - lxc config device add c"${i}" rootfs disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + ! inc config device add c"${i}" root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" || false + inc config device add c"${i}" rootfs disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" done # Try to set new pool. This should fail since there is a single container # that has no local root disk device. - ! lxc profile device set test rootfs pool "lxdtest-$(basename "${LXD_DIR}")-pool2" || false + ! inc profile device set test rootfs pool "incustest-$(basename "${INCUS_DIR}")-pool2" || false # This should work since it doesn't change the pool property. - lxc profile device set test rootfs pool "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device set test rootfs pool "incustest-$(basename "${INCUS_DIR}")-pool1" # Check that we can not remove the root disk device since there is a single # container that is still using it. - ! lxc profile device remove test rootfs || false + ! inc profile device remove test rootfs || false # Give the last container a local root disk device. - ! lxc config device add c3 root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" || false - lxc config device add c3 rootfs disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + ! inc config device add c3 root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" || false + inc config device add c3 rootfs disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Try to set new pool. This should work since the container has a local disk - lxc profile device set test rootfs pool "lxdtest-$(basename "${LXD_DIR}")-pool2" - lxc profile device set test rootfs pool "lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile device set test rootfs pool "incustest-$(basename "${INCUS_DIR}")-pool2" + inc profile device set test rootfs pool "incustest-$(basename "${INCUS_DIR}")-pool1" # Check that we can now remove the root disk device since no container is # actually using it. - lxc profile device remove test rootfs + inc profile device remove test rootfs # Add back a root device to the profile. - ! lxc profile device add test rootfs1 disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" || false + ! inc profile device add test rootfs1 disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" || false # Try to add another root device to the profile that tries to set a pool # property. This should fail. This is also a test for whether it is possible # to put multiple disk devices on the same path. This must fail! - ! lxc profile device add test rootfs2 disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool2" || false + ! inc profile device add test rootfs2 disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool2" || false # Add another root device to the profile that does not set a pool property. # This should not work since it would use the same path. - ! lxc profile device add test rootfs3 disk path="/" || false + ! inc profile device add test rootfs3 disk path="/" || false # Create a second profile. - lxc profile create testDup - lxc profile device add testDup rootfs1 disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool1" + inc profile create testDup + inc profile device add testDup rootfs1 disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool1" # Create a third profile - lxc profile create testNoDup - lxc profile device add testNoDup rootfs2 disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool2" + inc profile create testNoDup + inc profile device add testNoDup rootfs2 disk path="/" pool="incustest-$(basename "${INCUS_DIR}")-pool2" # Verify that we cannot create a container with profiles that have # contradicting root devices. - ! lxc launch testimage cConflictingProfiles -p test -p testDup -p testNoDup || false + ! inc launch testimage cConflictingProfiles -p test -p testDup -p testNoDup || false # And that even with a local disk, a container can't have multiple root devices - ! lxc launch testimage cConflictingProfiles -s "lxdtest-$(basename "${LXD_DIR}")-pool2" -p test -p testDup -p testNoDup || false + ! inc launch testimage cConflictingProfiles -s "incustest-$(basename "${INCUS_DIR}")-pool2" -p test -p testDup -p testNoDup || false # Check that we cannot assign conflicting profiles to a container that # relies on another profiles root disk device. - lxc launch testimage cOnDefault - ! lxc profile assign cOnDefault default,testDup,testNoDup || false + inc launch testimage cOnDefault + ! inc profile assign cOnDefault default,testDup,testNoDup || false # Verify that we can create a container with two profiles that specify the # same root disk device. - lxc launch testimage cNonConflictingProfiles -p test -p testDup + inc launch testimage cNonConflictingProfiles -p test -p testDup # Try to remove the root disk device from one of the profiles. - lxc profile device remove test rootfs1 + inc profile device remove test rootfs1 # Try to remove the root disk device from the second profile. - ! lxc profile device remove testDup rootfs1 || false + ! inc profile device remove testDup rootfs1 || false # Test that we can't remove the root disk device from the containers config # when the profile it is attached to specifies no root device. for i in $(seq 1 3); do - ! lxc config device remove c"${i}" root || false + ! inc config device remove c"${i}" root || false # Must fail. - ! lxc profile assign c"${i}" testDup,testNoDup || false + ! inc profile assign c"${i}" testDup,testNoDup || false done - lxc delete -f cNonConflictingProfiles - lxc delete -f cOnDefault + inc delete -f cNonConflictingProfiles + inc delete -f cOnDefault for i in $(seq 1 3); do - lxc delete -f c"${i}" + inc delete -f c"${i}" done ) # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - kill_lxd "${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_snapshots.sh b/test/suites/storage_snapshots.sh index d843b370a3b..c463052727e 100644 --- a/test/suites/storage_snapshots.sh +++ b/test/suites/storage_snapshots.sh @@ -2,106 +2,106 @@ test_storage_volume_snapshots() { ensure_import_testimage # shellcheck disable=2039,3043 - local LXD_STORAGE_DIR lxd_backend + local INCUS_STORAGE_DIR incus_backend - lxd_backend=$(storage_backend "$LXD_DIR") - LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) - chmod +x "${LXD_STORAGE_DIR}" - spawn_lxd "${LXD_STORAGE_DIR}" false + incus_backend=$(storage_backend "$INCUS_DIR") + INCUS_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX) + chmod +x "${INCUS_STORAGE_DIR}" + spawn_incus "${INCUS_STORAGE_DIR}" false # shellcheck disable=2039,3043 local storage_pool storage_volume - storage_pool="lxdtest-$(basename "${LXD_STORAGE_DIR}")-pool" + storage_pool="incustest-$(basename "${INCUS_STORAGE_DIR}")-pool" storage_volume="${storage_pool}-vol" - lxc storage create "$storage_pool" "$lxd_backend" - lxc storage volume create "${storage_pool}" "${storage_volume}" - lxc launch testimage c1 -s "${storage_pool}" - lxc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt + inc storage create "$storage_pool" "$incus_backend" + inc storage volume create "${storage_pool}" "${storage_volume}" + inc launch testimage c1 -s "${storage_pool}" + inc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt # Create file on volume echo foobar > "${TEST_DIR}/testfile" - lxc file push "${TEST_DIR}/testfile" c1/mnt/testfile + inc file push "${TEST_DIR}/testfile" c1/mnt/testfile # Validate file - lxc exec c1 -- test -f /mnt/testfile - [ "$(lxc exec c1 -- cat /mnt/testfile)" = 'foobar' ] + inc exec c1 -- test -f /mnt/testfile + [ "$(inc exec c1 -- cat /mnt/testfile)" = 'foobar' ] - lxc storage volume detach "${storage_pool}" "${storage_volume}" c1 + inc storage volume detach "${storage_pool}" "${storage_volume}" c1 # This will create a snapshot named 'snap0' - lxc storage volume snapshot "${storage_pool}" "${storage_volume}" - lxc storage volume list "${storage_pool}" | grep "${storage_volume}/snap0" - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'name: snap0' - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z' + inc storage volume snapshot "${storage_pool}" "${storage_volume}" + inc storage volume list "${storage_pool}" | grep "${storage_volume}/snap0" + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'name: snap0' + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z' # edit volume snapshot description - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed 's/^description:.*/description: foo/' | lxc storage volume edit "${storage_pool}" "${storage_volume}/snap0" - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q 'description: foo' + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed 's/^description:.*/description: foo/' | inc storage volume edit "${storage_pool}" "${storage_volume}/snap0" + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q 'description: foo' # edit volume snapshot expiry date - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed 's/^expires_at:.*/expires_at: 2100-01-02T15:04:05Z/' | lxc storage volume edit "${storage_pool}" "${storage_volume}/snap0" + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed 's/^expires_at:.*/expires_at: 2100-01-02T15:04:05Z/' | inc storage volume edit "${storage_pool}" "${storage_volume}/snap0" # Depending on the timezone of the runner, some values will be different. # Both the year (2100) and the month (01) will be constant though. - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q '^expires_at: 2100-01' + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q '^expires_at: 2100-01' # Reset/remove expiry date - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed '/^expires_at:/d' | lxc storage volume edit "${storage_pool}" "${storage_volume}/snap0" - lxc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q '^expires_at: 0001-01-01T00:00:00Z' + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | sed '/^expires_at:/d' | inc storage volume edit "${storage_pool}" "${storage_volume}/snap0" + inc storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep -q '^expires_at: 0001-01-01T00:00:00Z' - lxc storage volume set "${storage_pool}" "${storage_volume}" snapshots.expiry '1d' - lxc storage volume snapshot "${storage_pool}" "${storage_volume}" - ! lxc storage volume show "${storage_pool}" "${storage_volume}/snap1" | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc storage volume set "${storage_pool}" "${storage_volume}" snapshots.expiry '1d' + inc storage volume snapshot "${storage_pool}" "${storage_volume}" + ! inc storage volume show "${storage_pool}" "${storage_volume}/snap1" | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc storage volume snapshot "${storage_pool}" "${storage_volume}" --no-expiry - lxc storage volume show "${storage_pool}" "${storage_volume}/snap2" | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false + inc storage volume snapshot "${storage_pool}" "${storage_volume}" --no-expiry + inc storage volume show "${storage_pool}" "${storage_volume}/snap2" | grep -q 'expires_at: 0001-01-01T00:00:00Z' || false - lxc storage volume rm "${storage_pool}" "${storage_volume}/snap2" - lxc storage volume rm "${storage_pool}" "${storage_volume}/snap1" + inc storage volume rm "${storage_pool}" "${storage_volume}/snap2" + inc storage volume rm "${storage_pool}" "${storage_volume}/snap1" # Test snapshot renaming - lxc storage volume snapshot "${storage_pool}" "${storage_volume}" - lxc storage volume list "${storage_pool}" | grep "${storage_volume}/snap1" - lxc storage volume show "${storage_pool}" "${storage_volume}/snap1" | grep 'name: snap1' - lxc storage volume rename "${storage_pool}" "${storage_volume}/snap1" "${storage_volume}/foo" - lxc storage volume list "${storage_pool}" | grep "${storage_volume}/foo" - lxc storage volume show "${storage_pool}" "${storage_volume}/foo" | grep 'name: foo' - - lxc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt + inc storage volume snapshot "${storage_pool}" "${storage_volume}" + inc storage volume list "${storage_pool}" | grep "${storage_volume}/snap1" + inc storage volume show "${storage_pool}" "${storage_volume}/snap1" | grep 'name: snap1' + inc storage volume rename "${storage_pool}" "${storage_volume}/snap1" "${storage_volume}/foo" + inc storage volume list "${storage_pool}" | grep "${storage_volume}/foo" + inc storage volume show "${storage_pool}" "${storage_volume}/foo" | grep 'name: foo' + + inc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt # Delete file on volume - lxc file delete c1/mnt/testfile + inc file delete c1/mnt/testfile # Validate file - ! lxc exec c1 -- test -f /mnt/testfile || false + ! inc exec c1 -- test -f /mnt/testfile || false # This should fail since you cannot restore a snapshot when the target volume # is attached to the container - ! lxc storage volume restore "${storage_pool}" "${storage_volume}" snap0 || false + ! inc storage volume restore "${storage_pool}" "${storage_volume}" snap0 || false - lxc stop -f c1 - lxc storage volume restore "${storage_pool}" "${storage_volume}" foo + inc stop -f c1 + inc storage volume restore "${storage_pool}" "${storage_volume}" foo - lxc start c1 - lxc storage volume detach "${storage_pool}" "${storage_volume}" c1 - lxc storage volume restore "${storage_pool}" "${storage_volume}" foo - lxc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt + inc start c1 + inc storage volume detach "${storage_pool}" "${storage_volume}" c1 + inc storage volume restore "${storage_pool}" "${storage_volume}" foo + inc storage volume attach "${storage_pool}" "${storage_volume}" c1 /mnt # Validate file - lxc exec c1 -- test -f /mnt/testfile - [ "$(lxc exec c1 -- cat /mnt/testfile)" = 'foobar' ] + inc exec c1 -- test -f /mnt/testfile + [ "$(inc exec c1 -- cat /mnt/testfile)" = 'foobar' ] - lxc storage volume detach "${storage_pool}" "${storage_volume}" c1 - lxc delete -f c1 - lxc storage volume delete "${storage_pool}" "${storage_volume}" + inc storage volume detach "${storage_pool}" "${storage_volume}" c1 + inc delete -f c1 + inc storage volume delete "${storage_pool}" "${storage_volume}" # Check snapshots naming conflicts. - lxc storage volume create "${storage_pool}" "vol1" - lxc storage volume create "${storage_pool}" "vol1-snap0" - lxc storage volume snapshot "${storage_pool}" "vol1" "snap0" - lxc storage volume delete "${storage_pool}" "vol1" - lxc storage volume delete "${storage_pool}" "vol1-snap0" + inc storage volume create "${storage_pool}" "vol1" + inc storage volume create "${storage_pool}" "vol1-snap0" + inc storage volume snapshot "${storage_pool}" "vol1" "snap0" + inc storage volume delete "${storage_pool}" "vol1" + inc storage volume delete "${storage_pool}" "vol1-snap0" - lxc storage delete "${storage_pool}" + inc storage delete "${storage_pool}" # shellcheck disable=SC2031,2269 - LXD_DIR="${LXD_DIR}" - kill_lxd "${LXD_STORAGE_DIR}" + INCUS_DIR="${INCUS_DIR}" + kill_incus "${INCUS_STORAGE_DIR}" } diff --git a/test/suites/storage_volume_attach.sh b/test/suites/storage_volume_attach.sh index bdbc2f6d287..9dcb85f647f 100644 --- a/test/suites/storage_volume_attach.sh +++ b/test/suites/storage_volume_attach.sh @@ -39,66 +39,66 @@ test_storage_volume_attach() { ensure_import_testimage # create storage volume - lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")" testvolume + inc storage volume create "incustest-$(basename "${INCUS_DIR}")" testvolume # create containers - lxc launch testimage c1 -c security.privileged=true - lxc launch testimage c2 + inc launch testimage c1 -c security.privileged=true + inc launch testimage c2 # Attach to a single privileged container - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")" testvolume c1 testvolume - PATH_TO_CHECK="${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")/custom/default_testvolume" + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")" testvolume c1 testvolume + PATH_TO_CHECK="${INCUS_DIR}/storage-pools/incustest-$(basename "${INCUS_DIR}")/custom/default_testvolume" [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "0:0" ] # make container unprivileged - lxc config set c1 security.privileged false + inc config set c1 security.privileged false [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "0:0" ] if [ "${UIDs}" -lt 500000 ] || [ "${GIDs}" -lt 500000 ]; then echo "==> SKIP: The storage volume attach test requires at least 500000 uids and gids" - lxc rm -f c1 c2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" testvolume + inc rm -f c1 c2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" testvolume return fi # restart - lxc restart --force c1 + inc restart --force c1 [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "${UID_BASE}:${GID_BASE}" ] # give container isolated id mapping - lxc config set c1 security.idmap.isolated true + inc config set c1 security.idmap.isolated true [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "${UID_BASE}:${GID_BASE}" ] # restart - lxc restart --force c1 + inc restart --force c1 # get new isolated base ids - ISOLATED_UID_BASE="$(lxc exec c1 -- cat /proc/self/uid_map | awk '{print $2}')" - ISOLATED_GID_BASE="$(lxc exec c1 -- cat /proc/self/gid_map | awk '{print $2}')" + ISOLATED_UID_BASE="$(inc exec c1 -- cat /proc/self/uid_map | awk '{print $2}')" + ISOLATED_GID_BASE="$(inc exec c1 -- cat /proc/self/gid_map | awk '{print $2}')" [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "${ISOLATED_UID_BASE}:${ISOLATED_GID_BASE}" ] - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")" testvolume c2 testvolume || false + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")" testvolume c2 testvolume || false # give container standard mapping - lxc config set c1 security.idmap.isolated false + inc config set c1 security.idmap.isolated false [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "${ISOLATED_UID_BASE}:${ISOLATED_GID_BASE}" ] # restart - lxc restart --force c1 + inc restart --force c1 [ "$(stat -c %u:%g "${PATH_TO_CHECK}")" = "${UID_BASE}:${GID_BASE}" ] # attach second container - lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")" testvolume c2 testvolume + inc storage volume attach "incustest-$(basename "${INCUS_DIR}")" testvolume c2 testvolume # check that setting perms on the root of the custom volume persists after a reboot. - lxc exec c2 -- stat -c '%a' /testvolume | grep 711 - lxc exec c2 -- chmod 0700 /testvolume - lxc exec c2 -- stat -c '%a' /testvolume | grep 700 - lxc restart --force c2 - lxc exec c2 -- stat -c '%a' /testvolume | grep 700 + inc exec c2 -- stat -c '%a' /testvolume | grep 711 + inc exec c2 -- chmod 0700 /testvolume + inc exec c2 -- stat -c '%a' /testvolume | grep 700 + inc restart --force c2 + inc exec c2 -- stat -c '%a' /testvolume | grep 700 # delete containers - lxc delete -f c1 - lxc delete -f c2 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" testvolume + inc delete -f c1 + inc delete -f c2 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" testvolume } diff --git a/test/suites/storage_volume_import.sh b/test/suites/storage_volume_import.sh index 40de5b77388..7d54cbc8c30 100644 --- a/test/suites/storage_volume_import.sh +++ b/test/suites/storage_volume_import.sh @@ -5,53 +5,53 @@ test_storage_volume_import() { ensure_import_testimage # importing an ISO as storage volume requires a volume name - ! lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.iso || false - ! lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.img --type=iso || false + ! inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.iso || false + ! inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.img --type=iso || false # import ISO as storage volume - lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.iso foo - lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.img --type=iso foobar - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foo | grep -q 'content_type: iso' - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foobar | grep -q 'content_type: iso' + inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.iso foo + inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.img --type=iso foobar + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foo | grep -q 'content_type: iso' + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foobar | grep -q 'content_type: iso' # delete an ISO storage volume and re-import it - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" foo - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" foobar + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" foo + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" foobar - lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.iso foo - lxc storage volume import "lxdtest-$(basename "${LXD_DIR}")" ./foo.img --type=iso foobar - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foo | grep -q 'content_type: iso' - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foobar | grep -q 'content_type: iso' + inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.iso foo + inc storage volume import "incustest-$(basename "${INCUS_DIR}")" ./foo.img --type=iso foobar + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foo | grep -q 'content_type: iso' + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foobar | grep -q 'content_type: iso' # snapshots are disabled for ISO storage volumes - ! lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")" foo || false + ! inc storage volume snapshot "incustest-$(basename "${INCUS_DIR}")" foo || false # backups are disabled for ISO storage volumes - ! lxc storage volume export "lxdtest-$(basename "${LXD_DIR}")" foo || false + ! inc storage volume export "incustest-$(basename "${INCUS_DIR}")" foo || false # cannot attach ISO storage volumes to containers - lxc init testimage c1 - ! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")" c1 foo || false + inc init testimage c1 + ! inc storage volume attach "incustest-$(basename "${INCUS_DIR}")" c1 foo || false # cannot change storage volume config - ! lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")" foo size=1GiB || false + ! inc storage volume set "incustest-$(basename "${INCUS_DIR}")" foo size=1GiB || false # copy volume - lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")"/foo "lxdtest-$(basename "${LXD_DIR}")"/bar - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" bar | grep -q 'content_type: iso' + inc storage volume copy "incustest-$(basename "${INCUS_DIR}")"/foo "incustest-$(basename "${INCUS_DIR}")"/bar + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" bar | grep -q 'content_type: iso' # cannot refresh copy - ! lxc storage volume copy "lxdtest-$(basename "${LXD_DIR}")"/foo "lxdtest-$(basename "${LXD_DIR}")"/bar --refresh || false + ! inc storage volume copy "incustest-$(basename "${INCUS_DIR}")"/foo "incustest-$(basename "${INCUS_DIR}")"/bar --refresh || false # can change description - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foo | sed 's/^description:.*/description: foo/' | lxc storage volume edit "lxdtest-$(basename "${LXD_DIR}")" foo - lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" foo | grep -q 'description: foo' + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foo | sed 's/^description:.*/description: foo/' | inc storage volume edit "incustest-$(basename "${INCUS_DIR}")" foo + inc storage volume show "incustest-$(basename "${INCUS_DIR}")" foo | grep -q 'description: foo' # cleanup - lxc delete -f c1 - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" foo - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" bar - lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")" foobar + inc delete -f c1 + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" foo + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" bar + inc storage volume delete "incustest-$(basename "${INCUS_DIR}")" foobar rm -f foo.iso foo.img } diff --git a/test/suites/template.sh b/test/suites/template.sh index 490bf9ec199..bc26c20fe25 100644 --- a/test/suites/template.sh +++ b/test/suites/template.sh @@ -1,98 +1,98 @@ test_template() { # shellcheck disable=2039,3043 - local lxd_backend - lxd_backend=$(storage_backend "$LXD_DIR") + local incus_backend + incus_backend=$(storage_backend "$INCUS_DIR") # Import a template which only triggers on create deps/import-busybox --alias template-test --template create - lxc init template-test template + inc init template-test template # Confirm that template application is delayed to first start - ! lxc file pull template/template - || false + ! inc file pull template/template - || false # Validate that the template is applied - lxc start template - lxc file pull template/template - | grep "^name: template$" + inc start template + inc file pull template/template - | grep "^name: template$" - if [ "$lxd_backend" = "lvm" ] || [ "$lxd_backend" = "ceph" ]; then - lxc stop template --force + if [ "$incus_backend" = "lvm" ] || [ "$incus_backend" = "ceph" ]; then + inc stop template --force fi # Confirm it's not applied on copies - lxc copy template template1 - lxc file pull template1/template - | grep "^name: template$" + inc copy template template1 + inc file pull template1/template - | grep "^name: template$" # Cleanup - lxc image delete template-test - lxc delete template template1 --force + inc image delete template-test + inc delete template template1 --force # Import a template which only triggers on copy deps/import-busybox --alias template-test --template copy - lxc launch template-test template + inc launch template-test template # Confirm that the template doesn't trigger on create - ! lxc file pull template/template - || false - if [ "$lxd_backend" = "lvm" ] || [ "$lxd_backend" = "ceph" ]; then - lxc stop template --force + ! inc file pull template/template - || false + if [ "$incus_backend" = "lvm" ] || [ "$incus_backend" = "ceph" ]; then + inc stop template --force fi # Copy the container - lxc copy template template1 + inc copy template template1 # Confirm that template application is delayed to first start - ! lxc file pull template1/template - || false + ! inc file pull template1/template - || false # Validate that the template is applied - lxc start template1 - lxc file pull template1/template - | grep "^name: template1$" + inc start template1 + inc file pull template1/template - | grep "^name: template1$" # Cleanup - lxc image delete template-test - lxc delete template template1 --force + inc image delete template-test + inc delete template template1 --force # Import a template which only triggers on start deps/import-busybox --alias template-test --template start - lxc launch template-test template + inc launch template-test template # Validate that the template is applied - lxc file pull template/template - | grep "^name: template$" - lxc file pull template/template - | grep "^user.foo: _unset_$" + inc file pull template/template - | grep "^name: template$" + inc file pull template/template - | grep "^user.foo: _unset_$" # Confirm it's re-run at every start - lxc config set template user.foo bar - lxc restart template --force - lxc file pull template/template - | grep "^user.foo: bar$" + inc config set template user.foo bar + inc restart template --force + inc file pull template/template - | grep "^user.foo: bar$" # Cleanup - lxc image delete template-test - lxc delete template --force + inc image delete template-test + inc delete template --force # Import a template which triggers on both create and copy deps/import-busybox --alias template-test --template create,copy - lxc init template-test template + inc init template-test template # Confirm that template application is delayed to first start - ! lxc file pull template/template - || false + ! inc file pull template/template - || false # Validate that the template is applied - lxc start template - lxc file pull template/template - | grep "^name: template$" + inc start template + inc file pull template/template - | grep "^name: template$" # Confirm it's also applied on copies - lxc copy template template1 - lxc start template1 - lxc file pull template1/template - | grep "^name: template1$" - lxc file pull template1/template - | grep "^user.foo: _unset_$" + inc copy template template1 + inc start template1 + inc file pull template1/template - | grep "^name: template1$" + inc file pull template1/template - | grep "^user.foo: _unset_$" # But doesn't change on restart - lxc config set template1 user.foo bar - lxc restart template1 --force - lxc file pull template1/template - | grep "^user.foo: _unset_$" + inc config set template1 user.foo bar + inc restart template1 --force + inc file pull template1/template - | grep "^user.foo: _unset_$" # Cleanup - lxc image delete template-test - lxc delete template template1 --force + inc image delete template-test + inc delete template template1 --force } diff --git a/test/suites/tls_restrictions.sh b/test/suites/tls_restrictions.sh index ef473311a24..7a38ec3bfd8 100644 --- a/test/suites/tls_restrictions.sh +++ b/test/suites/tls_restrictions.sh @@ -1,98 +1,98 @@ test_tls_restrictions() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" - FINGERPRINT=$(lxc config trust list --format csv | cut -d, -f4) + FINGERPRINT=$(inc config trust list --format csv | cut -d, -f4) # Validate admin rights with no restrictions - lxc_remote project create localhost:blah + inc_remote project create localhost:blah # Validate normal view with no restrictions - lxc_remote project list localhost: | grep -q default - lxc_remote project list localhost: | grep -q blah + inc_remote project list localhost: | grep -q default + inc_remote project list localhost: | grep -q blah # Apply restrictions - lxc config trust show "${FINGERPRINT}" | sed -e "s/restricted: false/restricted: true/" | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e "s/restricted: false/restricted: true/" | inc config trust edit "${FINGERPRINT}" # Confirm no project visible when none listed - [ "$(lxc_remote project list localhost: --format csv | wc -l)" = 0 ] + [ "$(inc_remote project list localhost: --format csv | wc -l)" = 0 ] # Allow access to project blah - lxc config trust show "${FINGERPRINT}" | sed -e "s/projects: \[\]/projects: ['blah']/" -e "s/restricted: false/restricted: true/" | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e "s/projects: \[\]/projects: ['blah']/" -e "s/restricted: false/restricted: true/" | inc config trust edit "${FINGERPRINT}" # Validate restricted view - ! lxc_remote project list localhost: | grep -q default || false - lxc_remote project list localhost: | grep -q blah + ! inc_remote project list localhost: | grep -q default || false + inc_remote project list localhost: | grep -q blah - ! lxc_remote project create localhost:blah1 || false + ! inc_remote project create localhost:blah1 || false # Cleanup - lxc config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | lxc config trust edit "${FINGERPRINT}" - lxc project delete blah + inc config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | inc config trust edit "${FINGERPRINT}" + inc project delete blah } test_certificate_edit() { ensure_import_testimage - ensure_has_localhost_remote "${LXD_ADDR}" + ensure_has_localhost_remote "${INCUS_ADDR}" # Generate a certificate openssl req -x509 -newkey ec \ -pkeyopt ec_paramgen_curve:secp384r1 -sha384 -nodes \ - -keyout "${LXD_CONF}/client.key.new" -out "${LXD_CONF}/client.crt.new" \ + -keyout "${INCUS_CONF}/client.key.new" -out "${INCUS_CONF}/client.crt.new" \ -days 3650 -subj "/CN=test.local" - FINGERPRINT=$(lxc config trust list --format csv | cut -d, -f4) + FINGERPRINT=$(inc config trust list --format csv | cut -d, -f4) # Try replacing the own certificate with a new one. # This should succeed as the user is listed as an admin. - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" -X PATCH -d "{\"certificate\":\"$(sed ':a;N;$!ba;s/\n/\\n/g' "${LXD_CONF}/client.crt.new")\"}" "https://${LXD_ADDR}/1.0/certificates/${FINGERPRINT}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" -X PATCH -d "{\"certificate\":\"$(sed ':a;N;$!ba;s/\n/\\n/g' "${INCUS_CONF}/client.crt.new")\"}" "https://${INCUS_ADDR}/1.0/certificates/${FINGERPRINT}" # Record new fingerprint - FINGERPRINT=$(lxc config trust list --format csv | cut -d, -f4) + FINGERPRINT=$(inc config trust list --format csv | cut -d, -f4) - # Move new certificate and key to LXD_CONF and back up old files. - mv "${LXD_CONF}/client.crt" "${LXD_CONF}/client.crt.bak" - mv "${LXD_CONF}/client.key" "${LXD_CONF}/client.key.bak" - mv "${LXD_CONF}/client.crt.new" "${LXD_CONF}/client.crt" - mv "${LXD_CONF}/client.key.new" "${LXD_CONF}/client.key" + # Move new certificate and key to INCUS_CONF and back up old files. + mv "${INCUS_CONF}/client.crt" "${INCUS_CONF}/client.crt.bak" + mv "${INCUS_CONF}/client.key" "${INCUS_CONF}/client.key.bak" + mv "${INCUS_CONF}/client.crt.new" "${INCUS_CONF}/client.crt" + mv "${INCUS_CONF}/client.key.new" "${INCUS_CONF}/client.key" - lxc_remote project create localhost:blah + inc_remote project create localhost:blah # Apply restrictions - lxc config trust show "${FINGERPRINT}" | sed -e "s/restricted: false/restricted: true/" | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e "s/restricted: false/restricted: true/" | inc config trust edit "${FINGERPRINT}" # Add created project to the list of restricted projects. This way, the user will be listed as # a normal user instead of an admin. - lxc config trust show "${FINGERPRINT}" | sed -e "s/projects: \[\]/projects: \[blah\]/" | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e "s/projects: \[\]/projects: \[blah\]/" | inc config trust edit "${FINGERPRINT}" # Try replacing the own certificate with the old one. # This should succeed as well as the own certificate may be changed. - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" -X PATCH -d "{\"certificate\":\"$(sed ':a;N;$!ba;s/\n/\\n/g' "${LXD_CONF}/client.crt.bak")\"}" "https://${LXD_ADDR}/1.0/certificates/${FINGERPRINT}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" -X PATCH -d "{\"certificate\":\"$(sed ':a;N;$!ba;s/\n/\\n/g' "${INCUS_CONF}/client.crt.bak")\"}" "https://${INCUS_ADDR}/1.0/certificates/${FINGERPRINT}" - # Move new certificate and key to LXD_CONF and back up old ones. - mv "${LXD_CONF}/client.crt.bak" "${LXD_CONF}/client.crt" - mv "${LXD_CONF}/client.key.bak" "${LXD_CONF}/client.key" + # Move new certificate and key to INCUS_CONF and back up old ones. + mv "${INCUS_CONF}/client.crt.bak" "${INCUS_CONF}/client.crt" + mv "${INCUS_CONF}/client.key.bak" "${INCUS_CONF}/client.key" # Record new fingerprint - FINGERPRINT=$(lxc config trust list --format csv | cut -d, -f4) + FINGERPRINT=$(inc config trust list --format csv | cut -d, -f4) # Trying to change other fields should fail as a non-admin. - ! lxc_remote config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | lxc_remote config trust edit localhost:"${FINGERPRINT}" || false + ! inc_remote config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | inc_remote config trust edit localhost:"${FINGERPRINT}" || false - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" -X PATCH -d "{\"restricted\": false}" "https://${LXD_ADDR}/1.0/certificates/${FINGERPRINT}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" -X PATCH -d "{\"restricted\": false}" "https://${INCUS_ADDR}/1.0/certificates/${FINGERPRINT}" - ! lxc_remote config trust show "${FINGERPRINT}" | sed -e "s/name:.*/name: foo/" | lxc_remote config trust edit localhost:"${FINGERPRINT}" || false + ! inc_remote config trust show "${FINGERPRINT}" | sed -e "s/name:.*/name: foo/" | inc_remote config trust edit localhost:"${FINGERPRINT}" || false - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" -X PATCH -d "{\"name\": \"bar\"}" "https://${LXD_ADDR}/1.0/certificates/${FINGERPRINT}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" -X PATCH -d "{\"name\": \"bar\"}" "https://${INCUS_ADDR}/1.0/certificates/${FINGERPRINT}" - ! lxc_remote config trust show "${FINGERPRINT}" | sed -e ':a;N;$!ba;s/projects:\n- blah/projects: \[\]/' | lxc_remote config trust edit localhost:"${FINGERPRINT}" || false + ! inc_remote config trust show "${FINGERPRINT}" | sed -e ':a;N;$!ba;s/projects:\n- blah/projects: \[\]/' | inc_remote config trust edit localhost:"${FINGERPRINT}" || false - curl -k -s --cert "${LXD_CONF}/client.crt" --key "${LXD_CONF}/client.key" -X PATCH -d "{\"projects\": []}" "https://${LXD_ADDR}/1.0/certificates/${FINGERPRINT}" + curl -k -s --cert "${INCUS_CONF}/client.crt" --key "${INCUS_CONF}/client.key" -X PATCH -d "{\"projects\": []}" "https://${INCUS_ADDR}/1.0/certificates/${FINGERPRINT}" # Cleanup - lxc config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e "s/restricted: true/restricted: false/" | inc config trust edit "${FINGERPRINT}" - lxc config trust show "${FINGERPRINT}" | sed -e ':a;N;$!ba;s/projects:\n- blah/projects: \[\]/' | lxc config trust edit "${FINGERPRINT}" + inc config trust show "${FINGERPRINT}" | sed -e ':a;N;$!ba;s/projects:\n- blah/projects: \[\]/' | inc config trust edit "${FINGERPRINT}" - lxc project delete blah + inc project delete blah } diff --git a/test/suites/warnings.sh b/test/suites/warnings.sh index 208c102e24c..f5c5c1dc663 100644 --- a/test/suites/warnings.sh +++ b/test/suites/warnings.sh @@ -1,67 +1,67 @@ test_warnings() { # Delete previous warnings - lxc query --wait /1.0/warnings\?recursion=1 | jq -r '.[].uuid' | xargs -n1 lxc warning delete + inc query --wait /1.0/warnings\?recursion=1 | jq -r '.[].uuid' | xargs -n1 inc warning delete # Create a global warning (no node and no project) - lxc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\"}' /internal/testing/warnings + inc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\"}' /internal/testing/warnings # More valid queries - lxc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"project\": \"default\"}' /internal/testing/warnings + inc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"project\": \"default\"}' /internal/testing/warnings # Update the last warning. This will not create a new warning. - lxc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning 2\", \"project\": \"default\"}' /internal/testing/warnings + inc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning 2\", \"project\": \"default\"}' /internal/testing/warnings # There should be two warnings now. - count=$(lxc query --wait /1.0/warnings | jq 'length') + count=$(inc query --wait /1.0/warnings | jq 'length') [ "${count}" -eq 2 ] || false - count=$(lxc query --wait /1.0/warnings\?recursion=1 | jq 'length') + count=$(inc query --wait /1.0/warnings\?recursion=1 | jq 'length') [ "${count}" -eq 2 ] || false # Invalid query (unknown project) - ! lxc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"project\": \"foo\"}' /internal/testing/warnings || false + ! inc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"project\": \"foo\"}' /internal/testing/warnings || false # Invalid query (unknown type code) - ! lxc query --wait -X POST -d '{\"type_code\": 999, \"message\": \"global warning\"}' /internal/testing/warnings || false + ! inc query --wait -X POST -d '{\"type_code\": 999, \"message\": \"global warning\"}' /internal/testing/warnings || false # Both entity type code as entity ID need to be valid otherwise no warning will be created. Note that empty/null values are valid as well. - ! lxc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"entity_type_code\": 0, \"entity_id\": 0}' /internal/testing/warnings || false + ! inc query --wait -X POST -d '{\"type_code\": 0, \"message\": \"global warning\", \"entity_type_code\": 0, \"entity_id\": 0}' /internal/testing/warnings || false ensure_import_testimage # Get image ID from database instead of assuming it - image_id=$(lxd sql global 'select image_id from images_aliases where name="testimage"' | grep -Eo '[[:digit:]]+') + image_id=$(incus sql global 'select image_id from images_aliases where name="testimage"' | grep -Eo '[[:digit:]]+') # Create a warning with entity type "image" and entity ID ${image_id} (the imported testimage) - lxc query --wait -X POST -d "{\\\"type_code\\\": 0, \\\"message\\\": \\\"global warning\\\", \\\"entity_type_code\\\": 1, \\\"entity_id\\\": ${image_id}}" /internal/testing/warnings + inc query --wait -X POST -d "{\\\"type_code\\\": 0, \\\"message\\\": \\\"global warning\\\", \\\"entity_type_code\\\": 1, \\\"entity_id\\\": ${image_id}}" /internal/testing/warnings # There should be three warnings now. - count=$(lxc warning list --format json | jq 'length') + count=$(inc warning list --format json | jq 'length') [ "${count}" -eq 3 ] || false # Test filtering - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/warnings" --data-urlencode "recursion=0" --data-urlencode "filter=status eq new" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/warnings" --data-urlencode "recursion=0" --data-urlencode "filter=status eq new" | jq ".metadata | length") [ "${count}" -eq 3 ] || false - count=$(curl -G --unix-socket "$LXD_DIR/unix.socket" "lxd/1.0/warnings" --data-urlencode "recursion=0" --data-urlencode "filter=status eq resolved" | jq ".metadata | length") + count=$(curl -G --unix-socket "$INCUS_DIR/unix.socket" "incus/1.0/warnings" --data-urlencode "recursion=0" --data-urlencode "filter=status eq resolved" | jq ".metadata | length") [ "${count}" -eq 0 ] || false # Acknowledge a warning - uuid=$(lxc warning list --format json | jq -r '.[] | select(.last_message=="global warning 2") | .uuid') - lxc warning ack "${uuid}" + uuid=$(inc warning list --format json | jq -r '.[] | select(.last_message=="global warning 2") | .uuid') + inc warning ack "${uuid}" # This should hide the acknowledged - count=$(lxc warning list --format json | jq 'length') + count=$(inc warning list --format json | jq 'length') [ "${count}" -eq 2 ] || false # ... unless one uses --all. - count=$(lxc warning list --all --format json | jq 'length') + count=$(inc warning list --all --format json | jq 'length') [ "${count}" -eq 3 ] || false - lxc warning show "${uuid}" | grep "global warning 2" + inc warning show "${uuid}" | grep "global warning 2" # Delete warning - lxc warning rm "${uuid}" - ! lxc warning list | grep -q "${uuid}" || false - ! lxc warning show "${uuid}" || false + inc warning rm "${uuid}" + ! inc warning list | grep -q "${uuid}" || false + ! inc warning show "${uuid}" || false }