Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(naming): update name in the instance test #369

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion e2e/basic/build_from_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestBuildFromGit(t *testing.T) {
})

// Test logic

require.NoError(t, instance.Start(), "Error starting instance")

data, err := instance.GetFileBytes("/home/hello.txt")
Expand Down
22 changes: 11 additions & 11 deletions e2e/basic/external_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ func TestExternalFile(t *testing.T) {
t.Fatalf("Error creating executor: %v", err)
}

web, err := knuu.NewInstance("web")
server, err := knuu.NewInstance("server")
if err != nil {
t.Fatalf("Error creating instance '%v':", err)
}
err = web.SetImage("docker.io/nginx:latest")
err = server.SetImage("docker.io/nginx:latest")
if err != nil {
t.Fatalf("Error setting image '%v':", err)
}
web.AddPortTCP(80)
_, err = web.ExecuteCommand("mkdir", "-p", "/usr/share/nginx/html")
server.AddPortTCP(80)
_, err = server.ExecuteCommand("mkdir", "-p", "/usr/share/nginx/html")
if err != nil {
t.Fatalf("Error executing command '%v':", err)
}
Expand Down Expand Up @@ -59,36 +59,36 @@ func TestExternalFile(t *testing.T) {
t.Fatalf("Error syncing data to disk '%v':", err)
}

err = web.AddFile("/tmp/index.html", "/usr/share/nginx/html/index.html", "0:0")
err = server.AddFile("/tmp/index.html", "/usr/share/nginx/html/index.html", "0:0")
if err != nil {
t.Fatalf("Error adding file '%v':", err)
}
err = web.Commit()
err = server.Commit()
if err != nil {
t.Fatalf("Error committing instance: %v", err)
}

t.Cleanup(func() {
require.NoError(t, knuu.BatchDestroy(executor.Instance, web))
require.NoError(t, knuu.BatchDestroy(executor.Instance, server))
})

// Test logic

webIP, err := web.GetIP()
serverIP, err := server.GetIP()
if err != nil {
t.Fatalf("Error getting IP '%v':", err)
}

err = web.Start()
err = server.Start()
if err != nil {
t.Fatalf("Error starting instance: %v", err)
}
err = web.WaitInstanceIsRunning()
err = server.WaitInstanceIsRunning()
if err != nil {
t.Fatalf("Error waiting for instance to be running: %v", err)
}

wget, err := executor.ExecuteCommand("wget", "-q", "-O", "-", webIP)
wget, err := executor.ExecuteCommand("wget", "-q", "-O", "-", serverIP)
if err != nil {
t.Fatalf("Error executing command '%v':", err)
}
Expand Down
24 changes: 12 additions & 12 deletions e2e/basic/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,53 @@ func TestFile(t *testing.T) {
t.Fatalf("Error creating executor: %v", err)
}

web, err := knuu.NewInstance("web")
serverfile, err := knuu.NewInstance("serverfile")
if err != nil {
t.Fatalf("Error creating instance '%v':", err)
}
err = web.SetImage("docker.io/nginx:latest")
err = serverfile.SetImage("docker.io/nginx:latest")
if err != nil {
t.Fatalf("Error setting image '%v':", err)
}
web.AddPortTCP(80)
_, err = web.ExecuteCommand("mkdir", "-p", "/usr/share/nginx/html")
serverfile.AddPortTCP(80)
_, err = serverfile.ExecuteCommand("mkdir", "-p", "/usr/share/nginx/html")
if err != nil {
t.Fatalf("Error executing command '%v':", err)
}
err = web.AddFile("resources/html/index.html", "/usr/share/nginx/html/index.html", "0:0")
err = serverfile.AddFile("resources/html/index.html", "/usr/share/nginx/html/index.html", "0:0")
if err != nil {
t.Fatalf("Error adding file '%v':", err)
}
err = web.AddVolumeWithOwner("/usr/share/nginx/html", "1Gi", 0)
err = serverfile.AddVolumeWithOwner("/usr/share/nginx/html", "1Gi", 0)
if err != nil {
t.Fatalf("Error adding volume: %v", err)
}
err = web.Commit()
err = serverfile.Commit()
if err != nil {
t.Fatalf("Error committing instance: %v", err)
}

t.Cleanup(func() {
require.NoError(t, knuu.BatchDestroy(executor.Instance, web))
require.NoError(t, knuu.BatchDestroy(executor.Instance, serverfile))
})

// Test logic

webIP, err := web.GetIP()
serverfileIP, err := serverfile.GetIP()
if err != nil {
t.Fatalf("Error getting IP '%v':", err)
}

err = web.Start()
err = serverfile.Start()
if err != nil {
t.Fatalf("Error starting instance: %v", err)
}
err = web.WaitInstanceIsRunning()
err = serverfile.WaitInstanceIsRunning()
if err != nil {
t.Fatalf("Error waiting for instance to be running: %v", err)
}

wget, err := executor.ExecuteCommand("wget", "-q", "-O", "-", webIP)
wget, err := executor.ExecuteCommand("wget", "-q", "-O", "-", serverfileIP)
if err != nil {
t.Fatalf("Error executing command '%v':", err)
}
Expand Down
4 changes: 4 additions & 0 deletions e2e/basic/files_to_volumes_cm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func TestNoVolumesOneFile(t *testing.T) {
if err != nil {
t.Fatalf("Error executing command for '%v': %v", instanceName, err)
}
err = instance.AddVolumeWithOwner("/usr/share/nginx/html", "1Gi", 0)
if err != nil {
t.Fatalf("Error adding volume: %v", err)
}
err = instance.Commit()
if err != nil {
t.Fatalf("Error committing instance '%v': %v", instanceName, err)
Expand Down
Loading