-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Brad Davidson <[email protected]>
- Loading branch information
Showing
3 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package tests | ||
package etcdsnapshot | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package startup | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
testutil "github.com/rancher/rke2/tests/integration" | ||
"github.com/sirupsen/logrus" | ||
utilnet "k8s.io/apimachinery/pkg/util/net" | ||
) | ||
|
||
var ( | ||
serverLog *os.File | ||
serverArgs = []string{"--debug"} | ||
testLock int | ||
) | ||
|
||
var _ = BeforeSuite(func() { | ||
var err error | ||
testLock, err = testutil.AcquireTestLock() | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
var _ = Describe("startup tests", Ordered, func() { | ||
When("a default server is created", func() { | ||
It("starts successfully", func() { | ||
var err error | ||
serverLog, err = testutil.StartServer(serverArgs...) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("has the default components deployed", func() { | ||
Eventually(func() error { | ||
err := testutil.ServerReady() | ||
if err != nil { | ||
logrus.Info(err) | ||
} | ||
return err | ||
}, "240s", "15s").Should(Succeed()) | ||
}) | ||
It("dies cleanly", func() { | ||
Expect(testutil.KillServer(serverLog)).To(Succeed()) | ||
Expect(testutil.Cleanup(testLock)).To(Succeed()) | ||
}) | ||
}) | ||
When("a server is created with bind-address", func() { | ||
It("starts successfully", func() { | ||
hostIP, _ := utilnet.ChooseHostInterface() | ||
var err error | ||
serverLog, err = testutil.StartServer(append(serverArgs, "--bind-address", hostIP.String())...) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("has the default components deployed", func() { | ||
Eventually(func() error { | ||
err := testutil.ServerReady() | ||
if err != nil { | ||
logrus.Info(err) | ||
} | ||
return err | ||
}, "240s", "15s").Should(Succeed()) | ||
}) | ||
It("dies cleanly", func() { | ||
Expect(testutil.KillServer(serverLog)).To(Succeed()) | ||
Expect(testutil.Cleanup(testLock)).To(Succeed()) | ||
}) | ||
}) | ||
}) | ||
|
||
var failed bool | ||
var _ = AfterEach(func() { | ||
failed = failed || CurrentSpecReport().Failed() | ||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
if failed { | ||
testutil.SaveLog(serverLog, false) | ||
serverLog = nil | ||
} | ||
Expect(testutil.KillServer(serverLog)).To(Succeed()) | ||
Expect(testutil.Cleanup(testLock)).To(Succeed()) | ||
}) | ||
|
||
func Test_IntegrationStartup(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Startup Suite") | ||
} |