@@ -38,9 +38,14 @@ var _ = Describe("KernelIPv6", func() {
3838
3939 When ("grub.cfg disables IPv6" , func () {
4040 When ("grub path is /boot/grub/grub.cfg" , func () {
41+ const boshSysctlPath = "/etc/sysctl.d/60-bosh-sysctl.conf"
4142 const grubPath = "/boot/grub/grub.cfg"
43+
4244 BeforeEach (func () {
43- err := fs .WriteFileString (grubPath , "before ipv6.disable=1 after" )
45+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=1\n net.ipv6.conf.default.disable_ipv6=1" )
46+ Expect (err ).ToNot (HaveOccurred ())
47+
48+ err = fs .WriteFileString (grubPath , "before ipv6.disable=1 after" )
4449 Expect (err ).ToNot (HaveOccurred ())
4550 })
4651
@@ -55,6 +60,7 @@ var _ = Describe("KernelIPv6", func() {
5560 Expect (act ()).ToNot (HaveOccurred ())
5661 Expect (cmdRunner .RunCommands ).To (Equal ([][]string {{"shutdown" , "-r" , "now" }}))
5762 })
63+
5864 It ("returns an error if update to " + grubPath + " fails" , func () {
5965 fs .WriteFileError = errors .New ("fake-err" )
6066
@@ -72,11 +78,45 @@ var _ = Describe("KernelIPv6", func() {
7278 Expect (err ).To (HaveOccurred ())
7379 Expect (err .Error ()).To (ContainSubstring ("fake-err" ))
7480 })
81+
82+ When ("60-bosh-sysctl.conf disables IPv6" , func () {
83+ It ("changes net.ipv6.conf.all.disable_ipv6=1 to net.ipv6.conf.all.disable_ipv6=0 from " + boshSysctlPath , func () {
84+ stopCh <- struct {}{}
85+ Expect (act ()).ToNot (HaveOccurred ())
86+ Expect (fs .ReadFileString (boshSysctlPath )).To (Equal ("net.ipv6.conf.all.disable_ipv6=0\n net.ipv6.conf.default.disable_ipv6=0" ))
87+ })
88+ })
89+
90+ When ("60-bosh-sysctl.conf enables IPv6" , func () {
91+ BeforeEach (func () {
92+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=0\n net.ipv6.conf.default.disable_ipv6=0" )
93+ Expect (err ).ToNot (HaveOccurred ())
94+ })
95+
96+ It ("does not change " + boshSysctlPath , func () {
97+ stopCh <- struct {}{}
98+ Expect (act ()).ToNot (HaveOccurred ())
99+ Expect (fs .ReadFileString (boshSysctlPath )).To (Equal ("net.ipv6.conf.all.disable_ipv6=0\n net.ipv6.conf.default.disable_ipv6=0" ))
100+ })
101+ })
75102 })
103+
104+ When ("60-bosh-sysctl.conf does not exist" , func () {
105+ It ("returns an error" , func () {
106+ err := act ()
107+ Expect (err ).To (HaveOccurred ())
108+ })
109+ })
110+
76111 When ("grub path is /boot/efi/EFI/grub/grub.cfg" , func () {
112+ const boshSysctlPath = "/etc/sysctl.d/60-bosh-sysctl.conf"
77113 const grubPath = "/boot/efi/EFI/grub/grub.cfg"
114+
78115 BeforeEach (func () {
79- err := fs .WriteFileString (grubPath , "before ipv6.disable=1 after" )
116+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=1\n net.ipv6.conf.default.disable_ipv6=1" )
117+ Expect (err ).ToNot (HaveOccurred ())
118+
119+ err = fs .WriteFileString (grubPath , "before ipv6.disable=1 after" )
80120 Expect (err ).ToNot (HaveOccurred ())
81121 })
82122
@@ -112,8 +152,13 @@ var _ = Describe("KernelIPv6", func() {
112152 })
113153
114154 When ("/boot/grub/grub.cfg doesn't exist but /boot/efi/EFI/grub/grub.cfg does" , func () {
155+ const boshSysctlPath = "/etc/sysctl.d/60-bosh-sysctl.conf"
156+
115157 BeforeEach (func () {
116- err := fs .WriteFileString ("/boot/efi/EFI/grub/grub.cfg" , "before ipv6.disable=1 after" )
158+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=1\n net.ipv6.conf.default.disable_ipv6=1" )
159+ Expect (err ).ToNot (HaveOccurred ())
160+
161+ err = fs .WriteFileString ("/boot/efi/EFI/grub/grub.cfg" , "before ipv6.disable=1 after" )
117162 Expect (err ).ToNot (HaveOccurred ())
118163 })
119164 It ("does not return an error if it fails to read /boot/grub/grub.cfg" , func () {
@@ -129,8 +174,13 @@ var _ = Describe("KernelIPv6", func() {
129174 })
130175
131176 When ("neither /boot/grub/grub.cfg nor /boot/efi/EFI/grub/grub.cfg exists" , func () {
177+ const boshSysctlPath = "/etc/sysctl.d/60-bosh-sysctl.conf"
178+
132179 It ("returns an error" , func () {
133- err := act ()
180+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=1\n net.ipv6.conf.default.disable_ipv6=1" )
181+ Expect (err ).ToNot (HaveOccurred ())
182+
183+ err = act ()
134184 Expect (err ).To (HaveOccurred ())
135185 })
136186 })
@@ -140,8 +190,13 @@ var _ = Describe("KernelIPv6", func() {
140190 "/boot/efi/EFI/grub/grub.cfg" ,
141191 } {
142192 When (grubPath + " allows IPv6" , func () {
193+ const boshSysctlPath = "/etc/sysctl.d/60-bosh-sysctl.conf"
194+
143195 BeforeEach (func () {
144- err := fs .WriteFileString (grubPath , "before after" )
196+ err := fs .WriteFileString (boshSysctlPath , "net.ipv6.conf.all.disable_ipv6=1\n net.ipv6.conf.default.disable_ipv6=1" )
197+ Expect (err ).ToNot (HaveOccurred ())
198+
199+ err = fs .WriteFileString (grubPath , "before after" )
145200 Expect (err ).ToNot (HaveOccurred ())
146201 })
147202
0 commit comments