mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-06 17:46:59 +02:00
Some checks failed
default / default (push) Has been cancelled
default / e2e-backups (push) Has been cancelled
default / e2e-forced-removal (push) Has been cancelled
default / e2e-scaling (push) Has been cancelled
default / e2e-short (push) Has been cancelled
default / e2e-short-secureboot (push) Has been cancelled
default / e2e-templates (push) Has been cancelled
default / e2e-upgrades (push) Has been cancelled
default / e2e-workload-proxy (push) Has been cancelled
All test modules were moved under `integration` tag and are now in `internal/integration` folder: no more `cmd/integration-test` executable. New Kres version is able to build the same executable from the tests directory instead. All Omni related flags were renamed, for example `--endpoint` -> `--omni.endpoint`. 2 more functional changes: - Enabled `--test.failfast` for all test runs. - Removed finalizers, which were running if the test has failed. Both of these changes should make it easier to understand the test failure: Talos node logs won't be cluttered with the finalizer tearing down the cluster. Fixes: https://github.com/siderolabs/omni/issues/1171 Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
94 lines
2.4 KiB
Go
94 lines
2.4 KiB
Go
// Copyright (c) 2025 Sidero Labs, Inc.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the LICENSE file.
|
|
|
|
//go:build integration
|
|
|
|
package integration_test
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/cosi-project/runtime/pkg/safe"
|
|
"github.com/siderolabs/talos/pkg/machinery/constants"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/siderolabs/omni/client/api/omni/management"
|
|
"github.com/siderolabs/omni/client/pkg/client"
|
|
clientconsts "github.com/siderolabs/omni/client/pkg/constants"
|
|
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
|
|
)
|
|
|
|
// AssertSomeImagesAreDownloadable verifies generated image download.
|
|
func AssertSomeImagesAreDownloadable(testCtx context.Context, client *client.Client, signer HTTPRequestSignerFunc, httpEndpoint string) TestFunc {
|
|
st := client.Omni().State()
|
|
|
|
return func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
media, err := safe.StateListAll[*omni.InstallationMedia](testCtx, st)
|
|
require.NoError(t, err)
|
|
|
|
var images []*omni.InstallationMedia
|
|
|
|
for val := range media.All() {
|
|
spec := val.TypedSpec().Value
|
|
|
|
switch spec.Profile {
|
|
case constants.BoardRPiGeneric:
|
|
fallthrough
|
|
case "aws":
|
|
fallthrough
|
|
case "iso":
|
|
images = append(images, val)
|
|
}
|
|
}
|
|
|
|
require.Greater(t, len(images), 2)
|
|
|
|
for _, image := range images {
|
|
t.Run(image.Metadata().ID(), func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx, cancel := context.WithTimeout(testCtx, time.Minute*5)
|
|
defer cancel()
|
|
|
|
u, err := url.Parse(httpEndpoint)
|
|
require.NoError(t, err)
|
|
|
|
schematic, err := client.Management().CreateSchematic(ctx, &management.CreateSchematicRequest{
|
|
MediaId: image.Metadata().ID(),
|
|
TalosVersion: clientconsts.DefaultTalosVersion,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
u.Path, err = url.JoinPath(u.Path, "image", schematic.SchematicId, clientconsts.DefaultTalosVersion, image.Metadata().ID())
|
|
require.NoError(t, err)
|
|
|
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, signer(ctx, req))
|
|
|
|
resp, err := http.DefaultClient.Do(req)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, http.StatusOK, resp.StatusCode)
|
|
|
|
n, err := io.Copy(io.Discard, resp.Body)
|
|
require.NoError(t, err)
|
|
|
|
require.Greater(t, n, int64(1024*1024))
|
|
|
|
require.NoError(t, resp.Body.Close())
|
|
})
|
|
}
|
|
}
|
|
}
|