-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Verify buildpack installs extensions correctly
Protects against issues like paketo-buildpacks/packit#245
- Loading branch information
Showing
5 changed files
with
102 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package integration_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/paketo-buildpacks/occam" | ||
"github.com/sclevine/spec" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func testExtensionsLoadable(t *testing.T, context spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
Eventually = NewWithT(t).Eventually | ||
pack occam.Pack | ||
docker occam.Docker | ||
) | ||
|
||
it.Before(func() { | ||
pack = occam.NewPack() | ||
docker = occam.NewDocker() | ||
}) | ||
|
||
context("when building a simple app that loads extensions", func() { | ||
var ( | ||
image occam.Image | ||
container occam.Container | ||
name string | ||
source string | ||
) | ||
|
||
it.Before(func() { | ||
var err error | ||
name, err = occam.RandomName() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
it.After(func() { | ||
Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) | ||
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) | ||
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) | ||
Expect(os.RemoveAll(source)).To(Succeed()) | ||
}) | ||
|
||
// PHP extensions are notorious in going wrong. | ||
// Make sure this buildpack installs extensions correctly. | ||
it("creates a working OCI image that can load extensions", func() { | ||
var err error | ||
source, err = occam.Source(filepath.Join("testdata", "app_loading_exts")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
var logs fmt.Stringer | ||
image, logs, err = pack.WithNoColor().Build. | ||
WithPullPolicy("never"). | ||
WithBuildpacks( | ||
phpDistBuildpack, | ||
buildPlanBuildpack, | ||
). | ||
Execute(name, source) | ||
Expect(err).NotTo(HaveOccurred(), logs.String()) | ||
|
||
container, err = docker.Container.Run. | ||
WithCommand("php app.php"). | ||
// tells php to use the ini config file in the app | ||
WithEnv(map[string]string{"PHP_INI_SCAN_DIR": "/workspace/some-dir"}). | ||
Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Eventually(func() string { | ||
cLogs, err := docker.Container.Logs.Execute(container.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
return cLogs.String() | ||
}).Should( | ||
ContainSubstring("LOADED:zip"), | ||
) | ||
}) | ||
}) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
|
||
foreach (get_loaded_extensions() as $ext) { | ||
print("LOADED:" . $ext . "\n"); | ||
} | ||
|
||
while (true) { | ||
sleep(10); | ||
} | ||
?> |
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,5 @@ | ||
[[requires]] | ||
name = "php" | ||
|
||
[requires.metadata] | ||
launch = true |
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,2 @@ | ||
extension_dir=${PHP_EXTENSION_DIR} | ||
extension=zip.so |