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

[DRAFT] End-to-end test service starting point #74

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

jadudm
Copy link
Contributor

@jadudm jadudm commented Jan 5, 2025

This PR could be kept a draft, or we could decide we want to bring the code in and iterate.

Unit tests are important in many ways, but I'd trade code coverage on things that don't matter for good end-to-end tests every day of the week. Put another way: I think unit tests matter on core operations: algorithmic transforms, logic, storage operations, etc., but there are other places where an end-to-end test, demonstrating the application logic, matter more to me (personally).

My personal vision (to be discussed) is that we have a way of running end-to-end tests on a daily basis. I would like to see:

  1. The app/stack deployed
  2. A crawl kicked off
  3. Indexing take place
  4. Searches run (via API, and eventually via Cypress or similar for SERP pages)
  5. Results compared to expected values

This e2e service may, or may not, be part of that. It provides a small service that serves static webpages. I pulled one page from NASA, and one from the FAC. Over time, we might pull more. I also excepted the domain e2e.gov (which perhaps should change) from various rules, so that we can set up a fake domain resolution and crawl this as if it were any other site (including locally). This way, we can run the tests in the local docker stack.

More thought will need to be given, however. Ideally, we would run against a staging deployment. This would serve for that, too, but may require more thought/development.

As stated... perhaps we keep this in draft, or perhaps we pull this in to the stack and play with it further.

jadudm added 3 commits January 1, 2025 16:48
This stands up a service on the local stack that serves pages, and
drives the process front-to-back so we can test the whole service.

Ultimately, we want this to be something we run against the `staging`
stack, but for now... this is better than nothing.
Now to integrate...
This lets fetch/walk/etc. hit the internal e2e container.
@jadudm jadudm changed the title [DRAFT] End-to-end service starting point [DRAFT] End-to-end test service starting point Jan 5, 2025
// If we are running against a fake domain, and in our local stack,
// we want this to pass. This will only work in the containerized env.
if env.IsContainerEnv() {
except, _ := regexp.MatchString(`^http://www.e2e.gov`, u.String())

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames High

This regular expression has an unescaped dot before 'e2e.gov', so it might match more hosts than expected when
the regular expression is used
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to escape the dot in the regular expression to ensure it matches only a literal dot and not any character. This can be done by replacing . with \\. in the regular expression. Additionally, using a raw string literal can make the regular expression more readable and avoid the need to escape backslashes.

Suggested changeset 1
internal/filtering/general.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/internal/filtering/general.go b/internal/filtering/general.go
--- a/internal/filtering/general.go
+++ b/internal/filtering/general.go
@@ -59,3 +59,3 @@
 	if env.IsContainerEnv() {
-		except, _ := regexp.MatchString(`^http://www.e2e.gov`, u.String())
+		except, _ := regexp.MatchString(`^http://www\.e2e\.gov`, u.String())
 		if except {
EOF
@@ -59,3 +59,3 @@
if env.IsContainerEnv() {
except, _ := regexp.MatchString(`^http://www.e2e.gov`, u.String())
except, _ := regexp.MatchString(`^http://www\.e2e\.gov`, u.String())
if except {
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant