Skip to content

Commit

Permalink
Update and fix nightly install tests (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Jan 24, 2025
1 parent 1bc086e commit af6a1bd
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 466 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/nightly-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ env:
jobs:

nightly-test:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
max-parallel: 4
matrix:
os: [ubuntu-latest]
test_suite:
- compat
- install
- upgrade
- project
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -34,8 +33,11 @@ jobs:
- name: Install musl-tools
run: "sudo apt-get install musl-tools"

- name: Remove rust-toolchain.toml
run: rm rust-toolchain.toml

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@d0e72ca3bfdc51937a4f81431ccbed269ef9f2a2
uses: dtolnay/rust-toolchain@stable
with:
components: "cargo,rustc,rust-std"
toolchain: "stable"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ gethostname = "0.5.0"
bitvec = "1.0.1"
nom = "7.1.3"
bitflags = "2.6"
renamore = "0.3.2"
renamore = {version="0.3.2", features = ["always-fallback"]}
anes = "0.2.0"
geozero = {version="0.14.0",features=["with-wkb"]}
geozero = {version="0.14.0", features=["with-wkb"]}

[dependencies.bzip2]
version = "*"
Expand Down
14 changes: 10 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@
in {
devShells.default = pkgs.mkShell {
buildInputs = common ++ [
(fenix_pkgs.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
})
(fenix_pkgs.combine [
(fenix_pkgs.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
})
(fenix_pkgs.targets.x86_64-unknown-linux-musl.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
})
])
];
};
};
Expand Down
60 changes: 14 additions & 46 deletions tests/common/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,28 @@ import asyncio
import sys
import edgedb
assert edgedb.connect(sys.argv[1]).query_one("SELECT 1+1") == 2
assert edgedb.create_client(sys.argv[1]).query_single("SELECT 1+1") == 2
async def test_async():
conn = await edgedb.async_connect(sys.argv[1])
return await conn.query_one("SELECT 1+1")
conn = edgedb.create_async_client(sys.argv[1])
return await conn.query_single("SELECT 1+1")
assert asyncio.get_event_loop().run_until_complete(test_async()) == 2
"###
}

pub fn edbconnect_js() -> &'static str {
r###"
const edgedb = require('edgedb')
edgedb.connect(process.argv[2])
.then(function(conn) {
return conn.queryOne('SELECT 1+1')
})
.then(function(value) {
console.assert(value == 2, value)
process.exit(0)
})
.catch(e => {
console.error("Error", e)
process.exit(1)
})
let client = edgedb.createClient(process.argv[2])
client.querySingle('SELECT 1+1')
.then(function(value) {
console.assert(value == 2, value)
process.exit(0)
})
.catch(e => {
console.error("Error", e)
process.exit(1)
})
"###
}

Expand Down Expand Up @@ -167,35 +165,6 @@ pub fn run(tagname: &str, script: &str) -> assert_cmd::assert::Assert {
.assert()
}

pub fn run_docker(tagname: &str, script: &str) -> assert_cmd::assert::Assert {
let script = format!(
r###"
export EDGEDB_SKIP_DOCKER_CHECK=yes
docker ps -q -f 'name=edgedb_test' | xargs -r docker container kill
docker system prune --all --force
docker volume list -q -f 'name=edgedb_test' | xargs -r docker volume rm
{script}
"###,
script = script
);
let path = if let Ok(path) = env::var("DOCKER_VOLUME_PATH") {
path.to_string()
} else {
"/var/run/docker.sock".to_string()
};
Command::new("docker")
.arg("run")
.arg("--rm")
.arg("-u")
.arg("1000")
.arg(format!("--volume={0}:{0}", path))
.arg("--net=host")
.arg(tagname)
.args(["bash", "-exc", &script])
.assert()
}

