Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Wait for global before ready during test #793

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/suite/clusters/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var _ = BeforeSuite(func() {
useExistingCluster := true
testProcessNamespace = fmt.Sprintf("e2e-clusters-%d", GinkgoParallelProcess())
if os.Getenv("TEST_USE_EXISTING_CLUSTER") == "true" {
testTimeout = time.Second * 300
testTimeout = time.Second * 900
testEnv = &envtest.Environment{
UseExistingCluster: &useExistingCluster,
}
Expand Down
49 changes: 49 additions & 0 deletions controllers/suite/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const (
dockerPasswordEnvVar = "DOCKER_PASSWORD"
// DockerRegistryCredentialsSecretName is the name of the k8s secret containing the registry credentials
DockerRegistryCredentialsSecretName = "regcred"

sidecarWaitForGlobalImageVersion = "alpine:20240329"
)

const TestInterval = time.Second * 1
Expand Down Expand Up @@ -173,6 +175,8 @@ func CleanupCluster(ctx context.Context, k8sClient client.Client, hc *humiov1alp

func ConstructBasicNodeSpecForHumioCluster(key types.NamespacedName) humiov1alpha1.HumioNodeSpec {
storageClassNameStandard := "standard"
userID := int64(65534)

nodeSpec := humiov1alpha1.HumioNodeSpec{
Image: controllers.Image,
ExtraKafkaConfigs: "security.protocol=PLAINTEXT",
Expand All @@ -198,6 +202,51 @@ func ConstructBasicNodeSpecForHumioCluster(key types.NamespacedName) humiov1alph
},
},
},
SidecarContainers: []corev1.Container{
{
Name: "wait-for-global-snapshot-on-disk",
Image: sidecarWaitForGlobalImageVersion,
Command: []string{"/bin/sh"},
Args: []string{
"-c",
"trap 'exit 0' 15; while true; do sleep 100 & wait $!; done",
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{
"/bin/sh",
"-c",
"ls /mnt/global*.json",
},
},
},
InitialDelaySeconds: 5,
TimeoutSeconds: 5,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 100,
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "humio-data",
MountPath: "/mnt",
ReadOnly: true,
},
},
SecurityContext: &corev1.SecurityContext{
Privileged: helpers.BoolPtr(false),
AllowPrivilegeEscalation: helpers.BoolPtr(false),
ReadOnlyRootFilesystem: helpers.BoolPtr(true),
RunAsUser: &userID,
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
},
},
},
},
},
EnvironmentVariables: []corev1.EnvVar{
{
Name: "ZOOKEEPER_URL",
Expand Down
2 changes: 1 addition & 1 deletion hack/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ wait_for_pod() {
preload_container_images() {
# Extract humio images and tags from go source
DEFAULT_IMAGE=$(grep '^\s*Image\s*=' controllers/humiocluster_defaults.go | cut -d '"' -f 2)
PRE_UPDATE_IMAGES=$(grep 'Version\s* = ' controllers/suite/clusters/humiocluster_controller_test.go | grep -v oldUnsupportedHumioVersion | grep -v 1.x.x | cut -d '"' -f 2 | sort -u)
PRE_UPDATE_IMAGES=$(grep -R 'Version\s* = ' controllers/suite | grep -v oldUnsupportedHumioVersion | grep -v 1.x.x | cut -d '"' -f 2 | sort -u)

# Preload default image used by tests
$docker pull $DEFAULT_IMAGE
Expand Down
Loading