Skip to content

Commit

Permalink
chore: add tests for zfs extension
Browse files Browse the repository at this point in the history
Add tests for ZFS and btrfs extensions.
Also fix the e2e-aws cron pipeline.

Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
frezbo committed Aug 23, 2023
1 parent cb468c4 commit 8338959
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 113 deletions.
3 changes: 2 additions & 1 deletion .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ local integration_extensions = Step('e2e-extensions', target='e2e-qemu', privile
QEMU_MEMORY_WORKERS: '4096',
WITH_CONFIG_PATCH_WORKER: '@_out/extensions-patch.json',
IMAGE_REGISTRY: local_registry,
QEMU_EXTRA_DISKS: '1',
EXTRA_TEST_ARGS: '-talos.extensions.testtype=qemu',
});
local integration_cilium = Step('e2e-cilium', target='e2e-qemu', privileged=true, depends_on=[load_artifacts], environment={
Expand Down Expand Up @@ -718,7 +719,7 @@ local e2e_pipelines = [
Pipeline('e2e-gcp', default_pipeline_steps + [capi_docker, e2e_capi, e2e_gcp]) + e2e_trigger(['e2e-gcp']),

// cron pipelines, triggered on schedule events
Pipeline('cron-e2e-aws', default_pipeline_steps + [capi_docker, e2e_capi, e2e_aws], [default_cron_pipeline]) + cron_trigger(['thrice-daily', 'nightly']),
Pipeline('cron-e2e-aws', default_pipeline_steps + [e2e_aws_prepare, tf_apply, e2e_aws_tf_apply_post, e2e_aws, tf_destroy], [default_cron_pipeline]) + cron_trigger(['thrice-daily', 'nightly']),
Pipeline('cron-e2e-gcp', default_pipeline_steps + [capi_docker, e2e_capi, e2e_gcp], [default_cron_pipeline]) + cron_trigger(['thrice-daily', 'nightly']),
];

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CLOUD_IMAGES_EXTRA_ARGS ?= ""

ARTIFACTS := _out
TOOLS ?= ghcr.io/siderolabs/tools:v1.5.0
PKGS ?= v1.6.0-alpha.0-5-g7717b7e
PKGS ?= v1.6.0-alpha.0-7-g2e1c0b9
EXTRAS ?= v1.5.0
# renovate: datasource=github-tags depName=golang/go
GO_VERSION ?= 1.20
Expand Down
3 changes: 3 additions & 0 deletions hack/test/extensions/extension-patch-filter.jq
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
{
"name": "ax88796b"
},
{
"name": "btrfs"
},
{
"name": "cdc_ether"
},
Expand Down
60 changes: 2 additions & 58 deletions internal/integration/api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ package api

import (
"bufio"
"bytes"
"context"
"strings"
"time"

"github.com/siderolabs/go-retry/retry"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/kubectl/pkg/scheme"

"github.com/siderolabs/talos/internal/integration/base"
"github.com/siderolabs/talos/pkg/machinery/client"
Expand Down Expand Up @@ -132,67 +128,15 @@ file locks (-x) unlimited
suite.Require().NoError(err)

// wait for the pod to be ready
suite.Require().NoError(retry.Constant(8*time.Minute, retry.WithUnits(time.Second*10)).Retry(
func() error {
pod, podErr := suite.Clientset.CoreV1().Pods("default").Get(suite.ctx, "defaults-test", metav1.GetOptions{})
if podErr != nil {
return retry.ExpectedErrorf("error getting pod: %s", podErr)
}

if pod.Status.Phase != corev1.PodRunning {
return retry.ExpectedErrorf("pod is not running yet: %s", pod.Status.Phase)
}

return nil
},
))
suite.Require().NoError(suite.WaitForPodToBeRunning(suite.ctx, 10*time.Minute, "default", "defaults-test"))

stdout, stderr, err := suite.executeRemoteCommand("default", "defaults-test", "ulimit -c -d -e -f -l -m -n -q -r -s -t -v -x")
stdout, stderr, err := suite.ExecuteCommandInPod(suite.ctx, "default", "defaults-test", "ulimit -c -d -e -f -l -m -n -q -r -s -t -v -x")
suite.Require().NoError(err)

suite.Require().Equal("", stderr)
suite.Require().Equal(strings.TrimPrefix(expectedUlimit, "\n"), stdout)
}

func (suite *CommonSuite) executeRemoteCommand(namespace, podName, command string) (string, string, error) {
cmd := []string{
"/bin/sh",
"-c",
command,
}
req := suite.Clientset.CoreV1().RESTClient().Post().Resource("pods").Name(podName).
Namespace(namespace).SubResource("exec")
option := &corev1.PodExecOptions{
Command: cmd,
Stdin: false,
Stdout: true,
Stderr: true,
TTY: false,
}

req.VersionedParams(
option,
scheme.ParameterCodec,
)

exec, err := remotecommand.NewSPDYExecutor(suite.RestConfig, "POST", req.URL())
if err != nil {
return "", "", err
}

var stdout, stderr bytes.Buffer

err = exec.StreamWithContext(suite.ctx, remotecommand.StreamOptions{
Stdout: &stdout,
Stderr: &stderr,
})
if err != nil {
return "", "", err
}

return stdout.String(), stderr.String(), nil
}

func init() {
allSuites = append(allSuites, &CommonSuite{})
}
Loading

0 comments on commit 8338959

Please sign in to comment.