pub fn run_systemd(tagname: &str, script: &str) -> assert_cmd::assert::Assert {
let script = format!(
r###"
Expand All @@ -205,8 +174,7 @@ pub fn run_systemd(tagname: &str, script: &str) -> assert_cmd::assert::Assert {
/lib/systemd/systemd --user --log-level=debug &
{script}
"###,
script = script
"###
);
let script = format!(
r###"
Expand Down
87 changes: 31 additions & 56 deletions tests/github-nightly/common.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
pub fn dock_ubuntu(codename: &str) -> String {
format!(
r###"
FROM ubuntu:{codename}
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ca-certificates sudo gnupg2 apt-transport-https curl \
software-properties-common dbus-user-session
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
RUN apt-get update && apt-get install -y docker-ce-cli
RUN adduser --uid 1000 --home /home/user1 \
--shell /bin/bash --ingroup users --gecos "Test User" \
user1
ADD ./edgedb /usr/bin/edgedb
ADD ./sudoers /etc/sudoers
"###,
codename = codename
)
#[derive(Debug, Clone)]
pub enum Distro {
Ubuntu(&'static str),
Debian(&'static str),
}

pub fn dock_ubuntu_jspy(codename: &str) -> String {
impl Distro {
pub fn tag_name(&self) -> String {
match self {
Distro::Ubuntu(cn) => format!("test-ubuntu-{cn}"),
Distro::Debian(cn) => format!("test-debian-{cn}"),
}
}

pub fn dockerfile(&self) -> String {
match self {
Distro::Ubuntu(codename) => dock_ubuntu(codename),
Distro::Debian(codename) => dock_debian(codename),
}
}
}

pub fn dock_ubuntu(codename: &str) -> String {
format!(
r###"
FROM ubuntu:{codename}
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ca-certificates sudo gnupg2 apt-transport-https curl \
software-properties-common dbus-user-session \
python3-pip npm
software-properties-common dbus-user-session
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
Expand All @@ -40,29 +37,6 @@ pub fn dock_ubuntu_jspy(codename: &str) -> String {
RUN adduser --uid 1000 --home /home/user1 \
--shell /bin/bash --ingroup users --gecos "Test User" \
user1
RUN pip3 install edgedb
RUN npm install edgedb
ADD ./edgedb /usr/bin/edgedb
ADD ./sudoers /etc/sudoers
ADD ./edbconnect.py /usr/bin/edbconnect.py
ADD ./edbconnect.js /usr/bin/edbconnect.js
"###,
codename = codename
)
}

pub fn dock_centos(codename: u32) -> String {
format!(
r###"
FROM centos:{codename}
RUN yum -y install sudo yum-utils systemd
RUN yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
RUN yum -y install docker-ce-cli
RUN adduser --uid 1000 --home /home/user1 \
--shell /bin/bash --group users \
user1
ADD ./edgedb /usr/bin/edgedb
ADD ./sudoers /etc/sudoers
"###,
Expand All @@ -75,14 +49,15 @@ pub fn dock_debian(codename: &str) -> String {
r###"
FROM debian:{codename}
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ca-certificates sudo gnupg2 apt-transport-https curl \
software-properties-common dbus-user-session
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update && apt-get install -y ca-certificates curl sudo
RUN install -m 0755 -d /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
RUN chmod a+r /etc/apt/keyrings/docker.asc
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
> /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
RUN adduser --uid 1000 --home /home/user1 \
--shell /bin/bash --ingroup users --gecos "Test User" \
Expand Down
52 changes: 24 additions & 28 deletions tests/github-nightly/compat.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
use test_case::test_case;
use test_case::test_matrix;

use crate::common::{dock_centos, dock_debian, dock_ubuntu};
use crate::common::Distro;
use crate::docker::run_systemd;
use crate::docker::{build_image, Context};
use crate::measure::Time;

// stable
#[test_case("edbtest_bionic", &dock_ubuntu("bionic"), "")]
#[test_case("edbtest_xenial", &dock_ubuntu("xenial"), "")]
#[test_case("edbtest_centos8", &dock_centos(8), "")]
#[test_case("edbtest_buster", &dock_debian("buster"), "")]
#[test_case("edbtest_stretch", &dock_debian("stretch"), "")]
#[test_case("edbtest_focal", &dock_ubuntu("focal"), "")]
// alpha7
#[test_case("edbtest_bionic", &dock_ubuntu("bionic"), "--version=1-alpha7")]
#[test_case("edbtest_xenial", &dock_ubuntu("xenial"), "--version=1-alpha7")]
#[test_case("edbtest_centos8", &dock_centos(8), "--version=1-alpha7")]
#[test_case("edbtest_buster", &dock_debian("buster"), "--version=1-alpha7")]
#[test_case("edbtest_stretch", &dock_debian("stretch"), "--version=1-alpha7")]
#[test_case("edbtest_focal", &dock_ubuntu("focal"), "--version=1-alpha7")]
// nightly
#[test_case("edbtest_bionic", &dock_ubuntu("bionic"), "--nightly")]
#[test_case("edbtest_xenial", &dock_ubuntu("xenial"), "--nightly")]
#[test_case("edbtest_centos8", &dock_centos(8), "--nightly")]
#[test_case("edbtest_buster", &dock_debian("buster"), "--nightly")]
#[test_case("edbtest_stretch", &dock_debian("stretch"), "--nightly")]
#[test_case("edbtest_focal", &dock_ubuntu("focal"), "--nightly")]
fn cli(tagname: &str, dockerfile: &str, version: &str) -> anyhow::Result<()> {
#[test_matrix(
[
Distro::Ubuntu("focal"),
Distro::Ubuntu("bionic"),
Distro::Ubuntu("xenial"),
Distro::Debian("bookworm"),
Distro::Debian("bullseye"),
Distro::Debian("buster"),
],
[
"", // latest
"--version=4.8", // previous
"--nightly", // nightly
]
)]
fn cli(distro: Distro, version: &str) -> anyhow::Result<()> {
let dockerfile = distro.dockerfile();
let tag_name = distro.tag_name();

let _tm = Time::measure();
let context = Context::new()
.add_file("Dockerfile", dockerfile)?
.add_sudoers()?
.add_bin()?;
build_image(context, tagname)?;
build_image(context, &tag_name)?;
run_systemd(
tagname,
&tag_name,
&format!(
r###"
edgedb server install {version}
Expand All @@ -43,8 +40,7 @@ fn cli(tagname: &str, dockerfile: &str, version: &str) -> anyhow::Result<()> {
query "SELECT 1+1")
test "$val" = "2"
# changed in 1-alpha.7 due to dropping implicit __tid__
edgedb -Itest1 list-scalar-types --system
edgedb -Itest1 list scalars --system
"###,
version = version,
),
Expand Down
Loading

0 comments on commit af6a1bd

Please sign in to comment.