Skip to content

Commit

Permalink
Stop using ostree trivial-httpd
Browse files Browse the repository at this point in the history
This isn't always available in recent ostree.
This work is based on #658 and
fixes ostreedev/ostree#723
  • Loading branch information
alexlarsson committed Mar 27, 2017
1 parent 82aad1c commit 32eb260
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions tests/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dist_installed_test_extra_scripts += \
tests/make-test-runtime.sh \
tests/make-test-bundles.sh \
tests/testpython.py \
tests/test-webserver.sh \
$(NULL)

dist_installed_test_data = \
Expand Down
5 changes: 3 additions & 2 deletions tests/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ setup_repo () {
GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh org.test.Platform bash ls cat echo readlink > /dev/null
GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-app.sh > /dev/null
update_repo
ostree trivial-httpd --autoexit --daemonize -p httpd-port repos
$(dirname $0)/test-webserver.sh repos
port=$(cat httpd-port)
FLATPAK_HTTP_PID=$(cat httpd-pid)
flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR}/pubring.gpg test-repo "http://127.0.0.1:${port}/test"
}

Expand Down Expand Up @@ -266,7 +267,7 @@ if ! /bin/kill -0 "$DBUS_SESSION_BUS_PID"; then
fi

cleanup () {
/bin/kill $DBUS_SESSION_BUS_PID
/bin/kill $DBUS_SESSION_BUS_PID ${FLATPAK_HTTP_PID:-}
gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye || true
fusermount -u $XDG_RUNTIME_DIR/doc || :
rm -rf $TEST_DATA_DIR
Expand Down
5 changes: 3 additions & 2 deletions tests/test-oci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ flatpak uninstall ${U} org.test.Hello
make_updated_app HTTP
${FLATPAK} build-bundle --oci repos/test oci/registry org.test.Hello

ostree trivial-httpd --autoexit --daemonize -p oci-port `pwd`/oci
ociport=$(cat oci-port)
$(dirname $0)/test-webserver.sh `pwd`/oci
ociport=$(cat httpd-port)
FLATPAK_HTTP_PID="${FLATPAK_HTTP_PID} $(cat httpd-pid)"

${FLATPAK} remote-add ${U} --oci oci-remote-http http://127.0.0.1:${ociport}/registry
${FLATPAK} install -v ${U} oci-remote-http org.test.Hello
Expand Down
16 changes: 14 additions & 2 deletions tests/testlibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ static char *flatpak_installationsdir;
static char *gpg_homedir;
static char *gpg_args;
static char *repo_url;
int httpd_pid = -1;

static const char *gpg_id = "7B0961FD";
const char *repo_name = "test-repo";
Expand Down Expand Up @@ -605,7 +606,8 @@ launch_httpd (void)
{
int status;
g_autoptr(GError) error = NULL;
char *argv[] = { "ostree", "trivial-httpd", "--autoexit", "--daemonize", "-p", "http-port", "repos", NULL };
g_autofree char *path = g_test_build_filename (G_TEST_DIST, "test-webserver.sh", NULL);
char *argv[] = {path , "repos", NULL };
GSpawnFlags flags = G_SPAWN_SEARCH_PATH;

if (g_test_verbose ())
Expand All @@ -629,11 +631,18 @@ add_remote (void)
char *argv[] = { "flatpak", "remote-add", "--user", "--gpg-import=", "name", "url", NULL };
g_autofree char *gpgimport = NULL;
g_autofree char *port = NULL;
g_autofree char *pid = NULL;
GSpawnFlags flags = G_SPAWN_SEARCH_PATH;

launch_httpd ();

g_file_get_contents ("http-port", &port, NULL, &error);
g_file_get_contents ("httpd-pid", &pid, NULL, &error);
g_assert_no_error (error);

httpd_pid = atoi (pid);
g_assert_cmpint (httpd_pid, !=, 0);

g_file_get_contents ("httpd-port", &port, NULL, &error);
g_assert_no_error (error);

if (port[strlen (port) - 1] == '\n')
Expand Down Expand Up @@ -824,6 +833,9 @@ global_teardown (void)
flags |= G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
}

if (httpd_pid != -1)
kill (httpd_pid, SIGKILL);

/* mostly ignore failure here */
if (!g_spawn_sync (NULL, (char **)argv, NULL, flags, NULL, NULL, NULL, NULL, &status, &error) ||
!g_spawn_check_exit_status (status, &error))
Expand Down

1 comment on commit 32eb260

@akshay2985
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to find tests/test-webserver.sh . Please tell me if this file is uploaded at some other location.

Please sign in to comment.