Qualifying for the foreign earned income exclusions requires you to pass one of two tests.

There are two separate tests that can qualify you to receive the foreign earned income exclusion and foreign housing exemption; the physical presence test and the bona fide resident test.

Physical Presence Test

In order to qualify for the physical presence test, you must be physically present in a foreign country for at least 330 days within a consecutive 12 month period. This test is simply based upon how long you stay in a foreign country and does not depend on how long you plan to stay abroad, nor the nature or purpose of your stay abroad. The 330 full days can include vacation time abroad and not just employment, as long as you are not physically present in the United States. A full day for the purpose of the physical presence test is considered a full 24 hour period beginning at midnight. Time spent traveling from the U.S. to a foreign country and vice versa does not count as a full day. If you pass over a foreign country while traveling from the United States, the first day you may count is the day following the day you departed from the U.S.

Bona Fide Resident Test

In order to be considered a bona fide resident and therefore qualify for the bona fide resident test, you must have established residence in a foreign country. Simply living in a foreign country for an entire year does not automatically qualify you as a bona fide resident. To determine if you meet the test of bona fide residence in a foreign country, you must determine your domicile. Your domicile is your permanent home, where you always return or intend to return to.
 In opposition to the physical presence test, the bona fide resident test takes into account the nature and purpose of your stay, and whether you plan to return to the United States or not. You must reside in a foreign country for an entire tax year (January 1st through December 31st). There is no limitation on travel back to the United States or elsewhere for vacation or business if you have claimed your residence in a foreign country.