Revision 63db7a3c1374a8c26f7b316d3aa2b54a12549676 authored by André Martins on 20 May 2021, 12:46:46 UTC, committed by André Martins on 20 May 2021, 13:17:44 UTC
`docker.io/cilium/cilium:v1.10.0@sha256:587627d909ffe0418c0bd907516496844867a21812946af82096d367760e4c1e`
`quay.io/cilium/cilium:v1.10.0@sha256:587627d909ffe0418c0bd907516496844867a21812946af82096d367760e4c1e`

`docker.io/cilium/clustermesh-apiserver:v1.10.0@sha256:c5dbcb2708529e4a3ccc007183d99c5171df5ee1db7e7218d48d7660c8158193`
`quay.io/cilium/clustermesh-apiserver:v1.10.0@sha256:c5dbcb2708529e4a3ccc007183d99c5171df5ee1db7e7218d48d7660c8158193`

`docker.io/cilium/docker-plugin:v1.10.0@sha256:52ccc5f5ab5d791c6f6b89dc57f7f0c2c202dfaef044dc61d4e276e693d43851`
`quay.io/cilium/docker-plugin:v1.10.0@sha256:52ccc5f5ab5d791c6f6b89dc57f7f0c2c202dfaef044dc61d4e276e693d43851`

`docker.io/cilium/hubble-relay:v1.10.0@sha256:e92e6778c71aa9e181618d61e9403761ad061c3960a9203aa2cf8e6cde95c9d7`
`quay.io/cilium/hubble-relay:v1.10.0@sha256:e92e6778c71aa9e181618d61e9403761ad061c3960a9203aa2cf8e6cde95c9d7`

`docker.io/cilium/operator-alibabacloud:v1.10.0@sha256:ab68157bd70c6158ec5fc03f17de81639d5a3ee7acd64120c2788354fa6f1cfc`
`quay.io/cilium/operator-alibabacloud:v1.10.0@sha256:ab68157bd70c6158ec5fc03f17de81639d5a3ee7acd64120c2788354fa6f1cfc`

`docker.io/cilium/operator-aws:v1.10.0@sha256:c704c40862aa8eecd6ba66d456701f7514b9db57ae956a8e22f640eea89003ed`
`quay.io/cilium/operator-aws:v1.10.0@sha256:c704c40862aa8eecd6ba66d456701f7514b9db57ae956a8e22f640eea89003ed`

`docker.io/cilium/operator-azure:v1.10.0@sha256:eed06e79fd5efed2fc9ccebd98e5c38c610429334389a3da939a40f701c1f399`
`quay.io/cilium/operator-azure:v1.10.0@sha256:eed06e79fd5efed2fc9ccebd98e5c38c610429334389a3da939a40f701c1f399`

`docker.io/cilium/operator-generic:v1.10.0@sha256:65143311a62a95dbe23c69ff2f624e0fdf030eb225e6375d889da66a955dd828`
`quay.io/cilium/operator-generic:v1.10.0@sha256:65143311a62a95dbe23c69ff2f624e0fdf030eb225e6375d889da66a955dd828`

`docker.io/cilium/operator:v1.10.0@sha256:d0ec430f14a39e0993abef058176c8e41387b58b4354e4bf658af47411867be7`
`quay.io/cilium/operator:v1.10.0@sha256:d0ec430f14a39e0993abef058176c8e41387b58b4354e4bf658af47411867be7`

Signed-off-by: André Martins <andre@cilium.io>
1 parent 952d9d3
Raw File
kvstore_watchdog_test.go
// Copyright 2020 Authors of Cilium
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !privileged_tests

package main

import (
	"reflect"
	"testing"

	"github.com/cilium/cilium/pkg/kvstore"
)

func Test_getOldestLeases(t *testing.T) {
	type args struct {
		m map[string]kvstore.Value
	}
	tests := []struct {
		name string
		args args
		want map[string]kvstore.Value
	}{
		{
			name: "test-1",
			args: args{
				m: map[string]kvstore.Value{},
			},
			want: map[string]kvstore.Value{},
		},
		{
			name: "test-2",
			args: args{
				m: map[string]kvstore.Value{
					"foo/bar/1": {
						Data:        nil,
						ModRevision: 1,
						LeaseID:     1,
					},
					"foo/bar/2": {
						Data:        nil,
						ModRevision: 2,
						LeaseID:     2,
					},
					"foo/bar/3": {
						Data:        nil,
						ModRevision: 3,
						LeaseID:     3,
					},
					"foo/bar/4": {
						Data:        nil,
						ModRevision: 4,
						LeaseID:     4,
					},
					"foo/bar/5": {
						Data:        nil,
						ModRevision: 5,
						LeaseID:     5,
					},
					"foo/baz/6": {
						Data:        nil,
						ModRevision: 6,
						LeaseID:     6,
					},
					"foo/bbz/7": {
						Data:        nil,
						ModRevision: 3,
						LeaseID:     3,
					},
				},
			},
			want: map[string]kvstore.Value{
				"foo/bar/1": {
					Data:        nil,
					ModRevision: 1,
					LeaseID:     1,
				},
				"foo/baz/6": {
					Data:        nil,
					ModRevision: 6,
					LeaseID:     6,
				},
				"foo/bbz/7": {
					Data:        nil,
					ModRevision: 3,
					LeaseID:     3,
				},
			},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := getOldestLeases(tt.args.m); !reflect.DeepEqual(got, tt.want) {
				t.Errorf("getOldestLeases() = %v, want %v", got, tt.want)
			}
		})
	}
}

func Test_getPath(t *testing.T) {
	type args struct {
		k string
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{
			name: "test-1",
			args: args{
				k: "cilium/state/identities/v1/locks/" +
					"k8s:io.cilium.k8s.policy.cluster=default;" +
					"k8s:io.cilium.k8s.policy.serviceaccount=default;" +
					"k8s:io.kubernetes.pod.namespace=default;k8s:k8s-app.guestbook=redis;" +
					"k8s:role=master;" +
					"/29c66fd840fa06f7",
			},
			want: "cilium/state/identities/v1/locks/" +
				"k8s:io.cilium.k8s.policy.cluster=default;" +
				"k8s:io.cilium.k8s.policy.serviceaccount=default;" +
				"k8s:io.kubernetes.pod.namespace=default;k8s:k8s-app.guestbook=redis;" +
				"k8s:role=master;",
		},
		{
			name: "test-2",
			args: args{
				k: "cilium/state/identities/v1/locks/" +
					"k8s:io.cilium.k8s.policy.cluster=default;" +
					"k8s:role=master/////;" +
					"/29c66fd840fa06f7",
			},
			want: "cilium/state/identities/v1/locks/" +
				"k8s:io.cilium.k8s.policy.cluster=default;" +
				"k8s:role=master/////;",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := keyPathFromLockPath(tt.args.k); got != tt.want {
				t.Errorf("keyPathFromLockPath() = %v, want %v", got, tt.want)
			}
		})
	}
}
back to top