Skip to content

Commit 0d2a5cc

Browse files
committed
Organized tests and removed unnecessary ones
1 parent 6334b00 commit 0d2a5cc

19 files changed

+679
-611
lines changed

integration/add_worker_test.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ var _ = Describe("kismatic install add-worker tests", func() {
1111
BeforeEach(func() {
1212
os.Chdir(kisPath)
1313
})
14-
Context("Targeting AWS infrastructure", func() {
15-
Context("Using Ubuntu 16.04 LTS", func() {
16-
ItOnAWS("should successfully add a new worker", func(provisioner infrastructureProvisioner) {
17-
WithInfrastructure(NodeCount{Worker: 2}, Ubuntu1604LTS, provisioner, func(nodes provisionedNodes, sshKey string) {
18-
theNode := nodes.worker[0]
19-
err := installKismaticMini(theNode, sshKey)
20-
Expect(err).ToNot(HaveOccurred())
2114

22-
newWorker := nodes.worker[1]
23-
err = addWorkerToKismaticMini(newWorker)
24-
Expect(err).ToNot(HaveOccurred())
25-
})
15+
Describe("adding a worker to an existing cluster", func() {
16+
ItOnAWS("should result in a cluster with an additional worker", func(aws infrastructureProvisioner) {
17+
WithInfrastructure(NodeCount{Worker: 2}, CentOS7, aws, func(nodes provisionedNodes, sshKey string) {
18+
theNode := nodes.worker[0]
19+
err := installKismaticMini(theNode, sshKey)
20+
Expect(err).ToNot(HaveOccurred())
21+
22+
newWorker := nodes.worker[1]
23+
err = addWorkerToKismaticMini(newWorker)
24+
Expect(err).ToNot(HaveOccurred())
2625
})
2726
})
2827
})
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package integration
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"time"
7+
8+
. "github.com/onsi/ginkgo"
9+
. "github.com/onsi/gomega"
10+
)
11+
12+
var _ = Describe("disconnected install feature", func() {
13+
BeforeEach(func() {
14+
os.Chdir(kisPath)
15+
})
16+
17+
Describe("Installing on machines with no internet access", func() {
18+
Context("with kismatic packages installed", func() {
19+
ItOnAWS("should install successfully", func(aws infrastructureProvisioner) {
20+
WithMiniInfrastructure(CentOS7, aws, func(node NodeDeets, sshKey string) {
21+
By("Installing the RPMs on the node")
22+
theNode := []NodeDeets{node}
23+
nodes := provisionedNodes{
24+
etcd: theNode,
25+
master: theNode,
26+
worker: theNode,
27+
ingress: theNode,
28+
}
29+
InstallKismaticPackages(nodes, CentOS7, sshKey)
30+
31+
By("Verifying connectivity to google.com")
32+
err := runViaSSH([]string{"curl --head www.google.com"}, theNode, sshKey, 1*time.Minute)
33+
FailIfError(err, "Failed to curl google")
34+
35+
By("Blocking all outbound connections")
36+
allowPorts := "8888,2379,6666,2380,6660,6443,8443,80,443" // ports needed/checked by inspector
37+
cmd := []string{
38+
"sudo iptables -A OUTPUT -o lo -j ACCEPT", // allow loopback
39+
"sudo iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT", // allow SSH
40+
fmt.Sprintf("sudo iptables -A OUTPUT -p tcp --match multiport --sports %s -j ACCEPT", allowPorts), // allow inspector
41+
"sudo iptables -A OUTPUT -s 172.16.0.0/16 -j ACCEPT",
42+
"sudo iptables -A OUTPUT -d 172.16.0.0/16 -j ACCEPT", // Allow pod network
43+
"sudo iptables -P OUTPUT DROP", // drop everything else
44+
}
45+
err = runViaSSH(cmd, theNode, sshKey, 1*time.Minute)
46+
FailIfError(err, "Failed to create iptable rule")
47+
48+
By("Verifying that connections are blocked")
49+
err = runViaSSH([]string{"curl --max-time 5 www.google.com"}, theNode, sshKey, 1*time.Minute)
50+
if err == nil {
51+
Fail("was able to ping google with outgoing connections blocked")
52+
}
53+
54+
By("Running kismatic install apply")
55+
installOpts := installOptions{
56+
allowPackageInstallation: false,
57+
modifyHostsFiles: true,
58+
autoConfigureDockerRegistry: true,
59+
}
60+
err = installKismatic(nodes, installOpts, sshKey)
61+
Expect(err).ToNot(HaveOccurred())
62+
})
63+
})
64+
})
65+
})
66+
})

integration/docker_registry_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package integration
2+
3+
import (
4+
"os"
5+
6+
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
var _ = Describe("kismatic docker registry feature", func() {
11+
BeforeEach(func() {
12+
os.Chdir(kisPath)
13+
})
14+
15+
Describe("enabling the internal docker registry feature", func() {
16+
ItOnAWS("should install successfully", func(aws infrastructureProvisioner) {
17+
WithInfrastructure(NodeCount{1, 1, 1, 0, 0}, CentOS7, aws, func(nodes provisionedNodes, sshKey string) {
18+
opts := installOptions{
19+
allowPackageInstallation: true,
20+
autoConfigureDockerRegistry: true,
21+
}
22+
err := installKismatic(nodes, opts, sshKey)
23+
Expect(err).ToNot(HaveOccurred())
24+
})
25+
})
26+
})
27+
28+
Describe("using an existing private docker registry", func() {
29+
ItOnAWS("should install successfully", func(aws infrastructureProvisioner) {
30+
WithInfrastructure(NodeCount{1, 1, 1, 0, 0}, CentOS7, aws, func(nodes provisionedNodes, sshKey string) {
31+
By("Installing an external Docker registry on one of the nodes")
32+
dockerRegistryPort := 8443
33+
caFile, err := deployDockerRegistry(nodes.etcd[0], dockerRegistryPort, sshKey)
34+
Expect(err).ToNot(HaveOccurred())
35+
installOpts := installOptions{
36+
allowPackageInstallation: true,
37+
dockerRegistryCAPath: caFile,
38+
dockerRegistryIP: nodes.etcd[0].PrivateIP,
39+
dockerRegistryPort: dockerRegistryPort,
40+
}
41+
err = installKismatic(nodes, installOpts, sshKey)
42+
Expect(err).ToNot(HaveOccurred())
43+
})
44+
})
45+
})
46+
})

integration/framework.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@ import (
77

88
// ItOnAWS runs a spec if the AWS details have been provided
99
func ItOnAWS(description string, f func(infrastructureProvisioner)) {
10-
It(description, func() {
11-
awsClient, ok := AWSClientFromEnvironment()
12-
if !ok {
13-
Skip("AWS environment variables were not defined")
14-
}
15-
f(awsClient)
10+
Context("When using AWS infrastructure [aws]", func() {
11+
It(description, func() {
12+
awsClient, ok := AWSClientFromEnvironment()
13+
if !ok {
14+
Skip("AWS environment variables were not defined")
15+
}
16+
f(awsClient)
17+
})
1618
})
1719
}
1820

1921
// ItOnPacket runs a spec if the Packet.Net details have been provided
2022
func ItOnPacket(description string, f func(infrastructureProvisioner)) {
21-
It(description, func() {
22-
packetClient, ok := packetClientFromEnv()
23-
if !ok {
24-
Skip("Packet environment variables were not defined")
25-
}
26-
f(packetClient)
23+
Context("When using Packet.net infrastructure [packet]", func() {
24+
It(description, func() {
25+
packetClient, ok := packetClientFromEnv()
26+
if !ok {
27+
Skip("Packet environment variables were not defined")
28+
}
29+
f(packetClient)
30+
})
2731
})
2832
}
2933

integration/glide.lock

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration/hosts_file_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package integration
2+
3+
import (
4+
"os"
5+
6+
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
var _ = Describe("hosts file modification feature", func() {
11+
BeforeEach(func() {
12+
os.Chdir(kisPath)
13+
})
14+
15+
Describe("enabling the hosts file modification feature", func() {
16+
ItOnAWS("should result in a functional cluster", func(aws infrastructureProvisioner) {
17+
WithInfrastructure(NodeCount{1, 1, 2, 0, 0}, CentOS7, aws, func(nodes provisionedNodes, sshKey string) {
18+
By("Setting the hostnames to be different than the actual ones")
19+
loadBalancedFQDN := nodes.master[0].PublicIP
20+
nodes.etcd[0].Hostname = "etcd01"
21+
nodes.master[0].Hostname = "master01"
22+
nodes.worker[0].Hostname = "worker01"
23+
nodes.worker[1].Hostname = "worker02"
24+
25+
plan := PlanAWS{
26+
AllowPackageInstallation: true,
27+
Etcd: nodes.etcd,
28+
Master: nodes.master,
29+
MasterNodeFQDN: loadBalancedFQDN,
30+
MasterNodeShortName: loadBalancedFQDN,
31+
Worker: nodes.worker[0:1],
32+
SSHKeyFile: sshKey,
33+
SSHUser: nodes.master[0].SSHUser,
34+
ModifyHostsFiles: true,
35+
}
36+
37+
By("Installing kismatic with bogus hostnames that are added to hosts files")
38+
err := installKismaticWithPlan(plan, sshKey)
39+
Expect(err).ToNot(HaveOccurred())
40+
41+
By("Adding a worker with a bogus hostname that is added to hosts files")
42+
err = addWorkerToKismaticMini(nodes.worker[1])
43+
Expect(err).ToNot(HaveOccurred())
44+
})
45+
})
46+
})
47+
})

0 commit comments

Comments
 (0)