mirror of https://github.com/k3s-io/k3s
[Release-1.22] Testing Directory rework and cert rotation test (#5761)
* Testing directory rework * New cert rotation test * Remove unnecessary e2e go.mod * Move cgroup and install tests out of the vagrant directory * Remove unit test from Drone Signed-off-by: Derek Nola <derek.nola@suse.com>pull/5779/head
parent
bb0cdd929a
commit
a58d9f6a70
|
@ -6,7 +6,7 @@ on:
|
|||
- "channel.yaml"
|
||||
- "install.sh"
|
||||
- "tests/**"
|
||||
- "!tests/vagrant/cgroup/**"
|
||||
- "!tests/cgroup/**"
|
||||
- ".github/**"
|
||||
- "!.github/workflows/cgroup.yaml"
|
||||
pull_request:
|
||||
|
@ -15,7 +15,7 @@ on:
|
|||
- "channel.yaml"
|
||||
- "install.sh"
|
||||
- "tests/**"
|
||||
- "!tests/vagrant/cgroup/**"
|
||||
- "!tests/cgroup/**"
|
||||
- ".github/**"
|
||||
- "!.github/workflows/cgroup.yaml"
|
||||
workflow_dispatch: {}
|
||||
|
@ -47,7 +47,7 @@ jobs:
|
|||
max-parallel: 1
|
||||
defaults:
|
||||
run:
|
||||
working-directory: tests/vagrant/cgroup/${{ matrix.mode }}/${{ matrix.vm }}
|
||||
working-directory: tests/cgroup/${{ matrix.mode }}/${{ matrix.vm }}
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v2
|
||||
|
@ -61,7 +61,7 @@ jobs:
|
|||
path: |
|
||||
~/.vagrant.d/boxes
|
||||
~/.vagrant.d/gems
|
||||
key: cgroup-${{ hashFiles(format('tests/vagrant/cgroup/{0}/{1}/Vagrantfile', matrix.mode, matrix.vm)) }}
|
||||
key: cgroup-${{ hashFiles(format('tests/cgroup/{0}/{1}/Vagrantfile', matrix.mode, matrix.vm)) }}
|
||||
id: vagrant-cache
|
||||
continue-on-error: true
|
||||
- name: "Vagrant Plugin(s)"
|
||||
|
|
|
@ -5,12 +5,12 @@ on:
|
|||
paths:
|
||||
- "channel.yaml"
|
||||
- "install.sh"
|
||||
- "tests/vagrant/install/**"
|
||||
- "tests/install/**"
|
||||
pull_request:
|
||||
branches: [release-1.22]
|
||||
paths:
|
||||
- "install.sh"
|
||||
- "tests/vagrant/install/**"
|
||||
- "tests/install/**"
|
||||
workflow_dispatch: {}
|
||||
jobs:
|
||||
test:
|
||||
|
@ -31,7 +31,7 @@ jobs:
|
|||
max-parallel: 2
|
||||
defaults:
|
||||
run:
|
||||
working-directory: tests/vagrant/install/${{ matrix.vm }}
|
||||
working-directory: tests/install/${{ matrix.vm }}
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v2
|
||||
|
@ -46,7 +46,7 @@ jobs:
|
|||
path: |
|
||||
~/.vagrant.d/boxes
|
||||
~/.vagrant.d/gems
|
||||
key: install-${{ hashFiles(format('tests/vagrant/install/{0}/Vagrantfile', matrix.vm)) }}
|
||||
key: install-${{ hashFiles(format('tests/install/{0}/Vagrantfile', matrix.vm)) }}
|
||||
id: vagrant-cache
|
||||
continue-on-error: true
|
||||
- name: "Vagrant Plugin(s)"
|
||||
|
|
|
@ -5,7 +5,8 @@ on:
|
|||
- "**.md"
|
||||
- "channel.yaml"
|
||||
- "install.sh"
|
||||
- "tests/vagrant/**"
|
||||
- "tests/install/**"
|
||||
- "tests/cgroup/**"
|
||||
- ".github/**"
|
||||
- "!.github/workflows/unitcoverage.yaml"
|
||||
pull_request:
|
||||
|
@ -13,7 +14,8 @@ on:
|
|||
- "**.md"
|
||||
- "channel.yaml"
|
||||
- "install.sh"
|
||||
- "tests/vagrant/**"
|
||||
- "tests/install/**"
|
||||
- "tests/cgroup/**"
|
||||
- ".github/**"
|
||||
- "!.github/workflows/unitcoverage.yaml"
|
||||
workflow_dispatch: {}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"github.com/k3s-io/k3s/pkg/clientaccess"
|
||||
"github.com/k3s-io/k3s/pkg/daemons/config"
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests"
|
||||
"github.com/robfig/cron/v3"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"go.etcd.io/etcd/server/v3/etcdserver"
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package flock_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/k3s-io/k3s/pkg/flock"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
const lockfile = "/tmp/testlock.test"
|
||||
|
||||
var lock int
|
||||
var _ = Describe("file locks", func() {
|
||||
When("a new exclusive lock is created", func() {
|
||||
It("starts up with no problems", func() {
|
||||
var err error
|
||||
lock, err = flock.Acquire(lockfile)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
It("has a write lock on the file", func() {
|
||||
Expect(flock.CheckLock(lockfile)).To(BeTrue())
|
||||
})
|
||||
It("release the lock correctly", func() {
|
||||
Expect(flock.Release(lock)).To(Succeed())
|
||||
Expect(flock.CheckLock(lockfile)).To(BeFalse())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func TestFlock(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Flock Suite")
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
//go:build linux || darwin || freebsd || openbsd || netbsd || dragonfly
|
||||
// +build linux darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
package flock
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_UnitFlock(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
wantCheck bool
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Basic Flock Test",
|
||||
path: "/tmp/testlock.test",
|
||||
|
||||
wantCheck: true,
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
lock, err := Acquire(tt.path)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Acquire() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
if got := CheckLock(tt.path); got != tt.wantCheck {
|
||||
t.Errorf("CheckLock() = %+v\nWant = %+v", got, tt.wantCheck)
|
||||
}
|
||||
|
||||
if err := Release(lock); (err != nil) != tt.wantErr {
|
||||
t.Errorf("Release() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
|
||||
if got := CheckLock(tt.path); got == tt.wantCheck {
|
||||
t.Errorf("CheckLock() = %+v\nWant = %+v", got, !tt.wantCheck)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -8,16 +8,22 @@ OUTFILE="./dist/artifacts/k3s-int-tests.yaml"
|
|||
|
||||
# Compile all integration tests and containerize them
|
||||
mkdir -p dist/artifacts
|
||||
go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-1.test ./tests/integration/... -run Integration
|
||||
|
||||
# Integration tests under /pkg
|
||||
PKG_TO_TEST=$(find ./pkg/ -type f -name "*_int_test.go" | sed -r 's|/[^/]+$||' |sort -u)
|
||||
INDEX=1
|
||||
for i in $PKG_TO_TEST; do
|
||||
echo $i
|
||||
go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$INDEX.test $i -run Integration
|
||||
INDEX=$(expr $INDEX + 1)
|
||||
name=$(echo "${i##*/}")
|
||||
echo $name
|
||||
go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/integration.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration
|
||||
done
|
||||
|
||||
# Integration tests under /tests
|
||||
PKG_TO_TEST=$(find ./tests/integration -type f -name "*_int_test.go" | sed -r 's|/[^/]+$||' |sort -u)
|
||||
for i in $PKG_TO_TEST; do
|
||||
name=$(echo "${i##*/}")
|
||||
echo $name
|
||||
go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/integration.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration
|
||||
done
|
||||
go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$INDEX.test ./tests/integration/... -run Integration
|
||||
docker build -f ./tests/integration/Dockerfile.test -t $REPO .
|
||||
docker save $REPO -o ./dist/artifacts/$REPO.tar
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ docker ps
|
|||
|
||||
# ---
|
||||
|
||||
. ./scripts/test-unit
|
||||
echo "Did test-unit $?"
|
||||
|
||||
. ./scripts/test-run-basics
|
||||
echo "Did test-run-basics $?"
|
||||
|
|
|
@ -82,7 +82,7 @@ ginkgo --junit-report=result.xml ./tests/integration/...
|
|||
|
||||
Integration tests can be run on an existing single-node cluster via compile time flag, tests will skip if the server is not configured correctly.
|
||||
```bash
|
||||
go test -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" ./tests/integration/... -run Integration
|
||||
go test -ldflags "-X 'github.com/k3s-io/k3s/tests/integration.existingServer=True'" ./tests/integration/... -run Integration
|
||||
```
|
||||
|
||||
Integration tests can also be run via a [Sonobuoy](https://sonobuoy.io/docs/v0.53.2/) plugin on an existing single-node cluster.
|
||||
|
@ -106,9 +106,9 @@ The sub-directories therein contain fixtures for running simple clusters to asse
|
|||
scenarios. These fixtures are mostly self-contained Vagrantfiles describing single-node installations that are
|
||||
easily spun up with Vagrant for the `libvirt` and `virtualbox` providers:
|
||||
|
||||
- [Control Groups](../tests/vagrant/cgroup) :arrow_right: on any code change
|
||||
- [mode=unified](../tests/vagrant/cgroup/unified) (cgroups v2)
|
||||
- [Fedora 34](../tests/vagrant/cgroup/unified/fedora-34) (rootfull + rootless)
|
||||
- [Control Groups](../tests/cgroup) :arrow_right: on any code change
|
||||
- [mode=unified](../tests/cgroup/unified) (cgroups v2)
|
||||
- [Fedora 34](../tests/cgroup/unified/fedora-34) (rootfull + rootless)
|
||||
|
||||
When adding new smoke test(s) please copy the prevalent style for the `Vagrantfile`.
|
||||
Ideally, the boxes used for additional assertions will support the default `virtualbox` provider which
|
||||
|
@ -143,7 +143,7 @@ These can be set on the CLI or exported before invoking Vagrant:
|
|||
|
||||
The **Install Script** tests can be run by changing to the fixture directory and invoking `vagrant up`, e.g.:
|
||||
```shell
|
||||
cd tests/vagrant/install/centos-8
|
||||
cd tests/install/centos-8
|
||||
vagrant up
|
||||
# the following provisioners are optional. the do not run by default but are invoked
|
||||
# explicitly by github actions workflow to avoid certain timeout issues on slow runners
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#
|
||||
# Vagrant box for testing k3s with cgroup v2.
|
||||
|
||||
ENV['TEST_UNITFILE_ROOTFULL'] ||= '../../../../../k3s.service'
|
||||
ENV['TEST_UNITFILE_ROOTLESS'] ||= '../../../../../k3s-rootless.service'
|
||||
ENV['TEST_UNITFILE_ROOTFULL'] ||= '../../../../k3s.service'
|
||||
ENV['TEST_UNITFILE_ROOTLESS'] ||= '../../../../k3s-rootless.service'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
||||
|
@ -12,7 +12,7 @@ Vagrant.configure("2") do |config|
|
|||
}
|
||||
config.vm.box = "fedora/34-cloud-base"
|
||||
config.vm.boot_timeout = ENV['TEST_VM_BOOT_TIMEOUT'] || 600 # seconds
|
||||
config.vm.synced_folder '../../../../../dist/artifacts', '/vagrant', type: 'rsync', disabled: false,
|
||||
config.vm.synced_folder '../../../../dist/artifacts', '/vagrant', type: 'rsync', disabled: false,
|
||||
rsync__exclude: ENV['RSYNC_EXCLUDE'] || '*.tar.*'
|
||||
|
||||
config.vm.define 'cgroup-unified', primary: true do |test|
|
|
@ -1,10 +0,0 @@
|
|||
module github.com/k3s-io/k3s/tests/e2e
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/kr/pretty v0.2.0 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.1.1
|
||||
github.com/onsi/gomega v1.17.0
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
)
|
109
tests/e2e/go.sum
109
tests/e2e/go.sum
|
@ -1,109 +0,0 @@
|
|||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo/v2 v2.1.1 h1:LCnPB85AvFNr91s0B2aDzEiiIg6MUwLYbryC1NSlWi8=
|
||||
github.com/onsi/ginkgo/v2 v2.1.1/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
@ -2,7 +2,7 @@
|
|||
# vi: set ft=ruby :
|
||||
#
|
||||
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../../install.sh'
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
|
@ -2,7 +2,7 @@
|
|||
# vi: set ft=ruby :
|
||||
#
|
||||
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../../install.sh'
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
|
@ -2,7 +2,7 @@
|
|||
# vi: set ft=ruby :
|
||||
#
|
||||
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../../install.sh'
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
|
@ -2,7 +2,7 @@
|
|||
# vi: set ft=ruby :
|
||||
#
|
||||
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../../install.sh'
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
|
@ -2,7 +2,7 @@
|
|||
# vi: set ft=ruby :
|
||||
#
|
||||
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../../install.sh'
|
||||
ENV['TEST_INSTALL_SH'] ||= '../../../install.sh'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = {
|
|
@ -0,0 +1,92 @@
|
|||
package cert_rotation_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
const tmpdDataDir = "/tmp/certrotationtest"
|
||||
|
||||
var server, server2 *testutil.K3sServer
|
||||
var serverArgs = []string{"--cluster-init", "-t", "test", "-d", tmpdDataDir}
|
||||
var certHash, caCertHash string
|
||||
var testLock int
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
if !testutil.IsExistingServer() {
|
||||
var err error
|
||||
testLock, err = testutil.K3sTestLock()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
server, err = testutil.K3sStartServer(serverArgs...)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
})
|
||||
|
||||
var _ = Describe("certificate rotation", func() {
|
||||
BeforeEach(func() {
|
||||
if testutil.IsExistingServer() && !testutil.ServerArgsPresent(serverArgs) {
|
||||
Skip("Test needs k3s server with: " + strings.Join(serverArgs, " "))
|
||||
}
|
||||
})
|
||||
When("a new server is created", func() {
|
||||
It("starts up with no problems", func() {
|
||||
Eventually(func() error {
|
||||
return testutil.K3sDefaultDeployments()
|
||||
}, "180s", "5s").Should(Succeed())
|
||||
})
|
||||
It("get certificate hash", func() {
|
||||
// get md5sum of the CA certs
|
||||
var err error
|
||||
caCertHash, err = testutil.RunCommand("md5sum " + tmpdDataDir + "/server/tls/client-ca.crt | cut -f 1 -d' '")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
certHash, err = testutil.RunCommand("md5sum " + tmpdDataDir + "/server/tls/serving-kube-apiserver.crt | cut -f 1 -d' '")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
It("stop k3s", func() {
|
||||
Expect(testutil.K3sKillServer(server)).To(Succeed())
|
||||
})
|
||||
It("certificate rotate", func() {
|
||||
_, err := testutil.K3sCmd("certificate", "rotate", "-d", tmpdDataDir)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
})
|
||||
It("start k3s server", func() {
|
||||
var err error
|
||||
server2, err = testutil.K3sStartServer(serverArgs...)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
It("starts up with no problems", func() {
|
||||
Eventually(func() error {
|
||||
return testutil.K3sDefaultDeployments()
|
||||
}, "360s", "5s").Should(Succeed())
|
||||
})
|
||||
It("get certificate hash", func() {
|
||||
// get md5sum of the CA certs
|
||||
var err error
|
||||
caCertHashAfter, err := testutil.RunCommand("md5sum " + tmpdDataDir + "/server/tls/client-ca.crt | cut -f 1 -d' '")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
certHashAfter, err := testutil.RunCommand("md5sum " + tmpdDataDir + "/server/tls/serving-kube-apiserver.crt | cut -f 1 -d' '")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(caCertHash).To(Not(Equal(certHashAfter)))
|
||||
Expect(caCertHash).To(Equal(caCertHashAfter))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
if !testutil.IsExistingServer() {
|
||||
Expect(testutil.K3sKillServer(server)).To(Succeed())
|
||||
Expect(testutil.K3sCleanup(testLock, "")).To(Succeed())
|
||||
Expect(testutil.K3sKillServer(server2)).To(Succeed())
|
||||
Expect(testutil.K3sCleanup(testLock, tmpdDataDir)).To(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
func Test_IntegrationCertRotation(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Cert rotation Suite")
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package integration
|
|||
import (
|
||||
"testing"
|
||||
|
||||
testutil "github.com/k3s-io/k3s/tests/util"
|
||||
testutil "github.com/k3s-io/k3s/tests/integration"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package util
|
||||
package tests
|
||||
|
||||
import (
|
||||
"net"
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Wait for CoreDNS pods to be ready.
|
||||
|
||||
set -x
|
||||
echo "Waiting for CoreDNS pods to be ready..."
|
||||
counter=0
|
||||
# `kubectl wait` fails when the pods with the specified label are not created yet
|
||||
until kubectl wait --for=condition=ready pods --namespace=kube-system -l k8s-app=kube-dns; do
|
||||
((counter++))
|
||||
if [[ $counter -eq 20 ]]; then
|
||||
echo "CoreDNS not running?"
|
||||
kubectl get pods -A
|
||||
kubectl get nodes -o wide
|
||||
exit 1
|
||||
fi
|
||||
sleep 10
|
||||
done
|
|
@ -1 +0,0 @@
|
|||
.vagrant/
|
Loading…
Reference in New Issue